Skip to content

Commit

Permalink
GXM: Support smart danmaku mask
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Jan 26, 2025
1 parent 146b354 commit 5ce3c94
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion scripts/psv/gxm.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apk update && \

# Install VDPM Dependencies
ADD . /vdpm
RUN vdpm sdl2 mbedtls libass harfbuzz fribidi freetype libpng libwebp && \
RUN vdpm mbedtls libass harfbuzz fribidi freetype libpng libwebp && \
adduser --gecos '' --disabled-password builder && \
echo 'builder ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/builder && \
chown -R builder:builder /vdpm && \
Expand Down
6 changes: 3 additions & 3 deletions scripts/psv/mpv_gxm/VITABUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pkgname=mpv
pkgver=a6f4a7e6c4b38626cf80e18987dd3bcfca78a4b5
pkgver=d0c1c749f54f225aeb304cf0534beb565a1b7270
pkgrel=3
url="https://mpv.io/"
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/xfangfang/mpv/archive/${pkgver}.tar.gz")
sha256sums=('SKIP')
depends=('sdl2' 'libass' 'ffmpeg')
depends=('libass' 'ffmpeg')

prepare() {
cd $pkgname-$pkgver
Expand All @@ -21,7 +21,7 @@ build() {
-Dlibavdevice=disabled \
-Dmanpage-build=disabled \
-Dhtml-build=disabled \
-Dsdl2=enabled \
-Dsdl2=disabled \
-Dlibmpv=true \
-Dgxm=enabled \
-Dvitashark=disabled \
Expand Down
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
4 changes: 2 additions & 2 deletions wiliwili/source/fragment/player_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ brls::View* PlayerSetting::getDefaultFocus() { return this->settings->getDefault

void PlayerSetting::setupCustomShaders() {
// TODO Fix: shaders cannot work with deko3d and ps4
#if !defined(_DEBUG) && (defined(BOREALIS_USE_DEKO3D) || defined(PS4))
// hide shader setting: deko3d and ps4
#if !defined(_DEBUG) && (defined(BOREALIS_USE_DEKO3D) || defined(PS4) || defined(__PSV__))
// hide shader setting: deko3d, psv and ps4
auto* cell = new brls::RadioCell();
cell->title->setText("wiliwili/dialog/not_supported"_i18n);
shaderBox->addView(cell);
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
6 changes: 6 additions & 0 deletions wiliwili/source/utils/config_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ extern in_addr_t secondary_dns;
#include <psp2/kernel/cpu.h>
#include <psp2/kernel/threadmgr/thread.h>
#include <psp2/vshbridge.h>
extern "C"
{
unsigned int _newlib_heap_size_user = 220 * 1024 * 1024;
unsigned int sceLibcHeapSize = 24 * 1024 * 1024;
unsigned int _pthread_stack_default_user = 2 * 1024 * 1024;
}
#endif

#ifdef _WIN32
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 @@ -535,7 +535,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
1 change: 1 addition & 0 deletions wiliwili/source/view/mpv_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ void MPVCore::init() {
.context = window->context,
.shader_patcher = window->shader_patcher,
.buffer_index = 0,
.msaa = SCE_GXM_MULTISAMPLE_4X,
};

mpv_render_param params[] = {{MPV_RENDER_PARAM_API_TYPE, (void *)MPV_RENDER_API_TYPE_GXM},
Expand Down

0 comments on commit 5ce3c94

Please sign in to comment.