Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 21b8e68

Browse files
authored
Remove calls to SkCanvas::flush() (#43684)
In https://skia-review.googlesource.com/c/skia/+/716476, Skia removed calls to SkCanvas::flush(). This replaces those calls that Flutter was making with what had been going on - calling GrDirectContext::flush() if the canvas was backed by a Ganesh backend. Raster-backed canvases did not need flushing. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
1 parent 18c176a commit 21b8e68

File tree

8 files changed

+17
-12
lines changed

8 files changed

+17
-12
lines changed

display_list/skia/dl_sk_canvas.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "flutter/fml/trace_event.h"
1010

1111
#include "third_party/skia/include/core/SkColorFilter.h"
12+
#include "third_party/skia/include/gpu/GrDirectContext.h"
13+
#include "third_party/skia/include/gpu/GrRecordingContext.h"
1214

1315
namespace flutter {
1416

@@ -374,7 +376,11 @@ void DlSkCanvasAdapter::DrawShadow(const SkPath& path,
374376
}
375377

376378
void DlSkCanvasAdapter::Flush() {
377-
delegate_->flush();
379+
auto dContext = GrAsDirectContext(delegate_->recordingContext());
380+
381+
if (dContext) {
382+
dContext->flushAndSubmit();
383+
}
378384
}
379385

380386
} // namespace flutter

display_list/testing/dl_rendering_unittests.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ class RenderEnvironment {
492492
renderer.Render(canvas, info);
493493
canvas->restoreToCount(restore_count);
494494

495-
canvas->flush();
496495
if (GrDirectContext* dContext =
497496
GrAsDirectContext(surface->recordingContext())) {
498497
dContext->flushAndSubmit(surface, /*syncCpu=*/true);

lib/ui/painting/image_encoding_impl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "third_party/skia/include/core/SkCanvas.h"
1010
#include "third_party/skia/include/core/SkImage.h"
1111
#include "third_party/skia/include/core/SkSurface.h"
12+
#include "third_party/skia/include/gpu/GrDirectContext.h"
1213
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
1314

1415
namespace flutter {
@@ -41,7 +42,9 @@ sk_sp<SkImage> ConvertToRasterUsingResourceContext(
4142
}
4243

4344
surface->getCanvas()->drawImage(image, 0, 0);
44-
surface->getCanvas()->flush();
45+
if (resource_context) {
46+
resource_context->flushAndSubmit();
47+
}
4548

4649
auto snapshot = surface->makeImageSnapshot();
4750

shell/common/rasterizer_unittests.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,6 @@ TEST(RasterizerTest, TeardownFreesResourceCache) {
990990

991991
SkPaint paint;
992992
sk_surface->getCanvas()->drawPaint(paint);
993-
sk_surface->getCanvas()->flush();
994993
context->flushAndSubmit(true);
995994

996995
EXPECT_EQ(context->getResourceCachePurgeableBytes(), 0ul);

shell/common/snapshot_controller_skia.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ sk_sp<SkImage> DrawSnapshot(
2323
}
2424

2525
draw_callback(surface->getCanvas());
26-
surface->getCanvas()->flush();
26+
auto dContext = GrAsDirectContext(surface->recordingContext());
27+
if (dContext) {
28+
dContext->flushAndSubmit();
29+
}
2730

2831
sk_sp<SkImage> device_snapshot;
2932
{

shell/gpu/gpu_surface_gl_skia.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ bool GPUSurfaceGLSkia::PresentSurface(const SurfaceFrame& frame,
268268
delegate_->GLContextSetDamageRegion(frame.submit_info().buffer_damage);
269269

270270
{
271-
TRACE_EVENT0("flutter", "SkCanvas::Flush");
272-
onscreen_surface_->getCanvas()->flush();
271+
TRACE_EVENT0("flutter", "GrDirectContext::flushAndSubmit");
272+
context_->flushAndSubmit();
273273
}
274274

275275
GLPresentInfo present_info = {

shell/platform/fuchsia/flutter/canvas_spy.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,4 @@ void DidDrawCanvas::onDrawEdgeAAImageSet2(const ImageSetEntry set[],
267267
did_draw_ = true;
268268
}
269269

270-
void DidDrawCanvas::onFlush() {}
271-
272270
} // namespace flutter

shell/platform/fuchsia/flutter/canvas_spy.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,6 @@ class DidDrawCanvas final : public SkCanvasVirtualEnforcer<SkNoDrawCanvas> {
248248
const SkPaint*,
249249
SrcRectConstraint) override;
250250

251-
// |SkCanvasVirtualEnforcer<SkNoDrawCanvas>|
252-
void onFlush() override;
253-
254251
void MarkDrawIfNonTransparentPaint(const SkPaint& paint);
255252

256253
FML_DISALLOW_COPY_AND_ASSIGN(DidDrawCanvas);

0 commit comments

Comments
 (0)