From 525ec2dda1c928445769ff84dcc0c14262798929 Mon Sep 17 00:00:00 2001 From: Dom Chen Date: Thu, 7 Dec 2023 16:57:59 +0800 Subject: [PATCH] Replace the incorrect term of 'isAdopted' with 'externallyOwned'. (#1966) --- .github/workflows/build.yml | 3 ++- DEPS | 2 +- include/pag/pag.h | 4 ++-- src/platform/ios/private/PAGSurfaceImpl.mm | 2 +- src/rendering/PAGSurface.cpp | 8 ++++---- src/rendering/PAGSurfaceFactory.cpp | 6 +++--- web/src/core/backend-context.ts | 10 ++++++---- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3299f48d3..bd4131d732 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -338,6 +338,7 @@ jobs: with: host: 'linux' target: 'desktop' + version: '6.6.1' dir: '${{github.workspace}}/qt/' install-deps: 'true' cache: 'true' @@ -346,7 +347,7 @@ jobs: - name: Build QT run: | mkdir -p third_party/tgfx/out/cache - node build_pag -s ./qt PAGViewer -DCMAKE_PREFIX_PATH="${{env.Qt5_Dir}}/lib/cmake" -o ./out/release/viewer -a x64 + node build_pag -s ./qt PAGViewer -DCMAKE_PREFIX_PATH="${{env.QT_ROOT_DIR}}/lib/cmake" -o ./out/release/viewer -a x64 - name: Save Third-Party Cache if: ${{ (github.event_name == 'push') && (steps.third-party-cache.outputs.cache-hit != 'true') }} diff --git a/DEPS b/DEPS index 6e56cdc11f..f7e5e61e60 100644 --- a/DEPS +++ b/DEPS @@ -12,7 +12,7 @@ }, { "url": "${PAG_GROUP}/tgfx.git", - "commit": "db29a2b93408f6ce3acee469f38cb5651bcee274", + "commit": "e28c647b5433f9ecb0672cd84e355401058c02dd", "dir": "third_party/tgfx" }, { diff --git a/include/pag/pag.h b/include/pag/pag.h index 4b5493d7e1..32128d89e1 100644 --- a/include/pag/pag.h +++ b/include/pag/pag.h @@ -1248,7 +1248,7 @@ class PAG_API PAGSurface { bool readPixels(ColorType colorType, AlphaType alphaType, void* dstPixels, size_t dstRowBytes); protected: - explicit PAGSurface(std::shared_ptr drawable, bool contextAdopted = false); + explicit PAGSurface(std::shared_ptr drawable, bool externalContext = false); virtual void onDraw(std::shared_ptr graphic, std::shared_ptr surface, RenderCache* cache); @@ -1259,7 +1259,7 @@ class PAG_API PAGSurface { PAGPlayer* pagPlayer = nullptr; std::shared_ptr rootLocker = nullptr; std::shared_ptr drawable = nullptr; - bool contextAdopted = false; + bool externalContext = false; GLRestorer* glRestorer = nullptr; bool draw(RenderCache* cache, std::shared_ptr graphic, BackendSemaphore* signalSemaphore, diff --git a/src/platform/ios/private/PAGSurfaceImpl.mm b/src/platform/ios/private/PAGSurfaceImpl.mm index 24a033dbb2..dccdfaaf88 100644 --- a/src/platform/ios/private/PAGSurfaceImpl.mm +++ b/src/platform/ios/private/PAGSurfaceImpl.mm @@ -71,7 +71,7 @@ + (PAGSurfaceImpl*)FromCVPixelBuffer:(CVPixelBufferRef)pixelBuffer { + (PAGSurfaceImpl*)FromCVPixelBuffer:(CVPixelBufferRef)pixelBuffer context:(EAGLContext*)eaglContext { - auto device = tgfx::EAGLDevice::MakeAdopted(eaglContext); + auto device = tgfx::EAGLDevice::MakeFrom(eaglContext); auto drawable = pag::HardwareBufferDrawable::MakeFrom(pixelBuffer, device); auto surface = pag::PAGSurface::MakeFrom(drawable); if (surface == nullptr) { diff --git a/src/rendering/PAGSurface.cpp b/src/rendering/PAGSurface.cpp index 1ca0741cbf..96cf0e9c46 100644 --- a/src/rendering/PAGSurface.cpp +++ b/src/rendering/PAGSurface.cpp @@ -28,8 +28,8 @@ namespace pag { -PAGSurface::PAGSurface(std::shared_ptr drawable, bool contextAdopted) - : drawable(std::move(drawable)), contextAdopted(contextAdopted) { +PAGSurface::PAGSurface(std::shared_ptr drawable, bool externalContext) + : drawable(std::move(drawable)), externalContext(externalContext) { rootLocker = std::make_shared(); } @@ -276,7 +276,7 @@ bool PAGSurface::hitTest(RenderCache* cache, std::shared_ptr graphic, f tgfx::Context* PAGSurface::lockContext(bool force) { auto context = drawable->lockContext(force); - if (context != nullptr && contextAdopted) { + if (context != nullptr && externalContext) { #ifndef PAG_BUILD_FOR_WEB glRestorer = new GLRestorer(tgfx::GLFunctions::Get(context)); #endif @@ -286,7 +286,7 @@ tgfx::Context* PAGSurface::lockContext(bool force) { } void PAGSurface::unlockContext() { - if (contextAdopted) { + if (externalContext) { delete glRestorer; glRestorer = nullptr; } diff --git a/src/rendering/PAGSurfaceFactory.cpp b/src/rendering/PAGSurfaceFactory.cpp index 788db3726e..e74e570216 100644 --- a/src/rendering/PAGSurfaceFactory.cpp +++ b/src/rendering/PAGSurfaceFactory.cpp @@ -46,20 +46,20 @@ std::shared_ptr PAGSurface::MakeFrom(const BackendRenderTarget& rend std::shared_ptr PAGSurface::MakeFrom(const BackendTexture& texture, ImageOrigin origin, bool forAsyncThread) { std::shared_ptr device = nullptr; - bool isAdopted = false; + bool externalContext = false; if (forAsyncThread) { auto sharedContext = tgfx::GLDevice::CurrentNativeHandle(); device = tgfx::GLDevice::Make(sharedContext); } if (device == nullptr) { device = tgfx::GLDevice::Current(); - isAdopted = true; + externalContext = true; } auto drawable = TextureDrawable::MakeFrom(device, ToTGFX(texture), ToTGFX(origin)); if (drawable == nullptr) { return nullptr; } - return std::shared_ptr(new PAGSurface(std::move(drawable), isAdopted)); + return std::shared_ptr(new PAGSurface(std::move(drawable), externalContext)); } std::shared_ptr PAGSurface::MakeOffscreen(int width, int height) { diff --git a/web/src/core/backend-context.ts b/web/src/core/backend-context.ts index 4b3a908bb7..d932defd6c 100644 --- a/web/src/core/backend-context.ts +++ b/web/src/core/backend-context.ts @@ -27,13 +27,13 @@ export class BackendContext { public handle: number; - private adopted: boolean; + private externallyOwned: boolean; private isDestroyed = false; private oldHandle = 0; - public constructor(handle: number, adopted = false) { + public constructor(handle: number, externallyOwned = false) { this.handle = handle; - this.adopted = adopted; + this.externallyOwned = externallyOwned; } public getContext(): WebGLRenderingContext | null { @@ -93,7 +93,9 @@ export class BackendContext { } public destroy(): void { - if (this.adopted) return; + if (this.externallyOwned) { + return; + } PAGModule.GL.deleteContext(this.handle); }