Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the out-of-bounds memory access crash when rendering paths with freetype. #2224

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "9d2d0128b3ed673654b41bf94acdc2b4fd9ffb41",
"commit": "9fee156304983ab2f80fa6515a54b8dd478faa39",
"dir": "third_party/tgfx"
},
{
Expand Down
16 changes: 15 additions & 1 deletion src/rendering/graphics/Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////

#include "Canvas.h"
#include "rendering/caches/RenderCache.h"
#include "tgfx/gpu/Surface.h"

namespace pag {
Expand All @@ -30,10 +31,23 @@ Canvas::Canvas(tgfx::Surface* surface, RenderCache* cache)
state = std::make_shared<CanvasState>();
}

Canvas::Canvas(tgfx::Canvas* canvas, pag::RenderCache* cache) : canvas(canvas), cache(cache) {
Canvas::Canvas(tgfx::Canvas* canvas, RenderCache* cache) : canvas(canvas), cache(cache) {
state = std::make_shared<CanvasState>();
}

tgfx::Context* Canvas::getContext() const {
return cache->getContext();
}

tgfx::Surface* Canvas::getSurface() const {
return canvas->getSurface();
}

const tgfx::SurfaceOptions* Canvas::surfaceOptions() const {
auto surface = canvas->getSurface();
return surface ? surface->options() : nullptr;
}

void Canvas::save() {
auto canvasState = std::make_shared<CanvasState>();
*canvasState = *state;
Expand Down
24 changes: 13 additions & 11 deletions src/rendering/graphics/Canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,11 @@ class Canvas {
return cache;
}

tgfx::Context* getContext() const {
return canvas->getContext();
}
tgfx::Context* getContext() const;

tgfx::Surface* getSurface() const {
return canvas->getSurface();
}
tgfx::Surface* getSurface() const;

const tgfx::SurfaceOptions* surfaceOptions() const {
return canvas->surfaceOptions();
}
const tgfx::SurfaceOptions* surfaceOptions() const;

void save();

Expand Down Expand Up @@ -106,8 +100,12 @@ class Canvas {
canvas->clipPath(path);
}

void clear(const tgfx::Color& color = tgfx::Color::Transparent()) {
canvas->clear(color);
void clear() {
canvas->clear();
}

void clearRect(const tgfx::Rect& rect, const tgfx::Color& color) {
canvas->clearRect(rect, color);
}

void drawLine(float x0, float y0, float x1, float y1, const tgfx::Paint& paint) {
Expand Down Expand Up @@ -139,6 +137,10 @@ class Canvas {
canvas->drawRoundRect(rect, radiusX, radiusY, createPaint(paint));
}

void drawRRect(const tgfx::RRect& rRect, const tgfx::Paint& paint) {
canvas->drawRRect(rRect, paint);
}

/**
* Draws a path using the current clip, matrix, and specified paint.
*/
Expand Down
Loading
Loading