Skip to content

Commit 52f46bf

Browse files
Hpartydomchen
andauthored
Update tgfx to the latest version. (#2742)
Co-authored-by: domrjchen <dom@idom.me>
1 parent 845fa4d commit 52f46bf

File tree

9 files changed

+8143
-8116
lines changed

9 files changed

+8143
-8116
lines changed

CMakeLists.txt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
2121

2222
# Options for building libpag
2323
option(PAG_USE_OPENGL "Allow use of OpenGL as GPU backend" ON)
24-
option(PAG_USE_SWIFTSHADER "Allow build with SwiftShader library" OFF)
24+
option(PAG_USE_SWIFTSHADER "Allow build with the SwiftShader library" OFF)
25+
option(PAG_USE_ANGLE "Allow build with the ANGLE library" OFF)
2526
option(PAG_USE_QT "Allow build with QT frameworks" OFF)
2627
option(PAG_USE_RTTR "Enable RTTR support" OFF)
2728
option(PAG_USE_HARFBUZZ "Enable HarfBuzz support" OFF)
@@ -76,12 +77,13 @@ endif ()
7677

7778
if (PAG_USE_QT)
7879
set(PAG_USE_SWIFTSHADER OFF)
80+
set(PAG_USE_ANGLE OFF)
81+
elseif (PAG_USE_SWIFTSHADER)
82+
set(PAG_USE_ANGLE OFF)
7983
endif ()
8084

81-
if (PAG_USE_QT OR PAG_USE_SWIFTSHADER)
85+
if (PAG_USE_QT OR PAG_USE_SWIFTSHADER OR PAG_USE_ANGLE)
8286
set(PAG_USE_OPENGL ON)
83-
else ()
84-
set(USE_NATIVE_PLATFORM ON)
8587
endif ()
8688

8789
if (PAG_USE_FFAVC)
@@ -201,6 +203,8 @@ elseif (PAG_USE_SWIFTSHADER)
201203
list(APPEND PAG_INCLUDES ${TGFX_DIR}/vendor/swiftshader/include)
202204
file(GLOB_RECURSE PLATFORM_FILES src/platform/swiftshader/*.*)
203205
list(APPEND PAG_FILES ${PLATFORM_FILES})
206+
else ()
207+
set(USE_NATIVE_PLATFORM ON)
204208
endif ()
205209

206210
if (PAG_USE_RTTR)
@@ -350,9 +354,16 @@ elseif (WIN32)
350354
list(APPEND PAG_DEFINES NOMINMAX _USE_MATH_DEFINES)
351355

352356
if (USE_NATIVE_PLATFORM)
353-
list(APPEND PAG_INCLUDES ${TGFX_DIR}/vendor/angle/include)
354-
file(GLOB ANGLE_LIBS ${TGFX_DIR}/vendor/angle/${PLATFORM}/${ARCH}/*${CMAKE_STATIC_LIBRARY_SUFFIX})
355-
list(APPEND PAG_STATIC_LIBS ${ANGLE_LIBS})
357+
if (PAG_USE_ANGLE)
358+
list(APPEND PAG_DEFINES PAG_USE_ANGLE)
359+
list(APPEND PAG_INCLUDES ${TGFX_DIR}/vendor/angle/include)
360+
file(GLOB ANGLE_LIBS ${TGFX_DIR}/vendor/angle/${PLATFORM}/${ARCH}/*${CMAKE_STATIC_LIBRARY_SUFFIX})
361+
list(APPEND PAG_STATIC_LIBS ${ANGLE_LIBS})
362+
else ()
363+
find_library(OPENGL_LIB opengl32)
364+
list(APPEND PAG_STATIC_LIBS ${OPENGL_LIB})
365+
endif ()
366+
356367
file(GLOB_RECURSE PLATFORM_FILES src/platform/win/*.*)
357368
list(APPEND PAG_FILES ${PLATFORM_FILES})
358369
endif ()
@@ -431,6 +442,7 @@ if (NOT HAS_CUSTOM_TGFX_DIR AND EXISTS ${TGFX_CACHE_DIR})
431442
list(APPEND TGFX_OPTIONS "-DTGFX_USE_OPENGL=${PAG_USE_OPENGL}")
432443
list(APPEND TGFX_OPTIONS "-DTGFX_USE_QT=${PAG_USE_QT}")
433444
list(APPEND TGFX_OPTIONS "-DTGFX_USE_SWIFTSHADER=${PAG_USE_SWIFTSHADER}")
445+
list(APPEND TGFX_OPTIONS "-DTGFX_USE_ANGLE=${PAG_USE_ANGLE}")
434446
list(APPEND TGFX_OPTIONS "-DTGFX_USE_FREETYPE=${PAG_USE_FREETYPE}")
435447
list(APPEND TGFX_OPTIONS "-DTGFX_USE_PNG_DECODE=${PAG_USE_PNG_DECODE}")
436448
list(APPEND TGFX_OPTIONS "-DTGFX_USE_PNG_ENCODE=${PAG_USE_PNG_ENCODE}")
@@ -462,6 +474,7 @@ else ()
462474
set(TGFX_USE_OPENGL ${PAG_USE_OPENGL})
463475
set(TGFX_USE_QT ${PAG_USE_QT})
464476
set(TGFX_USE_SWIFTSHADER ${PAG_USE_SWIFTSHADER})
477+
set(TGFX_USE_ANGLE ${PAG_USE_ANGLE})
465478
set(TGFX_USE_FREETYPE ${PAG_USE_FREETYPE})
466479
set(TGFX_USE_PNG_DECODE ${PAG_USE_PNG_DECODE})
467480
set(TGFX_USE_PNG_ENCODE ${PAG_USE_PNG_ENCODE})

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
{
1414
"url": "${PAG_GROUP}/tgfx.git",
15-
"commit": "235ce5e99ddb33cb8679702ea6b17a7098e10023",
15+
"commit": "2d4b07c7388b5a5825fbbc032a30bb7a05e6452b",
1616
"dir": "third_party/tgfx"
1717
},
1818
{

src/platform/win/GPUDrawable.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
#include "GPUDrawable.h"
2020
#include <windows.h>
2121
#include "base/utils/Log.h"
22+
#ifdef PAG_USE_ANGLE
2223
#include "tgfx/gpu/opengl/egl/EGLWindow.h"
24+
#else
25+
#include "tgfx/gpu/opengl/wgl/WGLWindow.h"
26+
#endif
2327

2428
namespace pag {
2529
std::shared_ptr<GPUDrawable> GPUDrawable::FromWindow(void* nativeWindow, void* sharedContext) {
@@ -56,8 +60,13 @@ std::shared_ptr<tgfx::Device> GPUDrawable::getDevice() {
5660
return nullptr;
5761
}
5862
if (window == nullptr) {
63+
#ifdef PAG_USE_ANGLE
5964
window = tgfx::EGLWindow::MakeFrom(reinterpret_cast<EGLNativeWindowType>(nativeWindow),
6065
sharedContext);
66+
#else
67+
window = tgfx::WGLWindow::MakeFrom(reinterpret_cast<HWND>(nativeWindow),
68+
reinterpret_cast<HGLRC>(sharedContext));
69+
#endif
6170
}
6271
return window ? window->getDevice() : nullptr;
6372
}
@@ -75,4 +84,4 @@ void GPUDrawable::onFreeSurface() {
7584
void GPUDrawable::present(tgfx::Context* context) {
7685
window->present(context);
7786
}
78-
} // namespace pag
87+
} // namespace pag

src/platform/win/GPUDrawable.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
namespace tgfx {
2424
class EGLWindow;
25-
}
25+
class WGLWindow;
26+
} // namespace tgfx
2627

2728
namespace pag {
2829
class GPUDrawable : public Drawable {
@@ -51,10 +52,14 @@ class GPUDrawable : public Drawable {
5152
private:
5253
int _width = 0;
5354
int _height = 0;
55+
#ifdef PAG_USE_ANGLE
5456
std::shared_ptr<tgfx::EGLWindow> window = nullptr;
57+
#else
58+
std::shared_ptr<tgfx::WGLWindow> window = nullptr;
59+
#endif
5560
void* nativeWindow = nullptr;
5661
void* sharedContext = nullptr;
5762

5863
GPUDrawable(void* nativeWindow, void* sharedContext);
5964
};
60-
} // namespace pag
65+
} // namespace pag

src/rendering/PAGAnimator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ std::vector<int> PAGAnimator::doAdvance() {
275275

276276
void PAGAnimator::doUpdate(bool setStartTime) {
277277
locker.lock();
278-
if (task != nullptr && task->executing()) {
278+
if (task != nullptr && task->status() == tgfx::TaskStatus::Executing) {
279279
locker.unlock();
280280
return;
281281
}

src/rendering/graphics/Canvas.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ class Canvas {
105105
canvas->clear();
106106
}
107107

108-
void clearRect(const tgfx::Rect& rect, const tgfx::Color& color) {
109-
canvas->clearRect(rect, color);
110-
}
111-
112108
void drawLine(float x0, float y0, float x1, float y1, const tgfx::Paint& paint) {
113109
canvas->drawLine(x0, y0, x1, y1, createPaint(paint));
114110
}

src/rendering/renderers/FilterRenderer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ void FilterRenderer::MeasureFilterBounds(tgfx::Rect* bounds, const FilterModifie
152152
}
153153
}
154154

155-
tgfx::Rect GetClipBounds(Canvas* canvas, const FilterList* filterList) {
155+
tgfx::Rect GetClipBounds(Canvas* canvas, const FilterList* filterList,
156+
const tgfx::Rect& contentBounds) {
156157
auto clip = canvas->getTotalClip();
158+
if (clip.isInverseFillType()) {
159+
return contentBounds;
160+
}
157161
auto matrix = canvas->getMatrix();
158162
if (filterList->useParentSizeInput) {
159163
tgfx::Matrix inverted = tgfx::Matrix::I();
@@ -359,7 +363,7 @@ void FilterRenderer::DrawWithFilter(Canvas* parentCanvas, const FilterModifier*
359363
auto filterList = MakeFilterList(modifier);
360364
auto contentBounds = GetContentBounds(filterList.get(), content);
361365
// 相对于content Bounds的clip Bounds
362-
auto clipBounds = GetClipBounds(parentCanvas, filterList.get());
366+
auto clipBounds = GetClipBounds(parentCanvas, filterList.get(), contentBounds);
363367

364368
auto contentScale = GetContentScale(parentCanvas, filterList->scaleFactorLimit,
365369
GetScaleFactor(filterList.get(), contentBounds));

0 commit comments

Comments
 (0)