Composite Embedded Views with the correct GrContext
PaintRecorder Canvases are not associated with GrContexts.
This commit is contained in:
@@ -80,6 +80,7 @@ class Layer {
|
||||
// layers.
|
||||
SkCanvas* internal_nodes_canvas;
|
||||
SkCanvas* leaf_nodes_canvas;
|
||||
GrContext* gr_context;
|
||||
ExternalViewEmbedder* view_embedder;
|
||||
const Stopwatch& frame_time;
|
||||
const Stopwatch& engine_time;
|
||||
|
||||
@@ -81,6 +81,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
|
||||
Layer::PaintContext context = {
|
||||
(SkCanvas*)&internal_nodes_canvas,
|
||||
frame.canvas(),
|
||||
frame.gr_context(),
|
||||
frame.view_embedder(),
|
||||
frame.context().frame_time(),
|
||||
frame.context().engine_time(),
|
||||
@@ -128,6 +129,7 @@ sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
|
||||
(SkCanvas*)&internal_nodes_canvas,
|
||||
canvas, // canvas
|
||||
nullptr,
|
||||
nullptr,
|
||||
unused_stopwatch, // frame time (dont care)
|
||||
unused_stopwatch, // engine time (dont care)
|
||||
unused_texture_registry, // texture registry (not supported)
|
||||
|
||||
@@ -48,7 +48,7 @@ TEST(PerformanceOverlayLayer, Gold) {
|
||||
flow::TextureRegistry unused_texture_registry;
|
||||
|
||||
flow::Layer::PaintContext paintContext = {
|
||||
nullptr, surface->getCanvas(), nullptr, mock_stopwatch,
|
||||
nullptr, surface->getCanvas(), nullptr, nullptr, mock_stopwatch,
|
||||
mock_stopwatch, unused_texture_registry, nullptr, false};
|
||||
|
||||
// Specify font file to ensure the same font across different operation
|
||||
|
||||
@@ -23,7 +23,8 @@ void TextureLayer::Paint(PaintContext& context) const {
|
||||
if (!texture) {
|
||||
return;
|
||||
}
|
||||
texture->Paint(*context.leaf_nodes_canvas, paint_bounds(), freeze_);
|
||||
texture->Paint(*context.leaf_nodes_canvas, paint_bounds(), freeze_,
|
||||
context.gr_context);
|
||||
}
|
||||
|
||||
} // namespace flow
|
||||
|
||||
@@ -166,6 +166,7 @@ void RasterCache::Prepare(PrerollContext* context,
|
||||
Layer::PaintContext paintContext = {
|
||||
(SkCanvas*)&internal_nodes_canvas,
|
||||
canvas,
|
||||
context->gr_context,
|
||||
nullptr,
|
||||
context->frame_time,
|
||||
context->engine_time,
|
||||
|
||||
@@ -22,7 +22,10 @@ class Texture {
|
||||
virtual ~Texture();
|
||||
|
||||
// Called from GPU thread.
|
||||
virtual void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) = 0;
|
||||
virtual void Paint(SkCanvas& canvas,
|
||||
const SkRect& bounds,
|
||||
bool freeze,
|
||||
GrContext* context) = 0;
|
||||
|
||||
// Called from GPU thread.
|
||||
virtual void OnGrContextCreated() = 0;
|
||||
|
||||
@@ -32,7 +32,8 @@ void AndroidExternalTextureGL::MarkNewFrameAvailable() {
|
||||
|
||||
void AndroidExternalTextureGL::Paint(SkCanvas& canvas,
|
||||
const SkRect& bounds,
|
||||
bool freeze) {
|
||||
bool freeze,
|
||||
GrContext* context) {
|
||||
if (state_ == AttachmentState::detached) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ class AndroidExternalTextureGL : public flow::Texture {
|
||||
|
||||
~AndroidExternalTextureGL() override;
|
||||
|
||||
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) override;
|
||||
void Paint(SkCanvas& canvas,
|
||||
const SkRect& bounds,
|
||||
bool freeze,
|
||||
GrContext* context) override;
|
||||
|
||||
void OnGrContextCreated() override;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class IOSExternalTextureGL : public flow::Texture {
|
||||
~IOSExternalTextureGL() override;
|
||||
|
||||
// Called from GPU thread.
|
||||
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) override;
|
||||
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, GrContext* context) override;
|
||||
|
||||
void OnGrContextCreated() override;
|
||||
|
||||
|
||||
@@ -22,7 +22,10 @@ IOSExternalTextureGL::IOSExternalTextureGL(int64_t textureId,
|
||||
|
||||
IOSExternalTextureGL::~IOSExternalTextureGL() = default;
|
||||
|
||||
void IOSExternalTextureGL::Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) {
|
||||
void IOSExternalTextureGL::Paint(SkCanvas& canvas,
|
||||
const SkRect& bounds,
|
||||
bool freeze,
|
||||
GrContext* context) {
|
||||
if (!cache_ref_) {
|
||||
CVOpenGLESTextureCacheRef cache;
|
||||
CVReturn err = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, NULL,
|
||||
@@ -58,8 +61,9 @@ void IOSExternalTextureGL::Paint(SkCanvas& canvas, const SkRect& bounds, bool fr
|
||||
CVOpenGLESTextureGetName(texture_ref_), GL_RGBA8_OES};
|
||||
GrBackendTexture backendTexture(bounds.width(), bounds.height(), GrMipMapped::kNo, textureInfo);
|
||||
sk_sp<SkImage> image =
|
||||
SkImage::MakeFromTexture(canvas.getGrContext(), backendTexture, kTopLeft_GrSurfaceOrigin,
|
||||
SkImage::MakeFromTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin,
|
||||
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
|
||||
FML_DCHECK(image) << "Failed to create SkImage from Texture.";
|
||||
if (image) {
|
||||
canvas.drawImage(image, bounds.x(), bounds.y());
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ EmbedderExternalTextureGL::~EmbedderExternalTextureGL() = default;
|
||||
// |flow::Texture|
|
||||
void EmbedderExternalTextureGL::Paint(SkCanvas& canvas,
|
||||
const SkRect& bounds,
|
||||
bool freeze) {
|
||||
bool freeze,
|
||||
GrContext* context) {
|
||||
if (auto image = external_texture_callback_(
|
||||
Id(), //
|
||||
canvas.getGrContext(), //
|
||||
|
||||
@@ -27,7 +27,10 @@ class EmbedderExternalTextureGL : public flow::Texture {
|
||||
sk_sp<SkImage> last_image_;
|
||||
|
||||
// |flow::Texture|
|
||||
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) override;
|
||||
void Paint(SkCanvas& canvas,
|
||||
const SkRect& bounds,
|
||||
bool freeze,
|
||||
GrContext* context) override;
|
||||
|
||||
// |flow::Texture|
|
||||
void OnGrContextCreated() override;
|
||||
|
||||
Reference in New Issue
Block a user