Skip to content

Commit

Permalink
Replace the incorrect term of 'isAdopted' with 'externallyOwned'. (#1966
Browse files Browse the repository at this point in the history
)
  • Loading branch information
domchen authored Dec 7, 2023
1 parent 02cbd4d commit 525ec2d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ jobs:
with:
host: 'linux'
target: 'desktop'
version: '6.6.1'
dir: '${{github.workspace}}/qt/'
install-deps: 'true'
cache: 'true'
Expand All @@ -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') }}
Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"url": "${PAG_GROUP}/tgfx.git",
"commit": "db29a2b93408f6ce3acee469f38cb5651bcee274",
"commit": "e28c647b5433f9ecb0672cd84e355401058c02dd",
"dir": "third_party/tgfx"
},
{
Expand Down
4 changes: 2 additions & 2 deletions include/pag/pag.h
Original file line number Diff line number Diff line change
Expand Up @@ -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> drawable, bool contextAdopted = false);
explicit PAGSurface(std::shared_ptr<Drawable> drawable, bool externalContext = false);

virtual void onDraw(std::shared_ptr<Graphic> graphic, std::shared_ptr<tgfx::Surface> surface,
RenderCache* cache);
Expand All @@ -1259,7 +1259,7 @@ class PAG_API PAGSurface {
PAGPlayer* pagPlayer = nullptr;
std::shared_ptr<std::mutex> rootLocker = nullptr;
std::shared_ptr<Drawable> drawable = nullptr;
bool contextAdopted = false;
bool externalContext = false;
GLRestorer* glRestorer = nullptr;

bool draw(RenderCache* cache, std::shared_ptr<Graphic> graphic, BackendSemaphore* signalSemaphore,
Expand Down
2 changes: 1 addition & 1 deletion src/platform/ios/private/PAGSurfaceImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/rendering/PAGSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

namespace pag {

PAGSurface::PAGSurface(std::shared_ptr<Drawable> drawable, bool contextAdopted)
: drawable(std::move(drawable)), contextAdopted(contextAdopted) {
PAGSurface::PAGSurface(std::shared_ptr<Drawable> drawable, bool externalContext)
: drawable(std::move(drawable)), externalContext(externalContext) {
rootLocker = std::make_shared<std::mutex>();
}

Expand Down Expand Up @@ -276,7 +276,7 @@ bool PAGSurface::hitTest(RenderCache* cache, std::shared_ptr<Graphic> 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
Expand All @@ -286,7 +286,7 @@ tgfx::Context* PAGSurface::lockContext(bool force) {
}

void PAGSurface::unlockContext() {
if (contextAdopted) {
if (externalContext) {
delete glRestorer;
glRestorer = nullptr;
}
Expand Down
6 changes: 3 additions & 3 deletions src/rendering/PAGSurfaceFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ std::shared_ptr<PAGSurface> PAGSurface::MakeFrom(const BackendRenderTarget& rend
std::shared_ptr<PAGSurface> PAGSurface::MakeFrom(const BackendTexture& texture, ImageOrigin origin,
bool forAsyncThread) {
std::shared_ptr<tgfx::Device> 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<PAGSurface>(new PAGSurface(std::move(drawable), isAdopted));
return std::shared_ptr<PAGSurface>(new PAGSurface(std::move(drawable), externalContext));
}

std::shared_ptr<PAGSurface> PAGSurface::MakeOffscreen(int width, int height) {
Expand Down
10 changes: 6 additions & 4 deletions web/src/core/backend-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -93,7 +93,9 @@ export class BackendContext {
}

public destroy(): void {
if (this.adopted) return;
if (this.externallyOwned) {
return;
}
PAGModule.GL.deleteContext(this.handle);
}

Expand Down

0 comments on commit 525ec2d

Please sign in to comment.