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:
Chinmay Garde 2015-06-16 09:51:34 -07:00
parent fd396d024d
commit 78754cd6a1
4 changed files with 15 additions and 8 deletions

View File

@ -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);

View File

@ -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(); }

View File

@ -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

View File

@ -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_;