mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix offscreen rendering on iOS by not assuming that the default window bound framebuffer is 0
BUG= R=iansf@google.com Review URL: https://codereview.chromium.org/1183213007.
This commit is contained in:
parent
fd396d024d
commit
78754cd6a1
@ -10,12 +10,15 @@
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
GaneshSurface::GaneshSurface(GaneshContext* context, const gfx::Size& size) {
|
||||
GaneshSurface::GaneshSurface(intptr_t window_fbo,
|
||||
GaneshContext* context,
|
||||
const gfx::Size& size) {
|
||||
GrBackendRenderTargetDesc desc;
|
||||
desc.fWidth = size.width();
|
||||
desc.fHeight = size.height();
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
desc.fRenderTargetHandle = window_fbo;
|
||||
|
||||
auto target = skia::AdoptRef(context->gr()->wrapBackendRenderTarget(desc));
|
||||
DCHECK(target);
|
||||
|
||||
@ -15,11 +15,13 @@ namespace sky {
|
||||
namespace shell {
|
||||
|
||||
// GaneshSurface holds an SkSurface configured to render with Ganesh. Using the
|
||||
// provided GaneshContext, GaneshSurface wraps an SkSurface around FBO 0 so that
|
||||
// you can use |canvas()| to draw to FBO 0.
|
||||
// provided GaneshContext, GaneshSurface wraps an SkSurface around the window
|
||||
// bound FBO so that you can use |canvas()| to draw to that window bound FBO.
|
||||
class GaneshSurface {
|
||||
public:
|
||||
GaneshSurface(GaneshContext* context, const gfx::Size& size);
|
||||
GaneshSurface(intptr_t window_fbo,
|
||||
GaneshContext* context,
|
||||
const gfx::Size& size);
|
||||
~GaneshSurface();
|
||||
|
||||
SkCanvas* canvas() const { return surface_->getCanvas(); }
|
||||
|
||||
@ -54,7 +54,7 @@ void Rasterizer::Draw(skia::RefPtr<SkPicture> picture) {
|
||||
|
||||
EnsureGLContext();
|
||||
CHECK(context_->MakeCurrent(surface_.get()));
|
||||
EnsureGaneshSurface(size);
|
||||
EnsureGaneshSurface(surface_->GetBackingFrameBufferObject(), size);
|
||||
|
||||
DrawPicture(picture.get());
|
||||
surface_->SwapBuffers();
|
||||
@ -84,9 +84,11 @@ void Rasterizer::EnsureGLContext() {
|
||||
ganesh_context_.reset(new GaneshContext(context_.get()));
|
||||
}
|
||||
|
||||
void Rasterizer::EnsureGaneshSurface(const gfx::Size& size) {
|
||||
void Rasterizer::EnsureGaneshSurface(intptr_t window_fbo,
|
||||
const gfx::Size& size) {
|
||||
if (!ganesh_surface_ || ganesh_surface_->size() != size)
|
||||
ganesh_surface_.reset(new GaneshSurface(ganesh_context_.get(), size));
|
||||
ganesh_surface_.reset(
|
||||
new GaneshSurface(window_fbo, ganesh_context_.get(), size));
|
||||
}
|
||||
|
||||
} // namespace shell
|
||||
|
||||
@ -38,7 +38,7 @@ class Rasterizer : public GPUDelegate {
|
||||
|
||||
private:
|
||||
void EnsureGLContext();
|
||||
void EnsureGaneshSurface(const gfx::Size& size);
|
||||
void EnsureGaneshSurface(intptr_t window_fbo, const gfx::Size& size);
|
||||
void DrawPicture(SkPicture* picture);
|
||||
|
||||
scoped_refptr<gfx::GLShareGroup> share_group_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user