[chromium] Unify the drawing logic for different layer types that output textures...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Mar 2012 04:15:22 +0000 (04:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Mar 2012 04:15:22 +0000 (04:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81286

Patch by James Robinson <jamesr@chromium.org> on 2012-03-16
Reviewed by Adrienne Walker.

Source/WebCore:

Currently canvas 2d, webgl, and plugin layers all export a texture to the compositor that then needs to be
drawn.  There are a small set of operations that can be applied to the texture at draw time - do a Y flip,
stretch a subrect to the layer bounds, set the blend mode etc but they are fundamentally the same thing. This
collapses the nearly-redundant code into a single impl-side layer type for a texture-backed layer that can
handle the union of the bits needed for each layer type.

Canvas 2d, WebGL and plugin composited rendering are all covered by layout tests.

* WebCore.gypi:
* platform/graphics/chromium/Canvas2DLayerChromium.cpp:
(WebCore::Canvas2DLayerChromium::pushPropertiesTo):
* platform/graphics/chromium/CanvasLayerChromium.cpp:
(WebCore::CanvasLayerChromium::createCCLayerImpl):
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::drawQuad):
(WebCore::TexStretchTextureProgramBinding::set):
(WebCore::TexTransformTextureProgramBinding::set):
(WebCore::LayerRendererChromium::drawTextureQuad):
(WebCore::LayerRendererChromium::textureLayerProgramFlip):
(WebCore::LayerRendererChromium::textureLayerProgramStretch):
(WebCore::LayerRendererChromium::textureLayerProgramStretchFlip):
(WebCore::LayerRendererChromium::textureLayerTexRectProgram):
(WebCore::LayerRendererChromium::textureLayerTexRectProgramFlip):
(WebCore::LayerRendererChromium::cleanupSharedObjects):
* platform/graphics/chromium/LayerRendererChromium.h:
(WebCore):
(LayerRendererChromium):
* platform/graphics/chromium/PluginLayerChromium.cpp:
(WebCore::PluginLayerChromium::PluginLayerChromium):
(WebCore::PluginLayerChromium::createCCLayerImpl):
(WebCore::PluginLayerChromium::setIOSurfaceProperties):
(WebCore::PluginLayerChromium::pushPropertiesTo):
* platform/graphics/chromium/PluginLayerChromium.h:
(PluginLayerChromium):
* platform/graphics/chromium/WebGLLayerChromium.cpp:
(WebCore::WebGLLayerChromium::pushPropertiesTo):
* platform/graphics/chromium/cc/CCCanvasDrawQuad.cpp: Removed.
* platform/graphics/chromium/cc/CCCanvasDrawQuad.h: Removed.
* platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp: Removed.
* platform/graphics/chromium/cc/CCCanvasLayerImpl.h: Removed.
* platform/graphics/chromium/cc/CCDrawQuad.cpp:
(WebCore::CCDrawQuad::toTextureDrawQuad):
* platform/graphics/chromium/cc/CCDrawQuad.h:
(WebCore):
(CCDrawQuad):
* platform/graphics/chromium/cc/CCTextureDrawQuad.cpp: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCPluginDrawQuad.cpp.
(WebCore):
(WebCore::CCTextureDrawQuad::create):
(WebCore::CCTextureDrawQuad::CCTextureDrawQuad):
* platform/graphics/chromium/cc/CCTextureDrawQuad.h: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCPluginDrawQuad.h.
(WebCore):
(CCTextureDrawQuad):
(WebCore::CCTextureDrawQuad::textureId):
(WebCore::CCTextureDrawQuad::hasAlpha):
(WebCore::CCTextureDrawQuad::premultipliedAlpha):
(WebCore::CCTextureDrawQuad::uvRect):
(WebCore::CCTextureDrawQuad::flipped):
(WebCore::CCTextureDrawQuad::ioSurfaceSize):
(WebCore::CCTextureDrawQuad::ioSurfaceTextureId):
* platform/graphics/chromium/cc/CCTextureLayerImpl.cpp: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp.
(WebCore):
(WebCore::CCTextureLayerImpl::CCTextureLayerImpl):
(WebCore::CCTextureLayerImpl::~CCTextureLayerImpl):
(WebCore::CCTextureLayerImpl::willDraw):
(WebCore::CCTextureLayerImpl::appendQuads):
(WebCore::CCTextureLayerImpl::dumpLayerProperties):
(WebCore::CCTextureLayerImpl::didLoseContext):
(WebCore::CCTextureLayerImpl::setIOSurfaceProperties):
* platform/graphics/chromium/cc/CCTextureLayerImpl.h: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h.
(WebCore):
(CCTextureLayerImpl):
(WebCore::CCTextureLayerImpl::create):
(WebCore::CCTextureLayerImpl::textureId):
(WebCore::CCTextureLayerImpl::setTextureId):
(WebCore::CCTextureLayerImpl::setHasAlpha):
(WebCore::CCTextureLayerImpl::setPremultipliedAlpha):
(WebCore::CCTextureLayerImpl::setFlipped):
(WebCore::CCTextureLayerImpl::setUVRect):
(WebCore::CCTextureLayerImpl::layerTypeAsString):

Source/WebKit/chromium:

* tests/Canvas2DLayerChromiumTest.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111112 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h
Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/cc/CCCanvasDrawQuad.cpp [deleted file]
Source/WebCore/platform/graphics/chromium/cc/CCCanvasDrawQuad.h [deleted file]
Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp [deleted file]
Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h [deleted file]
Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.cpp
Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.h
Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.cpp [moved from Source/WebCore/platform/graphics/chromium/cc/CCPluginDrawQuad.cpp with 62% similarity]
Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.h [moved from Source/WebCore/platform/graphics/chromium/cc/CCPluginDrawQuad.h with 64% similarity]
Source/WebCore/platform/graphics/chromium/cc/CCTextureLayerImpl.cpp [moved from Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp with 80% similarity]
Source/WebCore/platform/graphics/chromium/cc/CCTextureLayerImpl.h [moved from Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h with 68% similarity]
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp

index c211f2e9b110de30d411ea40f78a64d94a62a0d7..c13fc6a3a10e25d4eda6e628e893b149a91e1a53 100644 (file)
@@ -1,3 +1,90 @@
+2012-03-16  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Unify the drawing logic for different layer types that output textures to the compositor
+        https://bugs.webkit.org/show_bug.cgi?id=81286
+
+        Reviewed by Adrienne Walker.
+
+        Currently canvas 2d, webgl, and plugin layers all export a texture to the compositor that then needs to be
+        drawn.  There are a small set of operations that can be applied to the texture at draw time - do a Y flip,
+        stretch a subrect to the layer bounds, set the blend mode etc but they are fundamentally the same thing. This
+        collapses the nearly-redundant code into a single impl-side layer type for a texture-backed layer that can
+        handle the union of the bits needed for each layer type.
+
+        Canvas 2d, WebGL and plugin composited rendering are all covered by layout tests.
+
+        * WebCore.gypi:
+        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
+        (WebCore::Canvas2DLayerChromium::pushPropertiesTo):
+        * platform/graphics/chromium/CanvasLayerChromium.cpp:
+        (WebCore::CanvasLayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::drawQuad):
+        (WebCore::TexStretchTextureProgramBinding::set):
+        (WebCore::TexTransformTextureProgramBinding::set):
+        (WebCore::LayerRendererChromium::drawTextureQuad):
+        (WebCore::LayerRendererChromium::textureLayerProgramFlip):
+        (WebCore::LayerRendererChromium::textureLayerProgramStretch):
+        (WebCore::LayerRendererChromium::textureLayerProgramStretchFlip):
+        (WebCore::LayerRendererChromium::textureLayerTexRectProgram):
+        (WebCore::LayerRendererChromium::textureLayerTexRectProgramFlip):
+        (WebCore::LayerRendererChromium::cleanupSharedObjects):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (WebCore):
+        (LayerRendererChromium):
+        * platform/graphics/chromium/PluginLayerChromium.cpp:
+        (WebCore::PluginLayerChromium::PluginLayerChromium):
+        (WebCore::PluginLayerChromium::createCCLayerImpl):
+        (WebCore::PluginLayerChromium::setIOSurfaceProperties):
+        (WebCore::PluginLayerChromium::pushPropertiesTo):
+        * platform/graphics/chromium/PluginLayerChromium.h:
+        (PluginLayerChromium):
+        * platform/graphics/chromium/WebGLLayerChromium.cpp:
+        (WebCore::WebGLLayerChromium::pushPropertiesTo):
+        * platform/graphics/chromium/cc/CCCanvasDrawQuad.cpp: Removed.
+        * platform/graphics/chromium/cc/CCCanvasDrawQuad.h: Removed.
+        * platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp: Removed.
+        * platform/graphics/chromium/cc/CCCanvasLayerImpl.h: Removed.
+        * platform/graphics/chromium/cc/CCDrawQuad.cpp:
+        (WebCore::CCDrawQuad::toTextureDrawQuad):
+        * platform/graphics/chromium/cc/CCDrawQuad.h:
+        (WebCore):
+        (CCDrawQuad):
+        * platform/graphics/chromium/cc/CCTextureDrawQuad.cpp: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCPluginDrawQuad.cpp.
+        (WebCore):
+        (WebCore::CCTextureDrawQuad::create):
+        (WebCore::CCTextureDrawQuad::CCTextureDrawQuad):
+        * platform/graphics/chromium/cc/CCTextureDrawQuad.h: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCPluginDrawQuad.h.
+        (WebCore):
+        (CCTextureDrawQuad):
+        (WebCore::CCTextureDrawQuad::textureId):
+        (WebCore::CCTextureDrawQuad::hasAlpha):
+        (WebCore::CCTextureDrawQuad::premultipliedAlpha):
+        (WebCore::CCTextureDrawQuad::uvRect):
+        (WebCore::CCTextureDrawQuad::flipped):
+        (WebCore::CCTextureDrawQuad::ioSurfaceSize):
+        (WebCore::CCTextureDrawQuad::ioSurfaceTextureId):
+        * platform/graphics/chromium/cc/CCTextureLayerImpl.cpp: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp.
+        (WebCore):
+        (WebCore::CCTextureLayerImpl::CCTextureLayerImpl):
+        (WebCore::CCTextureLayerImpl::~CCTextureLayerImpl):
+        (WebCore::CCTextureLayerImpl::willDraw):
+        (WebCore::CCTextureLayerImpl::appendQuads):
+        (WebCore::CCTextureLayerImpl::dumpLayerProperties):
+        (WebCore::CCTextureLayerImpl::didLoseContext):
+        (WebCore::CCTextureLayerImpl::setIOSurfaceProperties):
+        * platform/graphics/chromium/cc/CCTextureLayerImpl.h: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h.
+        (WebCore):
+        (CCTextureLayerImpl):
+        (WebCore::CCTextureLayerImpl::create):
+        (WebCore::CCTextureLayerImpl::textureId):
+        (WebCore::CCTextureLayerImpl::setTextureId):
+        (WebCore::CCTextureLayerImpl::setHasAlpha):
+        (WebCore::CCTextureLayerImpl::setPremultipliedAlpha):
+        (WebCore::CCTextureLayerImpl::setFlipped):
+        (WebCore::CCTextureLayerImpl::setUVRect):
+        (WebCore::CCTextureLayerImpl::layerTypeAsString):
+
 2012-03-16  Martin Robinson  <mrobinson@igalia.com>
 
         [Cairo] Text extent of shadowed text is calculated incorrectly
index bc8736546fc7b3d5adbe1d157f01032735651ac4..a5e845889a9fb025645ce8b865e9357c65e9fca0 100644 (file)
             'platform/graphics/chromium/cc/CCAnimationCurve.h',
             'platform/graphics/chromium/cc/CCAnimationEvents.cpp',
             'platform/graphics/chromium/cc/CCAnimationEvents.h',
-            'platform/graphics/chromium/cc/CCCanvasDrawQuad.cpp',
-            'platform/graphics/chromium/cc/CCCanvasDrawQuad.h',
-            'platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp',
-            'platform/graphics/chromium/cc/CCCanvasLayerImpl.h',
             'platform/graphics/chromium/cc/CCDamageTracker.cpp',
             'platform/graphics/chromium/cc/CCDamageTracker.h',
             'platform/graphics/chromium/cc/CCDebugBorderDrawQuad.cpp',
             'platform/graphics/chromium/cc/CCLayerSorter.h',
             'platform/graphics/chromium/cc/CCLayerTilingData.cpp',
             'platform/graphics/chromium/cc/CCLayerTilingData.h',
-            'platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp',
-            'platform/graphics/chromium/cc/CCLayerTreeHostCommon.h',
             'platform/graphics/chromium/cc/CCLayerTreeHost.cpp',
             'platform/graphics/chromium/cc/CCLayerTreeHost.h',
+            'platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp',
+            'platform/graphics/chromium/cc/CCLayerTreeHostCommon.h',
             'platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp',
             'platform/graphics/chromium/cc/CCLayerTreeHostImpl.h',
             'platform/graphics/chromium/cc/CCOcclusionTracker.cpp',
             'platform/graphics/chromium/cc/CCOverdrawMetrics.h',
             'platform/graphics/chromium/cc/CCPageScaleAnimation.cpp',
             'platform/graphics/chromium/cc/CCPageScaleAnimation.h',
-            'platform/graphics/chromium/cc/CCPluginDrawQuad.cpp',
-            'platform/graphics/chromium/cc/CCPluginDrawQuad.h',
-            'platform/graphics/chromium/cc/CCPluginLayerImpl.cpp',
-            'platform/graphics/chromium/cc/CCPluginLayerImpl.h',
             'platform/graphics/chromium/cc/CCProxy.cpp',
             'platform/graphics/chromium/cc/CCProxy.h',
             'platform/graphics/chromium/cc/CCQuadCuller.cpp',
             'platform/graphics/chromium/cc/CCSolidColorDrawQuad.h',
             'platform/graphics/chromium/cc/CCSolidColorLayerImpl.cpp',
             'platform/graphics/chromium/cc/CCSolidColorLayerImpl.h',
+            'platform/graphics/chromium/cc/CCTextureDrawQuad.cpp',
+            'platform/graphics/chromium/cc/CCTextureDrawQuad.h',
+            'platform/graphics/chromium/cc/CCTextureLayerImpl.cpp',
+            'platform/graphics/chromium/cc/CCTextureLayerImpl.h',
             'platform/graphics/chromium/cc/CCTextureUpdater.cpp',
             'platform/graphics/chromium/cc/CCTextureUpdater.h',
+            'platform/graphics/chromium/cc/CCThread.h',
             'platform/graphics/chromium/cc/CCTileDrawQuad.cpp',
             'platform/graphics/chromium/cc/CCTileDrawQuad.h',
             'platform/graphics/chromium/cc/CCTimingFunction.cpp',
             'platform/graphics/chromium/cc/CCTimingFunction.h',
-            'platform/graphics/chromium/cc/CCThread.h',
             'platform/graphics/chromium/cc/CCThreadProxy.cpp',
             'platform/graphics/chromium/cc/CCThreadProxy.h',
             'platform/graphics/chromium/cc/CCThreadTask.h',
index 5c0af2cfb93e4d00f7b906d54cbf0bc27b4c5425..7003826d70e18c32aadb184632122db5b221270d 100644 (file)
 
 #include "Canvas2DLayerChromium.h"
 
-#include "cc/CCCanvasLayerImpl.h"
-#include "cc/CCLayerTreeHost.h"
-#include "cc/CCTextureUpdater.h"
 #include "Extensions3DChromium.h"
 #include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h" // For the GLC() macro
+#include "cc/CCLayerTreeHost.h"
+#include "cc/CCTextureLayerImpl.h"
+#include "cc/CCTextureUpdater.h"
 
 #include "SkCanvas.h"
 
@@ -153,11 +153,11 @@ void Canvas2DLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
 {
     CanvasLayerChromium::pushPropertiesTo(layer);
 
-    CCCanvasLayerImpl* canvasLayer = static_cast<CCCanvasLayerImpl*>(layer);
+    CCTextureLayerImpl* textureLayer = static_cast<CCTextureLayerImpl*>(layer);
     if (m_useDoubleBuffering)
-        canvasLayer->setTextureId(m_frontTexture->textureId());
+        textureLayer->setTextureId(m_frontTexture->textureId());
     else
-        canvasLayer->setTextureId(m_backTextureId);
+        textureLayer->setTextureId(m_backTextureId);
 }
 
 void Canvas2DLayerChromium::unreserveContentsTexture()
index d533699af9f1f7aa08528d41f8b6bcc260b03531..4b6652384b9cbe7dc7445080cfe0f80c40b1d1d4 100644 (file)
@@ -34,9 +34,7 @@
 
 #include "CanvasLayerChromium.h"
 
-#include "cc/CCLayerImpl.h"
-#include "GraphicsContext3D.h"
-#include "LayerRendererChromium.h"
+#include "cc/CCTextureLayerImpl.h"
 
 namespace WebCore {
 
@@ -47,7 +45,7 @@ CanvasLayerChromium::CanvasLayerChromium()
 
 PassOwnPtr<CCLayerImpl> CanvasLayerChromium::createCCLayerImpl()
 {
-    return CCCanvasLayerImpl::create(m_layerId);
+    return CCTextureLayerImpl::create(m_layerId);
 }
 
 }
index acfd77232b2d44ca40f9ee72f11eecef0fc85393..27b3ede513257a7a9f46b9ae2492196a6c963990 100644 (file)
@@ -34,8 +34,6 @@
 #if USE(ACCELERATED_COMPOSITING)
 #include "LayerRendererChromium.h"
 
-#include "Canvas2DLayerChromium.h"
-#include "CanvasLayerTextureUpdater.h"
 #include "Extensions3DChromium.h"
 #include "FloatQuad.h"
 #include "GeometryBinding.h"
 #include "TrackingTextureAllocator.h"
 #include "TreeSynchronizer.h"
 #include "WebGLLayerChromium.h"
-#include "cc/CCCanvasDrawQuad.h"
 #include "cc/CCDamageTracker.h"
 #include "cc/CCDebugBorderDrawQuad.h"
 #include "cc/CCLayerImpl.h"
 #include "cc/CCLayerTreeHostCommon.h"
-#include "cc/CCPluginDrawQuad.h"
 #include "cc/CCProxy.h"
 #include "cc/CCRenderPass.h"
 #include "cc/CCRenderSurfaceDrawQuad.h"
 #include "cc/CCSolidColorDrawQuad.h"
+#include "cc/CCTextureDrawQuad.h"
 #include "cc/CCTileDrawQuad.h"
 #include "cc/CCVideoDrawQuad.h"
 #include "Extensions3D.h"
@@ -448,18 +445,15 @@ void LayerRendererChromium::drawQuad(const CCDrawQuad* quad, const FloatRect& su
     case CCDrawQuad::SolidColor:
         drawSolidColorQuad(quad->toSolidColorDrawQuad());
         break;
+    case CCDrawQuad::TextureContent:
+        drawTextureQuad(quad->toTextureDrawQuad());
+        break;
     case CCDrawQuad::TiledContent:
         drawTileQuad(quad->toTileDrawQuad());
         break;
-    case CCDrawQuad::CanvasContent:
-        drawCanvasQuad(quad->toCanvasDrawQuad());
-        break;
     case CCDrawQuad::VideoContent:
         drawVideoQuad(quad->toVideoDrawQuad());
         break;
-    case CCDrawQuad::PluginContent:
-        drawPluginQuad(quad->toPluginDrawQuad());
-        break;
     }
 }
 
@@ -696,31 +690,6 @@ void LayerRendererChromium::drawTileQuad(const CCTileDrawQuad* quad)
     drawTexturedQuad(quad->quadTransform(), tileRect.width(), tileRect.height(), quad->opacity(), localQuad, uniforms.matrixLocation, uniforms.alphaLocation, uniforms.pointLocation);
 }
 
-void LayerRendererChromium::drawCanvasQuad(const CCCanvasDrawQuad* quad)
-{
-    ASSERT(CCProxy::isImplThread());
-    const CCCanvasLayerImpl::Program* program = canvasLayerProgram();
-    ASSERT(program && program->initialized());
-    GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0));
-    GLC(context(), context()->bindTexture(GraphicsContext3D::TEXTURE_2D, quad->textureId()));
-    GLC(context(), context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
-    GLC(context(), context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
-
-    if (quad->hasAlpha() && !quad->premultipliedAlpha())
-        GLC(context(), context()->blendFunc(GraphicsContext3D::SRC_ALPHA, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
-
-    const IntSize& bounds = quad->quadRect().size();
-
-    GLC(context(), context()->useProgram(program->program()));
-    GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocation(), 0));
-    drawTexturedQuad(quad->layerTransform(), bounds.width(), bounds.height(), quad->opacity(), sharedGeometryQuad(),
-                                    program->vertexShader().matrixLocation(),
-                                    program->fragmentShader().alphaLocation(),
-                                    -1);
-
-    GLC(m_context.get(), m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
-}
-
 void LayerRendererChromium::drawYUV(const CCVideoDrawQuad* quad)
 {
     const CCVideoLayerImpl::YUVProgram* program = videoLayerYUVProgram();
@@ -871,7 +840,7 @@ void LayerRendererChromium::drawVideoQuad(const CCVideoDrawQuad* quad)
     }
 }
 
-struct PluginProgramBinding {
+struct TextureProgramBinding {
     template<class Program> void set(Program* program)
     {
         ASSERT(program && program->initialized());
@@ -886,10 +855,10 @@ struct PluginProgramBinding {
     int alphaLocation;
 };
 
-struct TexStretchPluginProgramBinding : PluginProgramBinding {
+struct TexStretchTextureProgramBinding : TextureProgramBinding {
     template<class Program> void set(Program* program)
     {
-        PluginProgramBinding::set(program);
+        TextureProgramBinding::set(program);
         offsetLocation = program->vertexShader().offsetLocation();
         scaleLocation = program->vertexShader().scaleLocation();
     }
@@ -897,66 +866,82 @@ struct TexStretchPluginProgramBinding : PluginProgramBinding {
     int scaleLocation;
 };
 
-struct TexTransformPluginProgramBinding : PluginProgramBinding {
+struct TexTransformTextureProgramBinding : TextureProgramBinding {
     template<class Program> void set(Program* program)
     {
-        PluginProgramBinding::set(program);
+        TextureProgramBinding::set(program);
         texTransformLocation = program->vertexShader().texTransformLocation();
     }
     int texTransformLocation;
 };
 
-void LayerRendererChromium::drawPluginQuad(const CCPluginDrawQuad* quad)
+void LayerRendererChromium::drawTextureQuad(const CCTextureDrawQuad* quad)
 {
     ASSERT(CCProxy::isImplThread());
-
+    unsigned matrixLocation = 0;
+    unsigned alphaLocation = 0;
     if (quad->ioSurfaceTextureId()) {
-        TexTransformPluginProgramBinding binding;
+        TexTransformTextureProgramBinding binding;
         if (quad->flipped())
-            binding.set(pluginLayerTexRectProgramFlip());
+            binding.set(textureLayerTexRectProgramFlip());
         else
-            binding.set(pluginLayerTexRectProgram());
+            binding.set(textureLayerTexRectProgram());
 
         GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0));
-        GLC(context(), context()->bindTexture(Extensions3D::TEXTURE_RECTANGLE_ARB, quad->ioSurfaceTextureId()));
 
         GLC(context(), context()->useProgram(binding.programId));
         GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
-        // Note: this code path ignores quad->uvRect().
-        GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceWidth(), quad->ioSurfaceHeight()));
-        const IntSize& bounds = quad->quadRect().size();
-        drawTexturedQuad(quad->layerTransform(), bounds.width(), bounds.height(), quad->opacity(), sharedGeometryQuad(),
-                                        binding.matrixLocation,
-                                        binding.alphaLocation,
-                                        -1);
-        GLC(context(), context()->bindTexture(Extensions3D::TEXTURE_RECTANGLE_ARB, 0));
+        GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height()));
+
+        matrixLocation = binding.matrixLocation;
+        alphaLocation = binding.alphaLocation;
+    } else if (quad->flipped() && quad->uvRect() == FloatRect(0, 0, 1, 1)) {
+        // A flipped quad with the default UV mapping is common enough to use a special shader.
+        // Canvas 2d and WebGL layers use this path always and plugin/external texture layers use this by default.
+        const CCTextureLayerImpl::ProgramFlip* program = textureLayerProgramFlip();
+        GLC(context(), context()->useProgram(program->program()));
+        GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocation(), 0));
+        matrixLocation = program->vertexShader().matrixLocation();
+        alphaLocation = program->fragmentShader().alphaLocation();
     } else {
-        TexStretchPluginProgramBinding binding;
+        TexStretchTextureProgramBinding binding;
         if (quad->flipped())
-            binding.set(pluginLayerProgramFlip());
+            binding.set(textureLayerProgramStretchFlip());
         else
-            binding.set(pluginLayerProgram());
-
-        GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0));
-        GLC(context(), context()->bindTexture(GraphicsContext3D::TEXTURE_2D, quad->textureId()));
-
-        // FIXME: setting the texture parameters every time is redundant. Move this code somewhere
-        // where it will only happen once per texture.
-        GLC(context, context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
-        GLC(context, context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
-        GLC(context, context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
-        GLC(context, context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
-
+            binding.set(textureLayerProgramStretch());
         GLC(context, context()->useProgram(binding.programId));
         GLC(context, context()->uniform1i(binding.samplerLocation, 0));
         GLC(context, context()->uniform2f(binding.offsetLocation, quad->uvRect().x(), quad->uvRect().y()));
         GLC(context, context()->uniform2f(binding.scaleLocation, quad->uvRect().width(), quad->uvRect().height()));
-        const IntSize& bounds = quad->quadRect().size();
-        drawTexturedQuad(quad->layerTransform(), bounds.width(), bounds.height(), quad->opacity(), sharedGeometryQuad(),
-                                        binding.matrixLocation,
-                                        binding.alphaLocation,
-                                        -1);
+
+        matrixLocation = binding.matrixLocation;
+        alphaLocation = binding.alphaLocation;
     }
+    GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0));
+
+    if (quad->ioSurfaceTextureId())
+        GLC(context(), context()->bindTexture(Extensions3D::TEXTURE_RECTANGLE_ARB, quad->ioSurfaceTextureId()));
+    else
+        GLC(context(), context()->bindTexture(GraphicsContext3D::TEXTURE_2D, quad->textureId()));
+
+    // FIXME: setting the texture parameters every time is redundant. Move this code somewhere
+    // where it will only happen once per texture.
+    GLC(context, context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
+    GLC(context, context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
+    GLC(context, context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
+    GLC(context, context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
+
+    if (quad->hasAlpha() && !quad->premultipliedAlpha())
+        GLC(context(), context()->blendFunc(GraphicsContext3D::SRC_ALPHA, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
+
+    const IntSize& bounds = quad->quadRect().size();
+
+    drawTexturedQuad(quad->layerTransform(), bounds.width(), bounds.height(), quad->opacity(), sharedGeometryQuad(), matrixLocation, alphaLocation, -1);
+
+    GLC(m_context.get(), m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
+
+    if (quad->ioSurfaceTextureId())
+        GLC(context(), context()->bindTexture(Extensions3D::TEXTURE_RECTANGLE_ARB, 0));
 }
 
 void LayerRendererChromium::finishDrawingFrame()
@@ -1371,59 +1356,59 @@ const CCTiledLayerImpl::ProgramSwizzleAA* LayerRendererChromium::tilerProgramSwi
     return m_tilerProgramSwizzleAA.get();
 }
 
-const CCCanvasLayerImpl::Program* LayerRendererChromium::canvasLayerProgram()
+const CCTextureLayerImpl::ProgramFlip* LayerRendererChromium::textureLayerProgramFlip()
 {
-    if (!m_canvasLayerProgram)
-        m_canvasLayerProgram = adoptPtr(new CCCanvasLayerImpl::Program(m_context.get()));
-    if (!m_canvasLayerProgram->initialized()) {
-        TRACE_EVENT("LayerRendererChromium::canvasLayerProgram::initialize", this, 0);
-        m_canvasLayerProgram->initialize(m_context.get());
+    if (!m_textureLayerProgramFlip)
+        m_textureLayerProgramFlip = adoptPtr(new CCTextureLayerImpl::ProgramFlip(m_context.get()));
+    if (!m_textureLayerProgramFlip->initialized()) {
+        TRACE_EVENT("LayerRendererChromium::textureLayerProgram::initialize", this, 0);
+        m_textureLayerProgramFlip->initialize(m_context.get());
     }
-    return m_canvasLayerProgram.get();
+    return m_textureLayerProgramFlip.get();
 }
 
-const CCPluginLayerImpl::Program* LayerRendererChromium::pluginLayerProgram()
+const CCTextureLayerImpl::ProgramStretch* LayerRendererChromium::textureLayerProgramStretch()
 {
-    if (!m_pluginLayerProgram)
-        m_pluginLayerProgram = adoptPtr(new CCPluginLayerImpl::Program(m_context.get()));
-    if (!m_pluginLayerProgram->initialized()) {
-        TRACE_EVENT("LayerRendererChromium::pluginLayerProgram::initialize", this, 0);
-        m_pluginLayerProgram->initialize(m_context.get());
+    if (!m_textureLayerProgramStretch)
+        m_textureLayerProgramStretch = adoptPtr(new CCTextureLayerImpl::ProgramStretch(m_context.get()));
+    if (!m_textureLayerProgramStretch->initialized()) {
+        TRACE_EVENT("LayerRendererChromium::textureLayerProgram::initialize", this, 0);
+        m_textureLayerProgramStretch->initialize(m_context.get());
     }
-    return m_pluginLayerProgram.get();
+    return m_textureLayerProgramStretch.get();
 }
 
-const CCPluginLayerImpl::ProgramFlip* LayerRendererChromium::pluginLayerProgramFlip()
+const CCTextureLayerImpl::ProgramStretchFlip* LayerRendererChromium::textureLayerProgramStretchFlip()
 {
-    if (!m_pluginLayerProgramFlip)
-        m_pluginLayerProgramFlip = adoptPtr(new CCPluginLayerImpl::ProgramFlip(m_context.get()));
-    if (!m_pluginLayerProgramFlip->initialized()) {
-        TRACE_EVENT("LayerRendererChromium::pluginLayerProgramFlip::initialize", this, 0);
-        m_pluginLayerProgramFlip->initialize(m_context.get());
+    if (!m_textureLayerProgramStretchFlip)
+        m_textureLayerProgramStretchFlip = adoptPtr(new CCTextureLayerImpl::ProgramStretchFlip(m_context.get()));
+    if (!m_textureLayerProgramStretchFlip->initialized()) {
+        TRACE_EVENT("LayerRendererChromium::textureLayerProgramStretchFlip::initialize", this, 0);
+        m_textureLayerProgramStretchFlip->initialize(m_context.get());
     }
-    return m_pluginLayerProgramFlip.get();
+    return m_textureLayerProgramStretchFlip.get();
 }
 
-const CCPluginLayerImpl::TexRectProgram* LayerRendererChromium::pluginLayerTexRectProgram()
+const CCTextureLayerImpl::TexRectProgram* LayerRendererChromium::textureLayerTexRectProgram()
 {
-    if (!m_pluginLayerTexRectProgram)
-        m_pluginLayerTexRectProgram = adoptPtr(new CCPluginLayerImpl::TexRectProgram(m_context.get()));
-    if (!m_pluginLayerTexRectProgram->initialized()) {
-        TRACE_EVENT("LayerRendererChromium::pluginLayerTexRectProgram::initialize", this, 0);
-        m_pluginLayerTexRectProgram->initialize(m_context.get());
+    if (!m_textureLayerTexRectProgram)
+        m_textureLayerTexRectProgram = adoptPtr(new CCTextureLayerImpl::TexRectProgram(m_context.get()));
+    if (!m_textureLayerTexRectProgram->initialized()) {
+        TRACE_EVENT("LayerRendererChromium::textureLayerTexRectProgram::initialize", this, 0);
+        m_textureLayerTexRectProgram->initialize(m_context.get());
     }
-    return m_pluginLayerTexRectProgram.get();
+    return m_textureLayerTexRectProgram.get();
 }
 
-const CCPluginLayerImpl::TexRectProgramFlip* LayerRendererChromium::pluginLayerTexRectProgramFlip()
+const CCTextureLayerImpl::TexRectProgramFlip* LayerRendererChromium::textureLayerTexRectProgramFlip()
 {
-    if (!m_pluginLayerTexRectProgramFlip)
-        m_pluginLayerTexRectProgramFlip = adoptPtr(new CCPluginLayerImpl::TexRectProgramFlip(m_context.get()));
-    if (!m_pluginLayerTexRectProgramFlip->initialized()) {
-        TRACE_EVENT("LayerRendererChromium::pluginLayerTexRectProgramFlip::initialize", this, 0);
-        m_pluginLayerTexRectProgramFlip->initialize(m_context.get());
+    if (!m_textureLayerTexRectProgramFlip)
+        m_textureLayerTexRectProgramFlip = adoptPtr(new CCTextureLayerImpl::TexRectProgramFlip(m_context.get()));
+    if (!m_textureLayerTexRectProgramFlip->initialized()) {
+        TRACE_EVENT("LayerRendererChromium::textureLayerTexRectProgramFlip::initialize", this, 0);
+        m_textureLayerTexRectProgramFlip->initialize(m_context.get());
     }
-    return m_pluginLayerTexRectProgramFlip.get();
+    return m_textureLayerTexRectProgramFlip.get();
 }
 
 const CCVideoLayerImpl::RGBAProgram* LayerRendererChromium::videoLayerRGBAProgram()
@@ -1480,6 +1465,16 @@ void LayerRendererChromium::cleanupSharedObjects()
         m_borderProgram->cleanup(m_context.get());
     if (m_headsUpDisplayProgram)
         m_headsUpDisplayProgram->cleanup(m_context.get());
+    if (m_textureLayerProgramFlip)
+        m_textureLayerProgramFlip->cleanup(m_context.get());
+    if (m_textureLayerProgramStretch)
+        m_textureLayerProgramStretch->cleanup(m_context.get());
+    if (m_textureLayerProgramStretchFlip)
+        m_textureLayerProgramStretchFlip->cleanup(m_context.get());
+    if (m_textureLayerTexRectProgram)
+        m_textureLayerTexRectProgram->cleanup(m_context.get());
+    if (m_textureLayerTexRectProgramFlip)
+        m_textureLayerTexRectProgramFlip->cleanup(m_context.get());
     if (m_tilerProgram)
         m_tilerProgram->cleanup(m_context.get());
     if (m_tilerProgramOpaque)
@@ -1492,16 +1487,6 @@ void LayerRendererChromium::cleanupSharedObjects()
         m_tilerProgramAA->cleanup(m_context.get());
     if (m_tilerProgramSwizzleAA)
         m_tilerProgramSwizzleAA->cleanup(m_context.get());
-    if (m_canvasLayerProgram)
-        m_canvasLayerProgram->cleanup(m_context.get());
-    if (m_pluginLayerProgram)
-        m_pluginLayerProgram->cleanup(m_context.get());
-    if (m_pluginLayerProgramFlip)
-        m_pluginLayerProgramFlip->cleanup(m_context.get());
-    if (m_pluginLayerTexRectProgram)
-        m_pluginLayerTexRectProgram->cleanup(m_context.get());
-    if (m_pluginLayerTexRectProgramFlip)
-        m_pluginLayerTexRectProgramFlip->cleanup(m_context.get());
     if (m_renderSurfaceMaskProgram)
         m_renderSurfaceMaskProgram->cleanup(m_context.get());
     if (m_renderSurfaceProgram)
@@ -1521,17 +1506,17 @@ void LayerRendererChromium::cleanupSharedObjects()
 
     m_borderProgram.clear();
     m_headsUpDisplayProgram.clear();
+    m_textureLayerProgramFlip.clear();
+    m_textureLayerProgramStretch.clear();
+    m_textureLayerProgramStretchFlip.clear();
+    m_textureLayerTexRectProgram.clear();
+    m_textureLayerTexRectProgramFlip.clear();
     m_tilerProgram.clear();
     m_tilerProgramOpaque.clear();
     m_tilerProgramSwizzle.clear();
     m_tilerProgramSwizzleOpaque.clear();
     m_tilerProgramAA.clear();
     m_tilerProgramSwizzleAA.clear();
-    m_canvasLayerProgram.clear();
-    m_pluginLayerProgram.clear();
-    m_pluginLayerProgramFlip.clear();
-    m_pluginLayerTexRectProgram.clear();
-    m_pluginLayerTexRectProgramFlip.clear();
     m_renderSurfaceMaskProgram.clear();
     m_renderSurfaceProgram.clear();
     m_renderSurfaceMaskProgramAA.clear();
index a6876e5d56743f4e195362291c6e9e003e6fd6bd..52ea87c133b157f1a5e0a8820addf63161f08d63 100644 (file)
 #include "LayerChromium.h"
 #include "TrackingTextureAllocator.h"
 #include "VideoLayerChromium.h"
-#include "cc/CCCanvasLayerImpl.h"
 #include "cc/CCDrawQuad.h"
 #include "cc/CCHeadsUpDisplay.h"
 #include "cc/CCLayerTreeHost.h"
-#include "cc/CCPluginLayerImpl.h"
+#include "cc/CCTextureLayerImpl.h"
 #include "cc/CCVideoLayerImpl.h"
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
@@ -57,6 +56,7 @@ namespace WebCore {
 class CCHeadsUpDisplay;
 class CCLayerImpl;
 class CCRenderPass;
+class CCTextureDrawQuad;
 class GeometryBinding;
 class GraphicsContext3D;
 class TrackingTextureAllocator;
@@ -121,17 +121,17 @@ public:
     const CCRenderSurface::ProgramAA* renderSurfaceProgramAA();
     const CCRenderSurface::MaskProgram* renderSurfaceMaskProgram();
     const CCRenderSurface::MaskProgramAA* renderSurfaceMaskProgramAA();
+    const CCTextureLayerImpl::ProgramFlip* textureLayerProgramFlip();
+    const CCTextureLayerImpl::ProgramStretch* textureLayerProgramStretch();
+    const CCTextureLayerImpl::ProgramStretchFlip* textureLayerProgramStretchFlip();
+    const CCTextureLayerImpl::TexRectProgram* textureLayerTexRectProgram();
+    const CCTextureLayerImpl::TexRectProgramFlip* textureLayerTexRectProgramFlip();
     const CCTiledLayerImpl::Program* tilerProgram();
     const CCTiledLayerImpl::ProgramOpaque* tilerProgramOpaque();
     const CCTiledLayerImpl::ProgramAA* tilerProgramAA();
     const CCTiledLayerImpl::ProgramSwizzle* tilerProgramSwizzle();
     const CCTiledLayerImpl::ProgramSwizzleOpaque* tilerProgramSwizzleOpaque();
     const CCTiledLayerImpl::ProgramSwizzleAA* tilerProgramSwizzleAA();
-    const CCCanvasLayerImpl::Program* canvasLayerProgram();
-    const CCPluginLayerImpl::Program* pluginLayerProgram();
-    const CCPluginLayerImpl::ProgramFlip* pluginLayerProgramFlip();
-    const CCPluginLayerImpl::TexRectProgram* pluginLayerTexRectProgram();
-    const CCPluginLayerImpl::TexRectProgramFlip* pluginLayerTexRectProgramFlip();
     const CCVideoLayerImpl::RGBAProgram* videoLayerRGBAProgram();
     const CCVideoLayerImpl::YUVProgram* videoLayerYUVProgram();
     const CCVideoLayerImpl::NativeTextureProgram* videoLayerNativeTextureProgram();
@@ -168,10 +168,9 @@ private:
     void drawDebugBorderQuad(const CCDebugBorderDrawQuad*);
     void drawRenderSurfaceQuad(const CCRenderSurfaceDrawQuad*);
     void drawSolidColorQuad(const CCSolidColorDrawQuad*);
+    void drawTextureQuad(const CCTextureDrawQuad*);
     void drawTileQuad(const CCTileDrawQuad*);
-    void drawCanvasQuad(const CCCanvasDrawQuad*);
     void drawVideoQuad(const CCVideoDrawQuad*);
-    void drawPluginQuad(const CCPluginDrawQuad*);
 
     ManagedTexture* getOffscreenLayerTexture();
     void copyPlaneToTexture(const CCVideoDrawQuad*, const void* plane, int index);
@@ -222,17 +221,17 @@ private:
     OwnPtr<GeometryBinding> m_sharedGeometry;
     OwnPtr<LayerChromium::BorderProgram> m_borderProgram;
     OwnPtr<CCHeadsUpDisplay::Program> m_headsUpDisplayProgram;
+    OwnPtr<CCTextureLayerImpl::ProgramFlip> m_textureLayerProgramFlip;
+    OwnPtr<CCTextureLayerImpl::ProgramStretch> m_textureLayerProgramStretch;
+    OwnPtr<CCTextureLayerImpl::ProgramStretchFlip> m_textureLayerProgramStretchFlip;
+    OwnPtr<CCTextureLayerImpl::TexRectProgram> m_textureLayerTexRectProgram;
+    OwnPtr<CCTextureLayerImpl::TexRectProgramFlip> m_textureLayerTexRectProgramFlip;
     OwnPtr<CCTiledLayerImpl::Program> m_tilerProgram;
     OwnPtr<CCTiledLayerImpl::ProgramOpaque> m_tilerProgramOpaque;
     OwnPtr<CCTiledLayerImpl::ProgramSwizzle> m_tilerProgramSwizzle;
     OwnPtr<CCTiledLayerImpl::ProgramSwizzleOpaque> m_tilerProgramSwizzleOpaque;
     OwnPtr<CCTiledLayerImpl::ProgramAA> m_tilerProgramAA;
     OwnPtr<CCTiledLayerImpl::ProgramSwizzleAA> m_tilerProgramSwizzleAA;
-    OwnPtr<CCCanvasLayerImpl::Program> m_canvasLayerProgram;
-    OwnPtr<CCPluginLayerImpl::Program> m_pluginLayerProgram;
-    OwnPtr<CCPluginLayerImpl::ProgramFlip> m_pluginLayerProgramFlip;
-    OwnPtr<CCPluginLayerImpl::TexRectProgram> m_pluginLayerTexRectProgram;
-    OwnPtr<CCPluginLayerImpl::TexRectProgramFlip> m_pluginLayerTexRectProgramFlip;
     OwnPtr<CCRenderSurface::MaskProgram> m_renderSurfaceMaskProgram;
     OwnPtr<CCRenderSurface::Program> m_renderSurfaceProgram;
     OwnPtr<CCRenderSurface::MaskProgramAA> m_renderSurfaceMaskProgramAA;
index 97703957f8bee1f02beb32f7da2f7d8baa31d48b..8a99ab0478f2c5d8649052dfea0cb2b2515b430e 100644 (file)
 
 #include "PluginLayerChromium.h"
 
-#include "GraphicsContext3D.h"
-#include "LayerRendererChromium.h"
-#include "cc/CCLayerImpl.h"
-#include "cc/CCPluginLayerImpl.h"
+#include "cc/CCTextureLayerImpl.h"
 
 namespace WebCore {
 
@@ -46,15 +43,13 @@ PluginLayerChromium::PluginLayerChromium()
     , m_textureId(0)
     , m_flipped(true)
     , m_uvRect(0, 0, 1, 1)
-    , m_ioSurfaceWidth(0)
-    , m_ioSurfaceHeight(0)
     , m_ioSurfaceId(0)
 {
 }
 
 PassOwnPtr<CCLayerImpl> PluginLayerChromium::createCCLayerImpl()
 {
-    return CCPluginLayerImpl::create(m_layerId);
+    return CCTextureLayerImpl::create(m_layerId);
 }
 
 void PluginLayerChromium::setTextureId(unsigned id)
@@ -77,8 +72,7 @@ void PluginLayerChromium::setUVRect(const FloatRect& rect)
 
 void PluginLayerChromium::setIOSurfaceProperties(int width, int height, uint32_t ioSurfaceId)
 {
-    m_ioSurfaceWidth = width;
-    m_ioSurfaceHeight = height;
+    m_ioSurfaceSize = IntSize(width, height);
     m_ioSurfaceId = ioSurfaceId;
     setNeedsCommit();
 }
@@ -92,11 +86,11 @@ void PluginLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
 {
     LayerChromium::pushPropertiesTo(layer);
 
-    CCPluginLayerImpl* pluginLayer = static_cast<CCPluginLayerImpl*>(layer);
-    pluginLayer->setTextureId(m_textureId);
-    pluginLayer->setFlipped(m_flipped);
-    pluginLayer->setUVRect(m_uvRect);
-    pluginLayer->setIOSurfaceProperties(m_ioSurfaceWidth, m_ioSurfaceHeight, m_ioSurfaceId);
+    CCTextureLayerImpl* textureLayer = static_cast<CCTextureLayerImpl*>(layer);
+    textureLayer->setTextureId(m_textureId);
+    textureLayer->setFlipped(m_flipped);
+    textureLayer->setUVRect(m_uvRect);
+    textureLayer->setIOSurfaceProperties(m_ioSurfaceSize, m_ioSurfaceId);
 }
 
 }
index 224da814f4386370ebebe70841ad1c0b16be6271..af004493830a3aa6b385a407487fe72b112237ea 100644 (file)
@@ -61,8 +61,7 @@ private:
     unsigned m_textureId;
     bool m_flipped;
     FloatRect m_uvRect;
-    int m_ioSurfaceWidth;
-    int m_ioSurfaceHeight;
+    IntSize m_ioSurfaceSize;
     uint32_t m_ioSurfaceId;
 };
 
index 80d23d1a8e190f26debb6afeb445c907f3af3d42..da55f3ac06c4d5c46edac179d84df638ac2199ec 100644 (file)
@@ -37,8 +37,9 @@
 #include "DrawingBuffer.h"
 #include "Extensions3DChromium.h"
 #include "GraphicsContext3D.h"
-#include "LayerRendererChromium.h"
 #include "TraceEvent.h"
+#include "cc/CCLayerTreeHost.h"
+#include "cc/CCTextureLayerImpl.h"
 
 namespace WebCore {
 
@@ -100,10 +101,10 @@ void WebGLLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
 {
     CanvasLayerChromium::pushPropertiesTo(layer);
 
-    CCCanvasLayerImpl* canvasLayer = static_cast<CCCanvasLayerImpl*>(layer);
-    canvasLayer->setTextureId(m_textureId);
-    canvasLayer->setHasAlpha(m_hasAlpha);
-    canvasLayer->setPremultipliedAlpha(m_premultipliedAlpha);
+    CCTextureLayerImpl* textureLayer = static_cast<CCTextureLayerImpl*>(layer);
+    textureLayer->setTextureId(m_textureId);
+    textureLayer->setHasAlpha(m_hasAlpha);
+    textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
 }
 
 bool WebGLLayerChromium::paintRenderedResultsToCanvas(ImageBuffer* imageBuffer)
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCCanvasDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCCanvasDrawQuad.cpp
deleted file mode 100644 (file)
index 56f5083..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "cc/CCCanvasDrawQuad.h"
-
-namespace WebCore {
-
-PassOwnPtr<CCCanvasDrawQuad> CCCanvasDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool hasAlpha, bool premultipliedAlpha)
-{
-    return adoptPtr(new CCCanvasDrawQuad(sharedQuadState, quadRect, textureId, hasAlpha, premultipliedAlpha));
-}
-
-CCCanvasDrawQuad::CCCanvasDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool hasAlpha, bool premultipliedAlpha)
-    : CCDrawQuad(sharedQuadState, CCDrawQuad::CanvasContent, quadRect)
-    , m_textureId(textureId)
-    , m_hasAlpha(hasAlpha)
-    , m_premultipliedAlpha(premultipliedAlpha)
-{
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCCanvasDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCCanvasDrawQuad.h
deleted file mode 100644 (file)
index aa85dbd..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CCCanvasDrawQuad_h
-#define CCCanvasDrawQuad_h
-
-#include "cc/CCDrawQuad.h"
-#include <wtf/PassOwnPtr.h>
-
-namespace WebCore {
-
-class CCLayerImpl;
-class CCCanvasDrawQuad : public CCDrawQuad {
-    WTF_MAKE_NONCOPYABLE(CCCanvasDrawQuad);
-public:
-    static PassOwnPtr<CCCanvasDrawQuad> create(const CCSharedQuadState*, const IntRect&, unsigned texture_id, bool hasAlpha, bool premultipliedAlpha);
-
-    unsigned textureId() const { return  m_textureId; }
-    bool hasAlpha() const { return  m_hasAlpha; }
-    bool premultipliedAlpha() const { return  m_premultipliedAlpha; }
-
-private:
-    CCCanvasDrawQuad(const CCSharedQuadState*, const IntRect&, unsigned texture_id, bool hasAlpha, bool premultipliedAlpha);
-    
-    unsigned m_textureId;
-    bool m_hasAlpha;
-    bool m_premultipliedAlpha;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp
deleted file mode 100644 (file)
index 144e579..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "cc/CCCanvasLayerImpl.h"
-
-#include "GraphicsContext3D.h"
-#include "LayerRendererChromium.h"
-#include "cc/CCCanvasDrawQuad.h"
-#include "cc/CCProxy.h"
-#include "cc/CCQuadCuller.h"
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-CCCanvasLayerImpl::CCCanvasLayerImpl(int id)
-    : CCLayerImpl(id)
-    , m_textureId(0)
-    , m_hasAlpha(true)
-    , m_premultipliedAlpha(true)
-{
-}
-
-CCCanvasLayerImpl::~CCCanvasLayerImpl()
-{
-}
-
-void CCCanvasLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState)
-{
-    IntRect quadRect(IntPoint(), bounds());
-    quadList.append(CCCanvasDrawQuad::create(sharedQuadState, quadRect, m_textureId, m_hasAlpha, m_premultipliedAlpha));
-}
-
-void CCCanvasLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
-{
-    writeIndent(ts, indent);
-    ts << "canvas layer texture id: " << m_textureId << " premultiplied: " << m_premultipliedAlpha << "\n";
-    CCLayerImpl::dumpLayerProperties(ts, indent);
-}
-
-}
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h b/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h
deleted file mode 100644 (file)
index a9eb860..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CCCanvasLayerImpl_h
-#define CCCanvasLayerImpl_h
-
-#include "ProgramBinding.h"
-#include "ShaderChromium.h"
-#include "cc/CCLayerImpl.h"
-
-namespace WebCore {
-
-class CCCanvasLayerImpl : public CCLayerImpl {
-public:
-    static PassOwnPtr<CCCanvasLayerImpl> create(int id)
-    {
-        return adoptPtr(new CCCanvasLayerImpl(id));
-    }
-    virtual ~CCCanvasLayerImpl();
-
-    virtual void appendQuads(CCQuadCuller&, const CCSharedQuadState*);
-
-    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexFlipAlpha> Program;
-
-    virtual void dumpLayerProperties(TextStream&, int indent) const;
-
-    unsigned textureId() const { return m_textureId; }
-    void setTextureId(unsigned id) { m_textureId = id; }
-    void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; }
-    void setPremultipliedAlpha(bool premultipliedAlpha) { m_premultipliedAlpha = premultipliedAlpha; }
-private:
-    explicit CCCanvasLayerImpl(int);
-
-    virtual const char* layerTypeAsString() const { return "CanvasLayer"; }
-
-    unsigned m_textureId;
-    bool m_hasAlpha;
-    bool m_premultipliedAlpha;
-};
-
-}
-
-#endif // CCCanvasLayerImpl_h
index 708500267218f6a5026d7bee6e2199236922137b..6a553002694b2bd36e5cee6b6b87f94e3f1f288c 100644 (file)
 
 #include "cc/CCDrawQuad.h"
 
-#include "cc/CCCanvasDrawQuad.h"
 #include "cc/CCDebugBorderDrawQuad.h"
 #include "cc/CCLayerImpl.h"
-#include "cc/CCPluginDrawQuad.h"
+#include "cc/CCTextureDrawQuad.h"
 #include "cc/CCRenderSurfaceDrawQuad.h"
 #include "cc/CCSolidColorDrawQuad.h"
 #include "cc/CCTileDrawQuad.h"
@@ -83,28 +82,22 @@ const CCSolidColorDrawQuad* CCDrawQuad::toSolidColorDrawQuad() const
     return static_cast<const CCSolidColorDrawQuad*>(this);
 }
 
+const CCTextureDrawQuad* CCDrawQuad::toTextureDrawQuad() const
+{
+    ASSERT(m_material == TextureContent);
+    return static_cast<const CCTextureDrawQuad*>(this);
+}
 const CCTileDrawQuad* CCDrawQuad::toTileDrawQuad() const
 {
     ASSERT(m_material == TiledContent);
     return static_cast<const CCTileDrawQuad*>(this);
 }
 
-const CCCanvasDrawQuad* CCDrawQuad::toCanvasDrawQuad() const
-{
-    ASSERT(m_material == CanvasContent);
-    return static_cast<const CCCanvasDrawQuad*>(this);
-}
-
 const CCVideoDrawQuad* CCDrawQuad::toVideoDrawQuad() const
 {
     ASSERT(m_material == VideoContent);
     return static_cast<const CCVideoDrawQuad*>(this);
 }
 
-const CCPluginDrawQuad* CCDrawQuad::toPluginDrawQuad() const
-{
-    ASSERT(m_material == PluginContent);
-    return static_cast<const CCPluginDrawQuad*>(this);
-}
 
 }
index b163393d56c5b1f5851e69d03dc41863a1519a7f..e6f208568cc482e8b706dd6a1586064b1769ab97 100644 (file)
@@ -33,10 +33,9 @@ namespace WebCore {
 class CCDebugBorderDrawQuad;
 class CCRenderSurfaceDrawQuad;
 class CCSolidColorDrawQuad;
+class CCTextureDrawQuad;
 class CCTileDrawQuad;
-class CCCanvasDrawQuad;
 class CCVideoDrawQuad;
-class CCPluginDrawQuad;
 
 // CCDrawQuad is a bag of data used for drawing a quad. Because different
 // materials need different bits of per-quad data to render, classes that derive
@@ -65,11 +64,10 @@ public:
         Invalid,
         DebugBorder,
         RenderSurface,
+        TextureContent,
         SolidColor,
         TiledContent,
-        CanvasContent,
         VideoContent,
-        PluginContent,
     };
 
     Material material() const { return m_material; }
@@ -77,10 +75,9 @@ public:
     const CCDebugBorderDrawQuad* toDebugBorderDrawQuad() const;
     const CCRenderSurfaceDrawQuad* toRenderSurfaceDrawQuad() const;
     const CCSolidColorDrawQuad* toSolidColorDrawQuad() const;
+    const CCTextureDrawQuad* toTextureDrawQuad() const;
     const CCTileDrawQuad* toTileDrawQuad() const;
-    const CCCanvasDrawQuad* toCanvasDrawQuad() const;
     const CCVideoDrawQuad* toVideoDrawQuad() const;
-    const CCPluginDrawQuad* toPluginDrawQuad() const;
 
 protected:
     CCDrawQuad(const CCSharedQuadState*, Material, const IntRect&);
similarity index 62%
rename from Source/WebCore/platform/graphics/chromium/cc/CCPluginDrawQuad.cpp
rename to Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.cpp
index 85289141d52952f4c66e663e17f66be5237fd5c6..64238b794d1b432f0c7be9cad65ebe0b80083e8b 100644 (file)
 
 #include "config.h"
 
-#include "cc/CCPluginDrawQuad.h"
+#include "cc/CCTextureDrawQuad.h"
 
 namespace WebCore {
 
-PassOwnPtr<CCPluginDrawQuad> CCPluginDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const FloatRect& uvRect, unsigned textureId, bool flipped, int ioSurfaceWidth, int ioSurfaceHeight, unsigned ioSurfaceTextureId)
+PassOwnPtr<CCTextureDrawQuad> CCTextureDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool hasAlpha, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
 {
-    return adoptPtr(new CCPluginDrawQuad(sharedQuadState, quadRect, uvRect, textureId, flipped, ioSurfaceWidth, ioSurfaceHeight, ioSurfaceTextureId));
+    return adoptPtr(new CCTextureDrawQuad(sharedQuadState, quadRect, textureId, hasAlpha, premultipliedAlpha, uvRect, flipped, ioSurfaceSize, ioSurfaceTextureId));
 }
 
-CCPluginDrawQuad::CCPluginDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const FloatRect& uvRect, unsigned textureId, bool flipped, int ioSurfaceWidth, int ioSurfaceHeight, unsigned ioSurfaceTextureId)
-    : CCDrawQuad(sharedQuadState, CCDrawQuad::PluginContent, quadRect)
-    , m_uvRect(uvRect)
+CCTextureDrawQuad::CCTextureDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool hasAlpha, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId)
+    : CCDrawQuad(sharedQuadState, CCDrawQuad::TextureContent, quadRect)
     , m_textureId(textureId)
+    , m_hasAlpha(hasAlpha)
+    , m_premultipliedAlpha(premultipliedAlpha)
+    , m_uvRect(uvRect)
     , m_flipped(flipped)
-    , m_ioSurfaceWidth(ioSurfaceWidth)
-    , m_ioSurfaceHeight(ioSurfaceHeight)
+    , m_ioSurfaceSize(ioSurfaceSize)
     , m_ioSurfaceTextureId(ioSurfaceTextureId)
 {
 }
similarity index 64%
rename from Source/WebCore/platform/graphics/chromium/cc/CCPluginDrawQuad.h
rename to Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.h
index 31a260d434f0be3510b6ba1a2d3d63f72940c08c..1a831571bad50dc896110bd85eb884c38382c292 100644 (file)
@@ -23,8 +23,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef CCPluginDrawQuad_h
-#define CCPluginDrawQuad_h
+#ifndef CCTextureDrawQuad_h
+#define CCTextureDrawQuad_h
 
 #include "cc/CCDrawQuad.h"
 #include <wtf/PassOwnPtr.h>
 namespace WebCore {
 
 class CCLayerImpl;
-
-class CCPluginDrawQuad : public CCDrawQuad {
-    WTF_MAKE_NONCOPYABLE(CCPluginDrawQuad);
+class CCTextureDrawQuad : public CCDrawQuad {
+    WTF_MAKE_NONCOPYABLE(CCTextureDrawQuad);
 public:
-    static PassOwnPtr<CCPluginDrawQuad> create(const CCSharedQuadState*, const IntRect& quadRect, const FloatRect& uvRect, unsigned textureId, bool flipped, int ioSurfaceWidth, int ioSurfaceHeight, unsigned m_ioSurfaceTextureId);
+    static PassOwnPtr<CCTextureDrawQuad> create(const CCSharedQuadState*, const IntRect&, unsigned textureId, bool hasAlpha, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
 
+    unsigned textureId() const { return  m_textureId; }
+    bool hasAlpha() const { return  m_hasAlpha; }
+    bool premultipliedAlpha() const { return  m_premultipliedAlpha; }
     FloatRect uvRect() const { return m_uvRect; }
-    unsigned textureId() const { return m_textureId; }
     bool flipped() const { return m_flipped; }
-    int ioSurfaceWidth() const { return m_ioSurfaceWidth; }
-    int ioSurfaceHeight() const { return m_ioSurfaceHeight; }
 
+    const IntSize& ioSurfaceSize() const { return m_ioSurfaceSize; }
     unsigned ioSurfaceTextureId() const { return m_ioSurfaceTextureId; }
-    
 private:
-    CCPluginDrawQuad(const CCSharedQuadState*, const IntRect& quadRect, const FloatRect& uvRect, unsigned textureId, bool flipped, int ioSurfaceWidth, int ioSurfaceHeight, unsigned ioSurfaceTextureId);
-
-    FloatRect m_uvRect;
+    CCTextureDrawQuad(const CCSharedQuadState*, const IntRect&, unsigned texture_id, bool hasAlpha, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId);
+    
     unsigned m_textureId;
+    bool m_hasAlpha;
+    bool m_premultipliedAlpha;
+    FloatRect m_uvRect;
     bool m_flipped;
-    int m_ioSurfaceWidth;
-    int m_ioSurfaceHeight;
+    IntSize m_ioSurfaceSize;
     unsigned m_ioSurfaceTextureId;
 };
 
similarity index 80%
rename from Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp
rename to Source/WebCore/platform/graphics/chromium/cc/CCTextureLayerImpl.cpp
index 4b14114b6abcd6f688a089dddb7ea3fa0f94d76b..e06f72f6f249b61c71aa3dad336431a8b2e62b3c 100644 (file)
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#include "cc/CCPluginLayerImpl.h"
+#include "cc/CCTextureLayerImpl.h"
 
 #include "Extensions3DChromium.h"
 #include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h"
-#include "cc/CCPluginDrawQuad.h"
 #include "cc/CCProxy.h"
 #include "cc/CCQuadCuller.h"
-#include <wtf/text/WTFString.h>
+#include "cc/CCTextureDrawQuad.h"
 
 namespace WebCore {
 
-CCPluginLayerImpl::CCPluginLayerImpl(int id)
+CCTextureLayerImpl::CCTextureLayerImpl(int id)
     : CCLayerImpl(id)
     , m_textureId(0)
+    , m_hasAlpha(true)
+    , m_premultipliedAlpha(true)
     , m_flipped(true)
     , m_uvRect(0, 0, 1, 1)
     , m_ioSurfaceId(0)
-    , m_ioSurfaceWidth(0)
-    , m_ioSurfaceHeight(0)
     , m_ioSurfaceChanged(false)
     , m_ioSurfaceTextureId(0)
 {
 }
 
-CCPluginLayerImpl::~CCPluginLayerImpl()
+CCTextureLayerImpl::~CCTextureLayerImpl()
 {
     // FIXME: it seems there is no layer renderer / GraphicsContext3D available here. Ideally we
     // would like to delete m_ioSurfaceTextureId.
     m_ioSurfaceTextureId = 0;
 }
 
-void CCPluginLayerImpl::willDraw(LayerRendererChromium* layerRenderer)
+void CCTextureLayerImpl::willDraw(LayerRendererChromium* layerRenderer)
 {
     if (m_ioSurfaceChanged) {
         GraphicsContext3D* context = layerRenderer->context();
@@ -77,8 +76,8 @@ void CCPluginLayerImpl::willDraw(LayerRendererChromium* layerRenderer)
         GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
         GLC(context, context->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
         extensions->texImageIOSurface2DCHROMIUM(Extensions3D::TEXTURE_RECTANGLE_ARB,
-                                                m_ioSurfaceWidth,
-                                                m_ioSurfaceHeight,
+                                                m_ioSurfaceSize.width(),
+                                                m_ioSurfaceSize.height(),
                                                 m_ioSurfaceId,
                                                 0);
         // Do not check for error conditions. texImageIOSurface2DCHROMIUM is supposed to hold on to
@@ -91,20 +90,20 @@ void CCPluginLayerImpl::willDraw(LayerRendererChromium* layerRenderer)
     }
 }
 
-void CCPluginLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState)
+void CCTextureLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState)
 {
     IntRect quadRect(IntPoint(), bounds());
-    quadList.append(CCPluginDrawQuad::create(sharedQuadState, quadRect, m_uvRect, m_textureId, m_flipped, m_ioSurfaceWidth, m_ioSurfaceHeight, m_ioSurfaceTextureId));
+    quadList.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_textureId, m_hasAlpha, m_premultipliedAlpha, m_uvRect, m_flipped, m_ioSurfaceSize, m_ioSurfaceTextureId));
 }
 
-void CCPluginLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
+void CCTextureLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
 {
     writeIndent(ts, indent);
-    ts << "plugin layer texture id: " << m_textureId << "\n";
+    ts << "texture layer texture id: " << m_textureId << " premultiplied: " << m_premultipliedAlpha << "\n";
     CCLayerImpl::dumpLayerProperties(ts, indent);
 }
 
-void CCPluginLayerImpl::didLoseContext()
+void CCTextureLayerImpl::didLoseContext()
 {
     if (m_ioSurfaceId) {
         // We don't have a valid texture ID in the new context; however,
@@ -114,16 +113,14 @@ void CCPluginLayerImpl::didLoseContext()
     }
 }
 
-void CCPluginLayerImpl::setIOSurfaceProperties(int width, int height, uint32_t ioSurfaceId)
+void CCTextureLayerImpl::setIOSurfaceProperties(const IntSize& size, unsigned ioSurfaceId)
 {
     if (m_ioSurfaceId != ioSurfaceId)
         m_ioSurfaceChanged = true;
 
-    m_ioSurfaceWidth = width;
-    m_ioSurfaceHeight = height;
+    m_ioSurfaceSize = size;
     m_ioSurfaceId = ioSurfaceId;
 }
-
-} // namespace WebCore
+}
 
 #endif // USE(ACCELERATED_COMPOSITING)
similarity index 68%
rename from Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h
rename to Source/WebCore/platform/graphics/chromium/cc/CCTextureLayerImpl.h
index 969b3363515e44b78516c9141e8361451167ced5..a81c3616aedb645a21a7350b91bd93d607f8bc72 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef CCPluginLayerImpl_h
-#define CCPluginLayerImpl_h
+#ifndef CCTextureLayerImpl_h
+#define CCTextureLayerImpl_h
 
-#include "FloatRect.h"
 #include "ProgramBinding.h"
 #include "ShaderChromium.h"
 #include "cc/CCLayerImpl.h"
 
 namespace WebCore {
 
-class CCPluginLayerImpl : public CCLayerImpl {
+class CCTextureLayerImpl : public CCLayerImpl {
 public:
-    static PassOwnPtr<CCPluginLayerImpl> create(int id)
+    static PassOwnPtr<CCTextureLayerImpl> create(int id)
     {
-        return adoptPtr(new CCPluginLayerImpl(id));
+        return adoptPtr(new CCTextureLayerImpl(id));
     }
-    virtual ~CCPluginLayerImpl();
+    virtual ~CCTextureLayerImpl();
 
-    virtual void willDraw(LayerRendererChromium*);
     virtual void appendQuads(CCQuadCuller&, const CCSharedQuadState*);
 
-    typedef ProgramBinding<VertexShaderPosTexStretch, FragmentShaderRGBATexAlpha> Program;
-    typedef ProgramBinding<VertexShaderPosTexStretch, FragmentShaderRGBATexFlipAlpha> ProgramFlip;
+    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexFlipAlpha> ProgramFlip;
+    typedef ProgramBinding<VertexShaderPosTexStretch, FragmentShaderRGBATexAlpha> ProgramStretch;
+    typedef ProgramBinding<VertexShaderPosTexStretch, FragmentShaderRGBATexFlipAlpha> ProgramStretchFlip;
     typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexRectAlpha> TexRectProgram;
     typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexRectFlipAlpha> TexRectProgramFlip;
 
-    virtual void dumpLayerProperties(TextStream&, int indent) const;
+    virtual void willDraw(LayerRendererChromium*);
     virtual void didLoseContext();
 
+    virtual void dumpLayerProperties(TextStream&, int indent) const;
+
+    unsigned textureId() const { return m_textureId; }
     void setTextureId(unsigned id) { m_textureId = id; }
+    void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; }
+    void setPremultipliedAlpha(bool premultipliedAlpha) { m_premultipliedAlpha = premultipliedAlpha; }
     void setFlipped(bool flipped) { m_flipped = flipped; }
     void setUVRect(const FloatRect& rect) { m_uvRect = rect; }
-    void setIOSurfaceProperties(int width, int height, uint32_t ioSurfaceId);
+    void setIOSurfaceProperties(const IntSize&, unsigned ioSurfaceId);
+
 
 private:
-    explicit CCPluginLayerImpl(int);
+    explicit CCTextureLayerImpl(int);
 
-    virtual const char* layerTypeAsString() const { return "PluginLayer"; }
+    virtual const char* layerTypeAsString() const { return "TextureLayer"; }
 
     unsigned m_textureId;
+    bool m_hasAlpha;
+    bool m_premultipliedAlpha;
     bool m_flipped;
     FloatRect m_uvRect;
-    uint32_t m_ioSurfaceId;
-    int m_ioSurfaceWidth;
-    int m_ioSurfaceHeight;
 
-    // Internals for the IOSurface rendering path.
+    // Internals for IOSurface-backed textures.
+    unsigned m_ioSurfaceId;
+    IntSize m_ioSurfaceSize;
     bool m_ioSurfaceChanged;
     unsigned m_ioSurfaceTextureId;
 };
 
 }
 
-#endif // CCPluginLayerImpl_h
+#endif // CCTextureLayerImpl_h
index 5606fb09a9f4996877c5afe6e1e1dcc659cf3d77..35791b2f8807aa5dd950c01c54e868fcd4aa61f5 100644 (file)
@@ -1,3 +1,12 @@
+2012-03-16  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Unify the drawing logic for different layer types that output textures to the compositor
+        https://bugs.webkit.org/show_bug.cgi?id=81286
+
+        Reviewed by Adrienne Walker.
+
+        * tests/Canvas2DLayerChromiumTest.cpp:
+
 2012-03-15  Daniel Cheng  <dcheng@chromium.org>
 
         [chromium] Refactor ClipboardChromium and DataTransferItemList/DataTransferItem to support HTML spec
index 03adb3c888abff840fa1e60997f6f006514fdae5..14c92ae9f7c92e9c7aa9634438dbd927ce0cad86 100644 (file)
@@ -34,8 +34,8 @@
 #include "TextureManager.h"
 #include "WebCompositor.h"
 #include "WebKit.h"
-#include "cc/CCCanvasLayerImpl.h"
 #include "cc/CCSingleThreadProxy.h"
+#include "cc/CCTextureLayerImpl.h"
 #include "cc/CCTextureUpdater.h"
 #include "platform/WebKitPlatformSupport.h"
 #include "platform/WebThread.h"
@@ -162,15 +162,15 @@ protected:
             DebugScopedSetImplThread scopedImplThread;
 
             OwnPtr<CCLayerImpl> layerImpl = canvas->createCCLayerImpl();
-            EXPECT_EQ(0u, static_cast<CCCanvasLayerImpl*>(layerImpl.get())->textureId());
+            EXPECT_EQ(0u, static_cast<CCTextureLayerImpl*>(layerImpl.get())->textureId());
 
             canvas->updateCompositorResources(implContext.get(), updater);
             canvas->pushPropertiesTo(layerImpl.get());
 
             if (threaded)
-                EXPECT_EQ(frontTextureId, static_cast<CCCanvasLayerImpl*>(layerImpl.get())->textureId());
+                EXPECT_EQ(frontTextureId, static_cast<CCTextureLayerImpl*>(layerImpl.get())->textureId());
             else
-                EXPECT_EQ(backTextureId, static_cast<CCCanvasLayerImpl*>(layerImpl.get())->textureId());
+                EXPECT_EQ(backTextureId, static_cast<CCTextureLayerImpl*>(layerImpl.get())->textureId());
         }
         canvas.clear();
         layerTreeHost->contentsTextureManager()->reduceMemoryToLimit(0);