Skip to content

Commit 28a46d5

Browse files
Qxyatiskakaushik
authored andcommitted
Composite Embedded Views with the correct GrContext
PaintRecorder Canvases are not associated with GrContexts.
1 parent 7af3f2b commit 28a46d5

12 files changed

+30
-10
lines changed

flow/layers/layer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class Layer {
8080
// layers.
8181
SkCanvas* internal_nodes_canvas;
8282
SkCanvas* leaf_nodes_canvas;
83+
GrContext* gr_context;
8384
ExternalViewEmbedder* view_embedder;
8485
const Stopwatch& frame_time;
8586
const Stopwatch& engine_time;

flow/layers/layer_tree.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
8181
Layer::PaintContext context = {
8282
(SkCanvas*)&internal_nodes_canvas,
8383
frame.canvas(),
84+
frame.gr_context(),
8485
frame.view_embedder(),
8586
frame.context().frame_time(),
8687
frame.context().engine_time(),
@@ -128,6 +129,7 @@ sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
128129
(SkCanvas*)&internal_nodes_canvas,
129130
canvas, // canvas
130131
nullptr,
132+
nullptr,
131133
unused_stopwatch, // frame time (dont care)
132134
unused_stopwatch, // engine time (dont care)
133135
unused_texture_registry, // texture registry (not supported)

flow/layers/performance_overlay_layer_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ TEST(PerformanceOverlayLayer, Gold) {
4848
flow::TextureRegistry unused_texture_registry;
4949

5050
flow::Layer::PaintContext paintContext = {
51-
nullptr, surface->getCanvas(), nullptr, mock_stopwatch,
51+
nullptr, surface->getCanvas(), nullptr, nullptr, mock_stopwatch,
5252
mock_stopwatch, unused_texture_registry, nullptr, false};
5353

5454
// Specify font file to ensure the same font across different operation

flow/layers/texture_layer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ void TextureLayer::Paint(PaintContext& context) const {
2323
if (!texture) {
2424
return;
2525
}
26-
texture->Paint(*context.leaf_nodes_canvas, paint_bounds(), freeze_);
26+
texture->Paint(*context.leaf_nodes_canvas, paint_bounds(), freeze_,
27+
context.gr_context);
2728
}
2829

2930
} // namespace flow

flow/raster_cache.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ void RasterCache::Prepare(PrerollContext* context,
166166
Layer::PaintContext paintContext = {
167167
(SkCanvas*)&internal_nodes_canvas,
168168
canvas,
169+
context->gr_context,
169170
nullptr,
170171
context->frame_time,
171172
context->engine_time,

flow/texture.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class Texture {
2222
virtual ~Texture();
2323

2424
// Called from GPU thread.
25-
virtual void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) = 0;
25+
virtual void Paint(SkCanvas& canvas,
26+
const SkRect& bounds,
27+
bool freeze,
28+
GrContext* context) = 0;
2629

2730
// Called from GPU thread.
2831
virtual void OnGrContextCreated() = 0;

shell/platform/android/android_external_texture_gl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ void AndroidExternalTextureGL::MarkNewFrameAvailable() {
3232

3333
void AndroidExternalTextureGL::Paint(SkCanvas& canvas,
3434
const SkRect& bounds,
35-
bool freeze) {
35+
bool freeze,
36+
GrContext* context) {
3637
if (state_ == AttachmentState::detached) {
3738
return;
3839
}

shell/platform/android/android_external_texture_gl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class AndroidExternalTextureGL : public flow::Texture {
1919

2020
~AndroidExternalTextureGL() override;
2121

22-
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) override;
22+
void Paint(SkCanvas& canvas,
23+
const SkRect& bounds,
24+
bool freeze,
25+
GrContext* context) override;
2326

2427
void OnGrContextCreated() override;
2528

shell/platform/darwin/ios/ios_external_texture_gl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class IOSExternalTextureGL : public flow::Texture {
1818
~IOSExternalTextureGL() override;
1919

2020
// Called from GPU thread.
21-
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) override;
21+
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, GrContext* context) override;
2222

2323
void OnGrContextCreated() override;
2424

shell/platform/darwin/ios/ios_external_texture_gl.mm

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

2323
IOSExternalTextureGL::~IOSExternalTextureGL() = default;
2424

25-
void IOSExternalTextureGL::Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) {
25+
void IOSExternalTextureGL::Paint(SkCanvas& canvas,
26+
const SkRect& bounds,
27+
bool freeze,
28+
GrContext* context) {
2629
if (!cache_ref_) {
2730
CVOpenGLESTextureCacheRef cache;
2831
CVReturn err = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, NULL,
@@ -58,8 +61,9 @@
5861
CVOpenGLESTextureGetName(texture_ref_), GL_RGBA8_OES};
5962
GrBackendTexture backendTexture(bounds.width(), bounds.height(), GrMipMapped::kNo, textureInfo);
6063
sk_sp<SkImage> image =
61-
SkImage::MakeFromTexture(canvas.getGrContext(), backendTexture, kTopLeft_GrSurfaceOrigin,
64+
SkImage::MakeFromTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin,
6265
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
66+
FML_DCHECK(image) << "Failed to create SkImage from Texture.";
6367
if (image) {
6468
canvas.drawImage(image, bounds.x(), bounds.y());
6569
}

shell/platform/embedder/embedder_external_texture_gl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ EmbedderExternalTextureGL::~EmbedderExternalTextureGL() = default;
2020
// |flow::Texture|
2121
void EmbedderExternalTextureGL::Paint(SkCanvas& canvas,
2222
const SkRect& bounds,
23-
bool freeze) {
23+
bool freeze,
24+
GrContext* context) {
2425
if (auto image = external_texture_callback_(
2526
Id(), //
2627
canvas.getGrContext(), //

shell/platform/embedder/embedder_external_texture_gl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class EmbedderExternalTextureGL : public flow::Texture {
2727
sk_sp<SkImage> last_image_;
2828

2929
// |flow::Texture|
30-
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) override;
30+
void Paint(SkCanvas& canvas,
31+
const SkRect& bounds,
32+
bool freeze,
33+
GrContext* context) override;
3134

3235
// |flow::Texture|
3336
void OnGrContextCreated() override;

0 commit comments

Comments
 (0)