Remove calls to SkCanvas::flush() (flutter/engine#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
This commit is contained in:
Kevin Lubick
2023-07-14 16:34:22 -04:00
committed by GitHub
parent 7dcc10184a
commit bdc24b3d18
8 changed files with 17 additions and 12 deletions

View File

@@ -9,6 +9,8 @@
#include "flutter/fml/trace_event.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrRecordingContext.h"
namespace flutter {
@@ -374,7 +376,11 @@ void DlSkCanvasAdapter::DrawShadow(const SkPath& path,
}
void DlSkCanvasAdapter::Flush() {
delegate_->flush();
auto dContext = GrAsDirectContext(delegate_->recordingContext());
if (dContext) {
dContext->flushAndSubmit();
}
}
} // namespace flutter

View File

@@ -492,7 +492,6 @@ class RenderEnvironment {
renderer.Render(canvas, info);
canvas->restoreToCount(restore_count);
canvas->flush();
if (GrDirectContext* dContext =
GrAsDirectContext(surface->recordingContext())) {
dContext->flushAndSubmit(surface, /*syncCpu=*/true);

View File

@@ -9,6 +9,7 @@
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
namespace flutter {
@@ -41,7 +42,9 @@ sk_sp<SkImage> ConvertToRasterUsingResourceContext(
}
surface->getCanvas()->drawImage(image, 0, 0);
surface->getCanvas()->flush();
if (resource_context) {
resource_context->flushAndSubmit();
}
auto snapshot = surface->makeImageSnapshot();

View File

@@ -990,7 +990,6 @@ TEST(RasterizerTest, TeardownFreesResourceCache) {
SkPaint paint;
sk_surface->getCanvas()->drawPaint(paint);
sk_surface->getCanvas()->flush();
context->flushAndSubmit(true);
EXPECT_EQ(context->getResourceCachePurgeableBytes(), 0ul);

View File

@@ -23,7 +23,10 @@ sk_sp<SkImage> DrawSnapshot(
}
draw_callback(surface->getCanvas());
surface->getCanvas()->flush();
auto dContext = GrAsDirectContext(surface->recordingContext());
if (dContext) {
dContext->flushAndSubmit();
}
sk_sp<SkImage> device_snapshot;
{

View File

@@ -268,8 +268,8 @@ bool GPUSurfaceGLSkia::PresentSurface(const SurfaceFrame& frame,
delegate_->GLContextSetDamageRegion(frame.submit_info().buffer_damage);
{
TRACE_EVENT0("flutter", "SkCanvas::Flush");
onscreen_surface_->getCanvas()->flush();
TRACE_EVENT0("flutter", "GrDirectContext::flushAndSubmit");
context_->flushAndSubmit();
}
GLPresentInfo present_info = {

View File

@@ -267,6 +267,4 @@ void DidDrawCanvas::onDrawEdgeAAImageSet2(const ImageSetEntry set[],
did_draw_ = true;
}
void DidDrawCanvas::onFlush() {}
} // namespace flutter

View File

@@ -248,9 +248,6 @@ class DidDrawCanvas final : public SkCanvasVirtualEnforcer<SkNoDrawCanvas> {
const SkPaint*,
SrcRectConstraint) override;
// |SkCanvasVirtualEnforcer<SkNoDrawCanvas>|
void onFlush() override;
void MarkDrawIfNonTransparentPaint(const SkPaint& paint);
FML_DISALLOW_COPY_AND_ASSIGN(DidDrawCanvas);