2011-04-13 Brian Salomon <bsalomon@google.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Apr 2011 14:33:25 +0000 (14:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Apr 2011 14:33:25 +0000 (14:33 +0000)
        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
Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp
Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp

index 3c6f3247b2ae589e38253cc00fe91817288b93bf..44849e5b3e306558d5d5db97eaae94263082d65c 100644 (file)
@@ -1,3 +1,18 @@
+2011-04-13  Brian Salomon  <bsalomon@google.com>
+
+        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  <caseq@chromium.org>
 
         Unreviewed. Fix chromium clang build problem:
 2011-04-13  Andrey Kosyakov  <caseq@chromium.org>
 
         Unreviewed. Fix chromium clang build problem:
index e559edb1b9b58ebc697b593ec0aa11d6340e44e6..94be2a06b09b9f08a7b489512ad7c054623cee63 100644 (file)
@@ -173,6 +173,29 @@ void DrawingBuffer::setGrContext(GrContext* context)
     // the SharedGraphicsContext3D object that is giving us the context.
     m_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
 
 }
 #endif
 
 }
index ed0c9cb97a5091dbd2411061b20709ab286def80..7d83e5f7bd1483773f847a2021511700e5cbabcb 100644 (file)
@@ -44,6 +44,7 @@
 
 #if ENABLE(SKIA_GPU)
 class GrContext;
 
 #if ENABLE(SKIA_GPU)
 class GrContext;
+struct GrPlatformSurfaceDesc;
 #endif
 
 namespace WebCore {
 #endif
 
 namespace WebCore {
@@ -102,6 +103,7 @@ public:
 
 #if ENABLE(SKIA_GPU)
     void setGrContext(GrContext* ctx);
 
 #if ENABLE(SKIA_GPU)
     void setGrContext(GrContext* ctx);
+    void getGrPlatformSurfaceDesc(GrPlatformSurfaceDesc*);
 #endif
 
     PassRefPtr<GraphicsContext3D> graphicsContext3D() const { return m_context; }
 #endif
 
     PassRefPtr<GraphicsContext3D> graphicsContext3D() const { return m_context; }
index e1ef9fa4a9508a653a4fdb9e4e016951a98b9444..34c2aff6cee053dedf17ef52cc77c0d5308f9747 100644 (file)
@@ -747,7 +747,12 @@ void PlatformContextSkia::setSharedGraphicsContext3D(SharedGraphicsContext3D* co
         gr->resetContext();
         drawingBuffer->setGrContext(gr);
 
         gr->resetContext();
         drawingBuffer->setGrContext(gr);
 
-        SkDeviceFactory* factory = new SkGpuDeviceFactory(gr, SkGpuDevice::Current3DApiRenderTarget());
+        GrPlatformSurfaceDesc drawBufDesc;
+        drawingBuffer->getGrPlatformSurfaceDesc(&drawBufDesc);
+        GrTexture* drawBufTex = static_cast<GrTexture*>(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);
         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);