Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f5f103a

Browse files
committed
report correct freed size when resurfacing
A little kludgey to force 2 calls in canvas.cc but 2 calls are necessary when changing size anyways, so it's the more general usage. TODO remove backends anyways Fixes Automattic#2514
1 parent 05a53d8 commit f5f103a

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

‎src/Canvas.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,8 @@ Canvas::resurface(Napi::Object This) {
907907
Napi::Value context;
908908

909909
if (This.Get("context").UnwrapTo(&context) && context.IsObject()) {
910-
backend()->recreateSurface();
910+
backend()->destroySurface();
911+
backend()->createSurface();
911912
// Reset context
912913
Context2d *context2d = Context2d::Unwrap(context.As<Napi::Object>());
913914
cairo_t *prev = context2d->context();

‎src/backend/Backend.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ void Backend::setCanvas(Canvas* _canvas)
2222
}
2323

2424

25-
cairo_surface_t* Backend::recreateSurface()
26-
{
27-
this->destroySurface();
28-
29-
return this->createSurface();
30-
}
31-
3225
DLL_PUBLIC cairo_surface_t* Backend::getSurface() {
3326
if (!surface) createSurface();
3427
return surface;
@@ -55,8 +48,9 @@ int Backend::getWidth()
5548
}
5649
void Backend::setWidth(int width_)
5750
{
51+
this->destroySurface();
5852
this->width = width_;
59-
this->recreateSurface();
53+
this->createSurface();
6054
}
6155

6256
int Backend::getHeight()
@@ -65,8 +59,9 @@ int Backend::getHeight()
6559
}
6660
void Backend::setHeight(int height_)
6761
{
62+
this->destroySurface();
6863
this->height = height_;
69-
this->recreateSurface();
64+
this->createSurface();
7065
}
7166

7267
bool Backend::isSurfaceValid(){

‎src/backend/Backend.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class Backend
3030
void setCanvas(Canvas* canvas);
3131

3232
virtual cairo_surface_t* createSurface() = 0;
33-
virtual cairo_surface_t* recreateSurface();
3433

3534
DLL_PUBLIC cairo_surface_t* getSurface();
3635
virtual void destroySurface();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /