From 758854f6367d5f29e9381a428ba2c60de3087eab Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Wed, 13 Apr 2011 14:33:25 +0000 Subject: [PATCH] 2011-04-13 Brian Salomon Reviewed by Kenneth Russell. Use new skia API for wrapping DrawingBuffer's FBO/Tex IDs in skia object https://bugs.webkit.org/show_bug.cgi?id=58363 No new tests needed, exercised by all existing canvas2d tests. * platform/graphics/chromium/DrawingBufferChromium.cpp: (WebCore::DrawingBuffer::getGrPlatformSurfaceDesc): * platform/graphics/gpu/DrawingBuffer.h: * platform/graphics/skia/PlatformContextSkia.cpp: (WebCore::PlatformContextSkia::setSharedGraphicsContext3D): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83733 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 15 ++++++++++++ .../chromium/DrawingBufferChromium.cpp | 23 +++++++++++++++++++ .../platform/graphics/gpu/DrawingBuffer.h | 2 ++ .../graphics/skia/PlatformContextSkia.cpp | 7 +++++- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 3c6f3247b2ae..44849e5b3e30 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,18 @@ +2011-04-13 Brian Salomon + + Reviewed by Kenneth Russell. + + Use new skia API for wrapping DrawingBuffer's FBO/Tex IDs in skia object + https://bugs.webkit.org/show_bug.cgi?id=58363 + + No new tests needed, exercised by all existing canvas2d tests. + + * platform/graphics/chromium/DrawingBufferChromium.cpp: + (WebCore::DrawingBuffer::getGrPlatformSurfaceDesc): + * platform/graphics/gpu/DrawingBuffer.h: + * platform/graphics/skia/PlatformContextSkia.cpp: + (WebCore::PlatformContextSkia::setSharedGraphicsContext3D): + 2011-04-13 Andrey Kosyakov Unreviewed. Fix chromium clang build problem: diff --git a/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp b/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp index e559edb1b9b5..94be2a06b09b 100644 --- a/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp @@ -173,6 +173,29 @@ void DrawingBuffer::setGrContext(GrContext* context) // the SharedGraphicsContext3D object that is giving us the context. m_grContext = context; } + +void DrawingBuffer::getGrPlatformSurfaceDesc(GrPlatformSurfaceDesc* desc) +{ + desc->fSurfaceType = kTextureRenderTarget_GrPlatformSurfaceType; + + desc->fPlatformTexture = m_colorBuffer; + if (multisample()) { + desc->fRenderTargetFlags = kIsMultisampled_GrPlatformRenderTargetFlagBit | kGrCanResolve_GrPlatformRenderTargetFlagBit; + desc->fPlatformRenderTarget = m_multisampleFBO; + desc->fPlatformResolveDestination = m_fbo; + } else { + desc->fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit; + desc->fPlatformRenderTarget = m_fbo; + desc->fPlatformResolveDestination = 0; + } + + desc->fWidth = m_size.width(); + desc->fHeight = m_size.height(); + desc->fConfig = kRGBA_8888_GrPixelConfig; + + desc->fStencilBits = (m_depthStencilBuffer || m_stencilBuffer) ? 8 : 0; +} + #endif } diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h index ed0c9cb97a50..7d83e5f7bd14 100644 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h +++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h @@ -44,6 +44,7 @@ #if ENABLE(SKIA_GPU) class GrContext; +struct GrPlatformSurfaceDesc; #endif namespace WebCore { @@ -102,6 +103,7 @@ public: #if ENABLE(SKIA_GPU) void setGrContext(GrContext* ctx); + void getGrPlatformSurfaceDesc(GrPlatformSurfaceDesc*); #endif PassRefPtr graphicsContext3D() const { return m_context; } diff --git a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp index e1ef9fa4a950..34c2aff6cee0 100644 --- a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp @@ -747,7 +747,12 @@ void PlatformContextSkia::setSharedGraphicsContext3D(SharedGraphicsContext3D* co gr->resetContext(); drawingBuffer->setGrContext(gr); - SkDeviceFactory* factory = new SkGpuDeviceFactory(gr, SkGpuDevice::Current3DApiRenderTarget()); + GrPlatformSurfaceDesc drawBufDesc; + drawingBuffer->getGrPlatformSurfaceDesc(&drawBufDesc); + GrTexture* drawBufTex = static_cast(gr->createPlatformSurface(drawBufDesc)); + SkDeviceFactory* factory = new SkGpuDeviceFactory(gr, drawBufTex); + drawBufTex->unref(); + SkDevice* device = factory->newDevice(m_canvas, SkBitmap::kARGB_8888_Config, drawingBuffer->size().width(), drawingBuffer->size().height(), false, false); m_canvas->setDevice(device)->unref(); m_canvas->setDeviceFactory(factory); -- 2.36.0