Skip to content

Commit

Permalink
GXM: Support danmaku mask
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Feb 6, 2025
1 parent 68ad8e9 commit d3a2e64
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions wiliwili/include/view/danmaku_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

#include "utils/event_helper.hpp"

#if defined(BOREALIS_USE_D3D11) || defined(BOREALIS_USE_OPENGL) && !defined(__PSV__) || defined(BOREALIS_USE_GXM)
#define DRAW_DANMAKU_MASK
#endif

// 每个分片内的svg数据,一般 1/30 s 一帧
class MaskSvg {
public:
Expand Down
2 changes: 1 addition & 1 deletion wiliwili/source/fragment/player_danmaku_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ PlayerDanmakuSetting::PlayerDanmakuSetting() {

auto& conf = ProgramConfig::instance();

#if defined(BOREALIS_USE_D3D11) || defined(BOREALIS_USE_OPENGL) && !defined(__PSV__)
#ifdef DRAW_DANMAKU_MASK
this->cellMask->init("wiliwili/player/danmaku/filter/mask"_i18n, DanmakuCore::DANMAKU_SMART_MASK, [](bool data) {
DanmakuCore::DANMAKU_SMART_MASK = data;
DanmakuCore::save();
Expand Down
2 changes: 1 addition & 1 deletion wiliwili/source/presenter/video_detail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ void VideoDetail::requestVideoPageDetail(const std::string& bvid, uint64_t cid,
BILI::get_page_detail(
bvid, cid,
[ASYNC_TOKEN, requestVideoHistory](const bilibili::VideoPageResult& result) {
#if defined(BOREALIS_USE_D3D11) || defined(BOREALIS_USE_OPENGL) && !defined(__PSV__)
#ifdef DRAW_DANMAKU_MASK
if (!result.mask_url.empty()) {
brls::Logger::debug("获取防遮挡数据: {}", result.mask_url);
DanmakuCore::instance().loadMaskData(result.mask_url);
Expand Down
5 changes: 3 additions & 2 deletions wiliwili/source/view/danmaku_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ std::vector<DanmakuItem> DanmakuCore::getDanmakuData() {
}

void DanmakuCore::drawMask(NVGcontext *vg, float x, float y, float width, float height) {
#if defined(BOREALIS_USE_OPENGL) || defined(BOREALIS_USE_D3D11)
#ifdef DRAW_DANMAKU_MASK
if (!DANMAKU_SMART_MASK || !maskData.isLoaded()) return;
double playbackTime = MPVCore::instance().playback_time;
/// 1. 先根据时间选择分片
Expand Down Expand Up @@ -533,7 +533,8 @@ void DanmakuCore::drawMask(NVGcontext *vg, float x, float y, float width, float
}

void DanmakuCore::clearMask(NVGcontext *vg, float x, float y, float width, float height) {
#if !defined(DEBUG_MASK) && (defined(BOREALIS_USE_OPENGL) || defined(BOREALIS_USE_D3D11))
#if !defined(DEBUG_MASK) && defined(DRAW_DANMAKU_MASK)
if (!DANMAKU_SMART_MASK || !maskData.isLoaded()) return;
if (maskTex > 0) {
nvgBeginPath(vg);
nvgRect(vg, x, y, width, height);
Expand Down

0 comments on commit d3a2e64

Please sign in to comment.