[chromium] Avoid calling getUniformLocation??() in the compositor startup
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jul 2012 02:34:16 +0000 (02:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jul 2012 02:34:16 +0000 (02:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90217

Patch by Alex Sakhartchouk <alexst@chromium.org> on 2012-07-03
Reviewed by Adrienne Walker.

Source/Platform:

Adding an entry point for bindUniformLocationCHROMIUM.

* chromium/public/WebGraphicsContext3D.h:
(WebGraphicsContext3D):
(WebKit::WebGraphicsContext3D::bindUniformLocationCHROMIUM):

Source/WebCore:

This change allows chrome compositor to bind uniform locations instead of querying
them from the graphics context by using GL_CHROMIUM_bind_uniform_location.

The extention itself is tested in chromium and the change in webkit simply adds
plumbing to allow its usage. Existing pixel tests would be able to verify proper behaviour.

* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::LayerRendererChromium):
(WebCore::LayerRendererChromium::initialize):
(WebCore::LayerRendererChromium::initializeSharedObjects):
(WebCore::LayerRendererChromium::tileCheckerboardProgram):
(WebCore::LayerRendererChromium::solidColorProgram):
(WebCore::LayerRendererChromium::headsUpDisplayProgram):
(WebCore::LayerRendererChromium::renderPassProgram):
(WebCore::LayerRendererChromium::renderPassProgramAA):
(WebCore::LayerRendererChromium::renderPassMaskProgram):
(WebCore::LayerRendererChromium::renderPassMaskProgramAA):
(WebCore::LayerRendererChromium::tileProgram):
(WebCore::LayerRendererChromium::tileProgramOpaque):
(WebCore::LayerRendererChromium::tileProgramAA):
(WebCore::LayerRendererChromium::tileProgramSwizzle):
(WebCore::LayerRendererChromium::tileProgramSwizzleOpaque):
(WebCore::LayerRendererChromium::tileProgramSwizzleAA):
(WebCore::LayerRendererChromium::textureProgram):
(WebCore::LayerRendererChromium::textureProgramFlip):
(WebCore::LayerRendererChromium::textureIOSurfaceProgram):
(WebCore::LayerRendererChromium::videoYUVProgram):
(WebCore::LayerRendererChromium::videoStreamTextureProgram):
* platform/graphics/chromium/LayerRendererChromium.h:
(LayerRendererChromium):
* platform/graphics/chromium/ProgramBinding.cpp:
(WebCore::ProgramBindingBase::ProgramBindingBase):
(WebCore::ProgramBindingBase::~ProgramBindingBase):
(WebCore::ProgramBindingBase::init):
(WebCore::ProgramBindingBase::link):
(WebCore):
(WebCore::ProgramBindingBase::cleanup):
(WebCore::ProgramBindingBase::createShaderProgram):
(WebCore::ProgramBindingBase::cleanupShaders):
* platform/graphics/chromium/ProgramBinding.h:
(ProgramBindingBase):
(WebCore::ProgramBinding::initialize):
* platform/graphics/chromium/ShaderChromium.cpp:
(WebCore::VertexShaderPosTex::init):
(WebCore::VertexShaderPosTexYUVStretch::init):
(WebCore::VertexShaderPos::init):
(WebCore::VertexShaderPosTexTransform::init):
(WebCore::VertexShaderQuad::init):
(WebCore::VertexShaderTile::init):
(WebCore::VertexShaderVideoTransform::init):
(WebCore::FragmentTexAlphaBinding::init):
(WebCore::FragmentTexOpaqueBinding::init):
(WebCore::FragmentShaderOESImageExternal::init):
(WebCore::FragmentShaderRGBATexAlphaAA::init):
(WebCore::FragmentTexClampAlphaAABinding::init):
(WebCore::FragmentShaderRGBATexAlphaMask::init):
(WebCore::FragmentShaderRGBATexAlphaMaskAA::init):
(WebCore::FragmentShaderYUVVideo::init):
(WebCore::FragmentShaderColor::init):
(WebCore::FragmentShaderCheckerboard::init):
* platform/graphics/chromium/ShaderChromium.h:
(VertexShaderPosTex):
(VertexShaderPosTexYUVStretch):
(VertexShaderPos):
(WebCore::VertexShaderPosTexIdentity::init):
(VertexShaderPosTexTransform):
(VertexShaderQuad):
(VertexShaderTile):
(VertexShaderVideoTransform):
(FragmentTexAlphaBinding):
(FragmentTexOpaqueBinding):
(FragmentShaderOESImageExternal):
(FragmentShaderRGBATexAlphaAA):
(FragmentTexClampAlphaAABinding):
(FragmentShaderRGBATexAlphaMask):
(FragmentShaderRGBATexAlphaMaskAA):
(FragmentShaderYUVVideo):
(FragmentShaderColor):
(FragmentShaderCheckerboard):
* platform/graphics/chromium/TextureCopier.cpp:
(WebCore::AcceleratedTextureCopier::AcceleratedTextureCopier):
(WebCore::AcceleratedTextureCopier::copyTexture):
* platform/graphics/chromium/TextureCopier.h:
(WebCore::AcceleratedTextureCopier::create):
(AcceleratedTextureCopier):

Source/WebKit/chromium:

Fixing the build error.

* tests/TextureCopierTest.cpp:

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

13 files changed:
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebGraphicsContext3D.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
Source/WebCore/platform/graphics/chromium/ProgramBinding.cpp
Source/WebCore/platform/graphics/chromium/ProgramBinding.h
Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp
Source/WebCore/platform/graphics/chromium/ShaderChromium.h
Source/WebCore/platform/graphics/chromium/TextureCopier.cpp
Source/WebCore/platform/graphics/chromium/TextureCopier.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/TextureCopierTest.cpp

index 0e59887..a57177f 100644 (file)
@@ -1,3 +1,16 @@
+2012-07-03  Alex Sakhartchouk  <alexst@chromium.org>
+
+        [chromium] Avoid calling getUniformLocation??() in the compositor startup
+        https://bugs.webkit.org/show_bug.cgi?id=90217
+
+        Reviewed by Adrienne Walker.
+
+        Adding an entry point for bindUniformLocationCHROMIUM.
+
+        * chromium/public/WebGraphicsContext3D.h:
+        (WebGraphicsContext3D):
+        (WebKit::WebGraphicsContext3D::bindUniformLocationCHROMIUM):
+
 2012-07-03  Tony Chang  <tony@chromium.org>
 
         [chromium] Unreviewed, update .gitignore to handle VS2010 files.
index 577d702..44c2067 100644 (file)
@@ -414,6 +414,9 @@ public:
     virtual void getQueryivEXT(WGC3Denum target, WGC3Denum pname, WGC3Dint* params) { }
     virtual void getQueryObjectuivEXT(WebGLId query, WGC3Denum pname, WGC3Duint* params) { }
 
+    // GL_CHROMIUM_bind_uniform_location
+    virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location, const WGC3Dchar* uniform) { }
+
     // GL_CHROMIUM_copy_texture
     virtual void copyTextureCHROMIUM(WGC3Denum target, WGC3Duint sourceId,
                                      WGC3Duint destId, WGC3Dint level, WGC3Denum internalFormat) { }
index 582779d..2c92eca 100644 (file)
@@ -1,3 +1,96 @@
+2012-07-03  Alex Sakhartchouk  <alexst@chromium.org>
+
+        [chromium] Avoid calling getUniformLocation??() in the compositor startup
+        https://bugs.webkit.org/show_bug.cgi?id=90217
+
+        Reviewed by Adrienne Walker.
+
+        This change allows chrome compositor to bind uniform locations instead of querying 
+        them from the graphics context by using GL_CHROMIUM_bind_uniform_location.
+
+        The extention itself is tested in chromium and the change in webkit simply adds
+        plumbing to allow its usage. Existing pixel tests would be able to verify proper behaviour.
+
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::LayerRendererChromium):
+        (WebCore::LayerRendererChromium::initialize):
+        (WebCore::LayerRendererChromium::initializeSharedObjects):
+        (WebCore::LayerRendererChromium::tileCheckerboardProgram):
+        (WebCore::LayerRendererChromium::solidColorProgram):
+        (WebCore::LayerRendererChromium::headsUpDisplayProgram):
+        (WebCore::LayerRendererChromium::renderPassProgram):
+        (WebCore::LayerRendererChromium::renderPassProgramAA):
+        (WebCore::LayerRendererChromium::renderPassMaskProgram):
+        (WebCore::LayerRendererChromium::renderPassMaskProgramAA):
+        (WebCore::LayerRendererChromium::tileProgram):
+        (WebCore::LayerRendererChromium::tileProgramOpaque):
+        (WebCore::LayerRendererChromium::tileProgramAA):
+        (WebCore::LayerRendererChromium::tileProgramSwizzle):
+        (WebCore::LayerRendererChromium::tileProgramSwizzleOpaque):
+        (WebCore::LayerRendererChromium::tileProgramSwizzleAA):
+        (WebCore::LayerRendererChromium::textureProgram):
+        (WebCore::LayerRendererChromium::textureProgramFlip):
+        (WebCore::LayerRendererChromium::textureIOSurfaceProgram):
+        (WebCore::LayerRendererChromium::videoYUVProgram):
+        (WebCore::LayerRendererChromium::videoStreamTextureProgram):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (LayerRendererChromium):
+        * platform/graphics/chromium/ProgramBinding.cpp:
+        (WebCore::ProgramBindingBase::ProgramBindingBase):
+        (WebCore::ProgramBindingBase::~ProgramBindingBase):
+        (WebCore::ProgramBindingBase::init):
+        (WebCore::ProgramBindingBase::link):
+        (WebCore):
+        (WebCore::ProgramBindingBase::cleanup):
+        (WebCore::ProgramBindingBase::createShaderProgram):
+        (WebCore::ProgramBindingBase::cleanupShaders):
+        * platform/graphics/chromium/ProgramBinding.h:
+        (ProgramBindingBase):
+        (WebCore::ProgramBinding::initialize):
+        * platform/graphics/chromium/ShaderChromium.cpp:
+        (WebCore::VertexShaderPosTex::init):
+        (WebCore::VertexShaderPosTexYUVStretch::init):
+        (WebCore::VertexShaderPos::init):
+        (WebCore::VertexShaderPosTexTransform::init):
+        (WebCore::VertexShaderQuad::init):
+        (WebCore::VertexShaderTile::init):
+        (WebCore::VertexShaderVideoTransform::init):
+        (WebCore::FragmentTexAlphaBinding::init):
+        (WebCore::FragmentTexOpaqueBinding::init):
+        (WebCore::FragmentShaderOESImageExternal::init):
+        (WebCore::FragmentShaderRGBATexAlphaAA::init):
+        (WebCore::FragmentTexClampAlphaAABinding::init):
+        (WebCore::FragmentShaderRGBATexAlphaMask::init):
+        (WebCore::FragmentShaderRGBATexAlphaMaskAA::init):
+        (WebCore::FragmentShaderYUVVideo::init):
+        (WebCore::FragmentShaderColor::init):
+        (WebCore::FragmentShaderCheckerboard::init):
+        * platform/graphics/chromium/ShaderChromium.h:
+        (VertexShaderPosTex):
+        (VertexShaderPosTexYUVStretch):
+        (VertexShaderPos):
+        (WebCore::VertexShaderPosTexIdentity::init):
+        (VertexShaderPosTexTransform):
+        (VertexShaderQuad):
+        (VertexShaderTile):
+        (VertexShaderVideoTransform):
+        (FragmentTexAlphaBinding):
+        (FragmentTexOpaqueBinding):
+        (FragmentShaderOESImageExternal):
+        (FragmentShaderRGBATexAlphaAA):
+        (FragmentTexClampAlphaAABinding):
+        (FragmentShaderRGBATexAlphaMask):
+        (FragmentShaderRGBATexAlphaMaskAA):
+        (FragmentShaderYUVVideo):
+        (FragmentShaderColor):
+        (FragmentShaderCheckerboard):
+        * platform/graphics/chromium/TextureCopier.cpp:
+        (WebCore::AcceleratedTextureCopier::AcceleratedTextureCopier):
+        (WebCore::AcceleratedTextureCopier::copyTexture):
+        * platform/graphics/chromium/TextureCopier.h:
+        (WebCore::AcceleratedTextureCopier::create):
+        (AcceleratedTextureCopier):
+
 2012-07-03  Erik Arvidsson  <arv@chromium.org>
 
         [V8] Remove enableFasterDOMStoreAccess which is never used
index 7c8181d..ddd7d51 100644 (file)
@@ -164,6 +164,7 @@ LayerRendererChromium::LayerRendererChromium(CCRendererClient* client,
     , m_defaultRenderPass(0)
     , m_isViewportChanged(false)
     , m_isFramebufferDiscarded(false)
+    , m_isUsingBindUniform(false)
     , m_visible(true)
     , m_textureUploaderSetting(textureUploaderSetting)
 {
@@ -227,6 +228,8 @@ bool LayerRendererChromium::initialize()
     GLC(m_context, m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_capabilities.maxTextureSize));
     m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context, extensions.contains("GL_EXT_texture_format_BGRA8888"));
 
+    m_isUsingBindUniform = extensions.contains("GL_CHROMIUM_bind_uniform_location");
+
     if (!initializeSharedObjects())
         return false;
 
@@ -1429,7 +1432,7 @@ bool LayerRendererChromium::initializeSharedObjects()
     m_implTextureManager = TextureManager::create(TextureManager::highLimitBytes(viewportSize()),
                                                   TextureManager::reclaimLimitBytes(viewportSize()),
                                                   m_capabilities.maxTextureSize);
-    m_textureCopier = AcceleratedTextureCopier::create(m_context);
+    m_textureCopier = AcceleratedTextureCopier::create(m_context, m_isUsingBindUniform);
     if (m_textureUploaderSetting == ThrottledUploader)
         m_textureUploader = ThrottledTextureUploader::create(m_context);
     else
@@ -1452,7 +1455,7 @@ const LayerRendererChromium::TileCheckerboardProgram* LayerRendererChromium::til
         m_tileCheckerboardProgram = adoptPtr(new TileCheckerboardProgram(m_context));
     if (!m_tileCheckerboardProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::checkerboardProgram::initalize");
-        m_tileCheckerboardProgram->initialize(m_context);
+        m_tileCheckerboardProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_tileCheckerboardProgram.get();
 }
@@ -1463,7 +1466,7 @@ const LayerRendererChromium::SolidColorProgram* LayerRendererChromium::solidColo
         m_solidColorProgram = adoptPtr(new SolidColorProgram(m_context));
     if (!m_solidColorProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::solidColorProgram::initialize");
-        m_solidColorProgram->initialize(m_context);
+        m_solidColorProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_solidColorProgram.get();
 }
@@ -1474,7 +1477,7 @@ const LayerRendererChromium::HeadsUpDisplayProgram* LayerRendererChromium::heads
         m_headsUpDisplayProgram = adoptPtr(new HeadsUpDisplayProgram(m_context));
     if (!m_headsUpDisplayProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::headsUpDisplayProgram::initialize");
-        m_headsUpDisplayProgram->initialize(m_context);
+        m_headsUpDisplayProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_headsUpDisplayProgram.get();
 }
@@ -1484,7 +1487,7 @@ const LayerRendererChromium::RenderPassProgram* LayerRendererChromium::renderPas
     ASSERT(m_renderPassProgram);
     if (!m_renderPassProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::renderPassProgram::initialize");
-        m_renderPassProgram->initialize(m_context);
+        m_renderPassProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_renderPassProgram.get();
 }
@@ -1495,7 +1498,7 @@ const LayerRendererChromium::RenderPassProgramAA* LayerRendererChromium::renderP
         m_renderPassProgramAA = adoptPtr(new RenderPassProgramAA(m_context));
     if (!m_renderPassProgramAA->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::renderPassProgramAA::initialize");
-        m_renderPassProgramAA->initialize(m_context);
+        m_renderPassProgramAA->initialize(m_context, m_isUsingBindUniform);
     }
     return m_renderPassProgramAA.get();
 }
@@ -1506,7 +1509,7 @@ const LayerRendererChromium::RenderPassMaskProgram* LayerRendererChromium::rende
         m_renderPassMaskProgram = adoptPtr(new RenderPassMaskProgram(m_context));
     if (!m_renderPassMaskProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::renderPassMaskProgram::initialize");
-        m_renderPassMaskProgram->initialize(m_context);
+        m_renderPassMaskProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_renderPassMaskProgram.get();
 }
@@ -1517,7 +1520,7 @@ const LayerRendererChromium::RenderPassMaskProgramAA* LayerRendererChromium::ren
         m_renderPassMaskProgramAA = adoptPtr(new RenderPassMaskProgramAA(m_context));
     if (!m_renderPassMaskProgramAA->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::renderPassMaskProgramAA::initialize");
-        m_renderPassMaskProgramAA->initialize(m_context);
+        m_renderPassMaskProgramAA->initialize(m_context, m_isUsingBindUniform);
     }
     return m_renderPassMaskProgramAA.get();
 }
@@ -1527,7 +1530,7 @@ const LayerRendererChromium::TileProgram* LayerRendererChromium::tileProgram()
     ASSERT(m_tileProgram);
     if (!m_tileProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::tileProgram::initialize");
-        m_tileProgram->initialize(m_context);
+        m_tileProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_tileProgram.get();
 }
@@ -1537,7 +1540,7 @@ const LayerRendererChromium::TileProgramOpaque* LayerRendererChromium::tileProgr
     ASSERT(m_tileProgramOpaque);
     if (!m_tileProgramOpaque->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::tileProgramOpaque::initialize");
-        m_tileProgramOpaque->initialize(m_context);
+        m_tileProgramOpaque->initialize(m_context, m_isUsingBindUniform);
     }
     return m_tileProgramOpaque.get();
 }
@@ -1548,7 +1551,7 @@ const LayerRendererChromium::TileProgramAA* LayerRendererChromium::tileProgramAA
         m_tileProgramAA = adoptPtr(new TileProgramAA(m_context));
     if (!m_tileProgramAA->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::tileProgramAA::initialize");
-        m_tileProgramAA->initialize(m_context);
+        m_tileProgramAA->initialize(m_context, m_isUsingBindUniform);
     }
     return m_tileProgramAA.get();
 }
@@ -1559,7 +1562,7 @@ const LayerRendererChromium::TileProgramSwizzle* LayerRendererChromium::tileProg
         m_tileProgramSwizzle = adoptPtr(new TileProgramSwizzle(m_context));
     if (!m_tileProgramSwizzle->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::tileProgramSwizzle::initialize");
-        m_tileProgramSwizzle->initialize(m_context);
+        m_tileProgramSwizzle->initialize(m_context, m_isUsingBindUniform);
     }
     return m_tileProgramSwizzle.get();
 }
@@ -1570,7 +1573,7 @@ const LayerRendererChromium::TileProgramSwizzleOpaque* LayerRendererChromium::ti
         m_tileProgramSwizzleOpaque = adoptPtr(new TileProgramSwizzleOpaque(m_context));
     if (!m_tileProgramSwizzleOpaque->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::tileProgramSwizzleOpaque::initialize");
-        m_tileProgramSwizzleOpaque->initialize(m_context);
+        m_tileProgramSwizzleOpaque->initialize(m_context, m_isUsingBindUniform);
     }
     return m_tileProgramSwizzleOpaque.get();
 }
@@ -1581,7 +1584,7 @@ const LayerRendererChromium::TileProgramSwizzleAA* LayerRendererChromium::tilePr
         m_tileProgramSwizzleAA = adoptPtr(new TileProgramSwizzleAA(m_context));
     if (!m_tileProgramSwizzleAA->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::tileProgramSwizzleAA::initialize");
-        m_tileProgramSwizzleAA->initialize(m_context);
+        m_tileProgramSwizzleAA->initialize(m_context, m_isUsingBindUniform);
     }
     return m_tileProgramSwizzleAA.get();
 }
@@ -1592,7 +1595,7 @@ const LayerRendererChromium::TextureProgram* LayerRendererChromium::textureProgr
         m_textureProgram = adoptPtr(new TextureProgram(m_context));
     if (!m_textureProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::textureProgram::initialize");
-        m_textureProgram->initialize(m_context);
+        m_textureProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_textureProgram.get();
 }
@@ -1603,7 +1606,7 @@ const LayerRendererChromium::TextureProgramFlip* LayerRendererChromium::textureP
         m_textureProgramFlip = adoptPtr(new TextureProgramFlip(m_context));
     if (!m_textureProgramFlip->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::textureProgramFlip::initialize");
-        m_textureProgramFlip->initialize(m_context);
+        m_textureProgramFlip->initialize(m_context, m_isUsingBindUniform);
     }
     return m_textureProgramFlip.get();
 }
@@ -1614,7 +1617,7 @@ const LayerRendererChromium::TextureIOSurfaceProgram* LayerRendererChromium::tex
         m_textureIOSurfaceProgram = adoptPtr(new TextureIOSurfaceProgram(m_context));
     if (!m_textureIOSurfaceProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::textureIOSurfaceProgram::initialize");
-        m_textureIOSurfaceProgram->initialize(m_context);
+        m_textureIOSurfaceProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_textureIOSurfaceProgram.get();
 }
@@ -1625,7 +1628,7 @@ const LayerRendererChromium::VideoYUVProgram* LayerRendererChromium::videoYUVPro
         m_videoYUVProgram = adoptPtr(new VideoYUVProgram(m_context));
     if (!m_videoYUVProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::videoYUVProgram::initialize");
-        m_videoYUVProgram->initialize(m_context);
+        m_videoYUVProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_videoYUVProgram.get();
 }
@@ -1636,7 +1639,7 @@ const LayerRendererChromium::VideoStreamTextureProgram* LayerRendererChromium::v
         m_videoStreamTextureProgram = adoptPtr(new VideoStreamTextureProgram(m_context));
     if (!m_videoStreamTextureProgram->initialized()) {
         TRACE_EVENT0("cc", "LayerRendererChromium::streamTextureProgram::initialize");
-        m_videoStreamTextureProgram->initialize(m_context);
+        m_videoStreamTextureProgram->initialize(m_context, m_isUsingBindUniform);
     }
     return m_videoStreamTextureProgram.get();
 }
index 34254b0..625e82f 100644 (file)
@@ -269,6 +269,7 @@ private:
 
     bool m_isViewportChanged;
     bool m_isFramebufferDiscarded;
+    bool m_isUsingBindUniform;
     bool m_visible;
     TextureUploaderOption m_textureUploaderSetting;
 };
index 72e49e2..1abc218 100644 (file)
@@ -42,6 +42,8 @@ namespace WebCore {
 
 ProgramBindingBase::ProgramBindingBase()
     : m_program(0)
+    , m_vertexShaderId(0)
+    , m_fragmentShaderId(0)
     , m_initialized(false)
 {
 }
@@ -50,6 +52,8 @@ ProgramBindingBase::~ProgramBindingBase()
 {
     // If you hit these asserts, you initialized but forgot to call cleanup().
     ASSERT(!m_program);
+    ASSERT(!m_vertexShaderId);
+    ASSERT(!m_fragmentShaderId);
     ASSERT(!m_initialized);
 }
 
@@ -61,10 +65,43 @@ static bool contextLost(WebGraphicsContext3D* context)
 
 void ProgramBindingBase::init(WebGraphicsContext3D* context, const String& vertexShader, const String& fragmentShader)
 {
-    m_program = createShaderProgram(context, vertexShader, fragmentShader);
+    TRACE_EVENT("ProgramBindingBase::init", this, 0);
+    m_vertexShaderId = loadShader(context, GraphicsContext3D::VERTEX_SHADER, vertexShader);
+    if (!m_vertexShaderId) {
+        if (!contextLost(context))
+            LOG_ERROR("Failed to create vertex shader");
+        return;
+    }
+
+    m_fragmentShaderId = loadShader(context, GraphicsContext3D::FRAGMENT_SHADER, fragmentShader);
+    if (!m_fragmentShaderId) {
+        GLC(context, context->deleteShader(m_vertexShaderId));
+        m_vertexShaderId = 0;
+        if (!contextLost(context))
+            LOG_ERROR("Failed to create fragment shader");
+        return;
+    }
+
+    m_program = createShaderProgram(context, m_vertexShaderId, m_fragmentShaderId);
     ASSERT(m_program || contextLost(context));
 }
 
+void ProgramBindingBase::link(WebGraphicsContext3D* context)
+{
+    GLC(context, context->linkProgram(m_program));
+    cleanupShaders(context);
+#ifndef NDEBUG
+    int linked = 0;
+    GLC(context, context->getProgramiv(m_program, GraphicsContext3D::LINK_STATUS, &linked));
+    if (!linked) {
+        if (!contextLost(context))
+            LOG_ERROR("Failed to link shader program");
+        GLC(context, context->deleteProgram(m_program));
+        return;
+    }
+#endif
+}
+
 void ProgramBindingBase::cleanup(WebGraphicsContext3D* context)
 {
     m_initialized = false;
@@ -74,6 +111,8 @@ void ProgramBindingBase::cleanup(WebGraphicsContext3D* context)
     ASSERT(context);
     GLC(context, context->deleteProgram(m_program));
     m_program = 0;
+
+    cleanupShaders(context);
 }
 
 unsigned ProgramBindingBase::loadShader(WebGraphicsContext3D* context, unsigned type, const String& shaderSource)
@@ -95,24 +134,8 @@ unsigned ProgramBindingBase::loadShader(WebGraphicsContext3D* context, unsigned
     return shader;
 }
 
-unsigned ProgramBindingBase::createShaderProgram(WebGraphicsContext3D* context, const String& vertexShaderSource, const String& fragmentShaderSource)
+unsigned ProgramBindingBase::createShaderProgram(WebGraphicsContext3D* context, unsigned vertexShader, unsigned fragmentShader)
 {
-    TRACE_EVENT0("cc", "ProgramBindingBase::createShaderProgram");
-    unsigned vertexShader = loadShader(context, GraphicsContext3D::VERTEX_SHADER, vertexShaderSource);
-    if (!vertexShader) {
-        if (!contextLost(context))
-            LOG_ERROR("Failed to create vertex shader");
-        return 0;
-    }
-
-    unsigned fragmentShader = loadShader(context, GraphicsContext3D::FRAGMENT_SHADER, fragmentShaderSource);
-    if (!fragmentShader) {
-        GLC(context, context->deleteShader(vertexShader));
-        if (!contextLost(context))
-            LOG_ERROR("Failed to create fragment shader");
-        return 0;
-    }
-
     unsigned programObject = context->createProgram();
     if (!programObject) {
         if (!contextLost(context))
@@ -127,23 +150,21 @@ unsigned ProgramBindingBase::createShaderProgram(WebGraphicsContext3D* context,
     GLC(context, context->bindAttribLocation(programObject, GeometryBinding::positionAttribLocation(), "a_position"));
     GLC(context, context->bindAttribLocation(programObject, GeometryBinding::texCoordAttribLocation(), "a_texCoord"));
 
-    GLC(context, context->linkProgram(programObject));
-#ifndef NDEBUG
-    int linked = 0;
-    GLC(context, context->getProgramiv(programObject, GraphicsContext3D::LINK_STATUS, &linked));
-    if (!linked) {
-        if (!contextLost(context))
-            LOG_ERROR("Failed to link shader program");
-        GLC(context, context->deleteProgram(programObject));
-        return 0;
-    }
-#endif
-
-    GLC(context, context->deleteShader(vertexShader));
-    GLC(context, context->deleteShader(fragmentShader));
     return programObject;
 }
 
+void ProgramBindingBase::cleanupShaders(WebGraphicsContext3D* context)
+{
+    if (m_vertexShaderId) {
+        GLC(context, context->deleteShader(m_vertexShaderId));
+        m_vertexShaderId = 0;
+    }
+    if (m_fragmentShaderId) {
+        GLC(context, context->deleteShader(m_fragmentShaderId));
+        m_fragmentShaderId = 0;
+    }
+}
+
 } // namespace WebCore
 
 #endif // USE(ACCELERATED_COMPOSITING)
index 39048f9..c2d47df 100644 (file)
@@ -42,6 +42,7 @@ public:
     ~ProgramBindingBase();
 
     void init(WebKit::WebGraphicsContext3D*, const String& vertexShader, const String& fragmentShader);
+    void link(WebKit::WebGraphicsContext3D*);
     void cleanup(WebKit::WebGraphicsContext3D*);
 
     unsigned program() const { ASSERT(m_initialized); return m_program; }
@@ -50,9 +51,12 @@ public:
 protected:
 
     unsigned loadShader(WebKit::WebGraphicsContext3D*, unsigned type, const String& shaderSource);
-    unsigned createShaderProgram(WebKit::WebGraphicsContext3D*, const String& vertexShaderSource, const String& fragmentShaderSource);
+    unsigned createShaderProgram(WebKit::WebGraphicsContext3D*, unsigned vertexShader, unsigned fragmentShader);
+    void cleanupShaders(WebKit::WebGraphicsContext3D*);
 
     unsigned m_program;
+    unsigned m_vertexShaderId;
+    unsigned m_fragmentShaderId;
     bool m_initialized;
 };
 
@@ -64,14 +68,24 @@ public:
         ProgramBindingBase::init(context, m_vertexShader.getShaderString(), m_fragmentShader.getShaderString());
     }
 
-    void initialize(WebKit::WebGraphicsContext3D* context)
+    void initialize(WebKit::WebGraphicsContext3D* context, bool usingBindUniform)
     {
         ASSERT(context);
         ASSERT(m_program);
         ASSERT(!m_initialized);
 
-        m_vertexShader.init(context, m_program);
-        m_fragmentShader.init(context, m_program);
+        // Need to bind uniforms before linking
+        if (!usingBindUniform)
+            link(context);
+
+        int baseUniformIndex = 0;
+        m_vertexShader.init(context, m_program, usingBindUniform, &baseUniformIndex);
+        m_fragmentShader.init(context, m_program, usingBindUniform, &baseUniformIndex);
+
+        // Link after binding uniforms
+        if (usingBindUniform)
+            link(context);
+
         m_initialized = true;
     }
 
index 2a140d1..7ee5a21 100644 (file)
@@ -38,14 +38,38 @@ using WebKit::WebGraphicsContext3D;
 
 namespace WebCore {
 
+namespace {
+
+static void getProgramUniformLocations(WebGraphicsContext3D* context, unsigned program, const char** shaderUniforms, size_t count, size_t maxLocations, int* locations, bool usingBindUniform, int* baseUniformIndex)
+{
+    for (size_t uniformIndex = 0; uniformIndex < count; uniformIndex ++) {
+        ASSERT(uniformIndex < maxLocations);
+
+        if (usingBindUniform) {
+            locations[uniformIndex] = (*baseUniformIndex)++;
+            context->bindUniformLocationCHROMIUM(program, locations[uniformIndex], shaderUniforms[uniformIndex]);
+        } else
+            locations[uniformIndex] = context->getUniformLocation(program, shaderUniforms[uniformIndex]);
+    }
+}
+
+}
+
 VertexShaderPosTex::VertexShaderPosTex()
     : m_matrixLocation(-1)
 {
 }
 
-void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program)
+void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_matrixLocation = context->getUniformLocation(program, "matrix");
+    static const char* shaderUniforms[] = {
+        "matrix",
+    };
+    int locations[1];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_matrixLocation = locations[0];
     ASSERT(m_matrixLocation != -1);
 }
 
@@ -71,11 +95,20 @@ VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch()
 {
 }
 
-void VertexShaderPosTexYUVStretch::init(WebGraphicsContext3D* context, unsigned program)
+void VertexShaderPosTexYUVStretch::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_matrixLocation = context->getUniformLocation(program, "matrix");
-    m_yWidthScaleFactorLocation = context->getUniformLocation(program, "y_widthScaleFactor");
-    m_uvWidthScaleFactorLocation = context->getUniformLocation(program, "uv_widthScaleFactor");
+    static const char* shaderUniforms[] = {
+        "matrix",
+        "y_widthScaleFactor",
+        "uv_widthScaleFactor",
+    };
+    int locations[3];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_matrixLocation = locations[0];
+    m_yWidthScaleFactorLocation = locations[1];
+    m_uvWidthScaleFactorLocation = locations[2];
     ASSERT(m_matrixLocation != -1 && m_yWidthScaleFactorLocation != -1 && m_uvWidthScaleFactorLocation != -1);
 }
 
@@ -104,9 +137,16 @@ VertexShaderPos::VertexShaderPos()
 {
 }
 
-void VertexShaderPos::init(WebGraphicsContext3D* context, unsigned program)
+void VertexShaderPos::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_matrixLocation = context->getUniformLocation(program, "matrix");
+    static const char* shaderUniforms[] = {
+        "matrix",
+    };
+    int locations[1];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_matrixLocation = locations[0];
     ASSERT(m_matrixLocation != -1);
 }
 
@@ -128,10 +168,18 @@ VertexShaderPosTexTransform::VertexShaderPosTexTransform()
 {
 }
 
-void VertexShaderPosTexTransform::init(WebGraphicsContext3D* context, unsigned program)
+void VertexShaderPosTexTransform::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_matrixLocation = context->getUniformLocation(program, "matrix");
-    m_texTransformLocation = context->getUniformLocation(program, "texTransform");
+    static const char* shaderUniforms[] = {
+        "matrix",
+        "texTransform",
+    };
+    int locations[2];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_matrixLocation = locations[0];
+    m_texTransformLocation = locations[1];
     ASSERT(m_matrixLocation != -1 && m_texTransformLocation != -1);
 }
 
@@ -170,10 +218,18 @@ String VertexShaderPosTexIdentity::getShaderString() const
     );
 }
 
-void VertexShaderQuad::init(WebGraphicsContext3D* context, unsigned program)
+void VertexShaderQuad::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_matrixLocation = context->getUniformLocation(program, "matrix");
-    m_pointLocation = context->getUniformLocation(program, "point");
+    static const char* shaderUniforms[] = {
+        "matrix",
+        "point",
+    };
+    int locations[2];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_matrixLocation = locations[0];
+    m_pointLocation = locations[1];
     ASSERT(m_matrixLocation != -1 && m_pointLocation != -1);
 }
 
@@ -206,11 +262,20 @@ VertexShaderTile::VertexShaderTile()
 {
 }
 
-void VertexShaderTile::init(WebGraphicsContext3D* context, unsigned program)
+void VertexShaderTile::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_matrixLocation = context->getUniformLocation(program, "matrix");
-    m_pointLocation = context->getUniformLocation(program, "point");
-    m_vertexTexTransformLocation = context->getUniformLocation(program, "vertexTexTransform");
+    static const char* shaderUniforms[] = {
+        "matrix",
+        "point",
+        "vertexTexTransform",
+    };
+    int locations[3];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_matrixLocation = locations[0];
+    m_pointLocation = locations[1];
+    m_vertexTexTransformLocation = locations[2];
     ASSERT(m_matrixLocation != -1 && m_pointLocation != -1 && m_vertexTexTransformLocation != -1);
 }
 
@@ -243,10 +308,18 @@ VertexShaderVideoTransform::VertexShaderVideoTransform()
 {
 }
 
-bool VertexShaderVideoTransform::init(WebGraphicsContext3D* context, unsigned program)
+bool VertexShaderVideoTransform::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_matrixLocation = context->getUniformLocation(program, "matrix");
-    m_texMatrixLocation = context->getUniformLocation(program, "texMatrix");
+    static const char* shaderUniforms[] = {
+        "matrix",
+        "texMatrix",
+    };
+    int locations[2];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_matrixLocation = locations[0];
+    m_texMatrixLocation = locations[1];
     return m_matrixLocation != -1 && m_texMatrixLocation != -1;
 }
 
@@ -272,11 +345,18 @@ FragmentTexAlphaBinding::FragmentTexAlphaBinding()
 {
 }
 
-void FragmentTexAlphaBinding::init(WebGraphicsContext3D* context, unsigned program)
+void FragmentTexAlphaBinding::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_samplerLocation = context->getUniformLocation(program, "s_texture");
-    m_alphaLocation = context->getUniformLocation(program, "alpha");
+    static const char* shaderUniforms[] = {
+        "s_texture",
+        "alpha",
+    };
+    int locations[2];
 
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_samplerLocation = locations[0];
+    m_alphaLocation = locations[1];
     ASSERT(m_samplerLocation != -1 && m_alphaLocation != -1);
 }
 
@@ -285,10 +365,16 @@ FragmentTexOpaqueBinding::FragmentTexOpaqueBinding()
 {
 }
 
-void FragmentTexOpaqueBinding::init(WebGraphicsContext3D* context, unsigned program)
+void FragmentTexOpaqueBinding::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_samplerLocation = context->getUniformLocation(program, "s_texture");
+    static const char* shaderUniforms[] = {
+        "s_texture",
+    };
+    int locations[1];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
 
+    m_samplerLocation = locations[0];
     ASSERT(m_samplerLocation != -1);
 }
 
@@ -307,10 +393,16 @@ String FragmentShaderRGBATexFlipAlpha::getShaderString() const
     );
 }
 
-bool FragmentShaderOESImageExternal::init(WebGraphicsContext3D* context, unsigned program)
+bool FragmentShaderOESImageExternal::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_samplerLocation = context->getUniformLocation(program, "s_texture");
+    static const char* shaderUniforms[] = {
+        "s_texture",
+    };
+    int locations[1];
 
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_samplerLocation = locations[0];
     return m_samplerLocation != -1;
 }
 
@@ -437,12 +529,20 @@ FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA()
 {
 }
 
-void FragmentShaderRGBATexAlphaAA::init(WebGraphicsContext3D* context, unsigned program)
+void FragmentShaderRGBATexAlphaAA::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_samplerLocation = context->getUniformLocation(program, "s_texture");
-    m_alphaLocation = context->getUniformLocation(program, "alpha");
-    m_edgeLocation = context->getUniformLocation(program, "edge");
+    static const char* shaderUniforms[] = {
+        "s_texture",
+        "alpha",
+        "edge",
+    };
+    int locations[3];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
 
+    m_samplerLocation = locations[0];
+    m_alphaLocation = locations[1];
+    m_edgeLocation = locations[2];
     ASSERT(m_samplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation != -1);
 }
 
@@ -479,13 +579,22 @@ FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding()
 {
 }
 
-void FragmentTexClampAlphaAABinding::init(WebGraphicsContext3D* context, unsigned program)
+void FragmentTexClampAlphaAABinding::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_samplerLocation = context->getUniformLocation(program, "s_texture");
-    m_alphaLocation = context->getUniformLocation(program, "alpha");
-    m_fragmentTexTransformLocation = context->getUniformLocation(program, "fragmentTexTransform");
-    m_edgeLocation = context->getUniformLocation(program, "edge");
+    static const char* shaderUniforms[] = {
+        "s_texture",
+        "alpha",
+        "fragmentTexTransform",
+        "edge",
+    };
+    int locations[4];
 
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_samplerLocation = locations[0];
+    m_alphaLocation = locations[1];
+    m_fragmentTexTransformLocation = locations[2];
+    m_edgeLocation = locations[3];
     ASSERT(m_samplerLocation != -1 && m_alphaLocation != -1 && m_fragmentTexTransformLocation != -1 && m_edgeLocation != -1);
 }
 
@@ -550,11 +659,20 @@ FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask()
 {
 }
 
-void FragmentShaderRGBATexAlphaMask::init(WebGraphicsContext3D* context, unsigned program)
+void FragmentShaderRGBATexAlphaMask::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_samplerLocation = context->getUniformLocation(program, "s_texture");
-    m_maskSamplerLocation = context->getUniformLocation(program, "s_mask");
-    m_alphaLocation = context->getUniformLocation(program, "alpha");
+    static const char* shaderUniforms[] = {
+        "s_texture",
+        "s_mask",
+        "alpha",
+    };
+    int locations[3];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_samplerLocation = locations[0];
+    m_maskSamplerLocation = locations[1];
+    m_alphaLocation = locations[2];
     ASSERT(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLocation != -1);
 }
 
@@ -583,12 +701,22 @@ FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA()
 {
 }
 
-void FragmentShaderRGBATexAlphaMaskAA::init(WebGraphicsContext3D* context, unsigned program)
+void FragmentShaderRGBATexAlphaMaskAA::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_samplerLocation = context->getUniformLocation(program, "s_texture");
-    m_maskSamplerLocation = context->getUniformLocation(program, "s_mask");
-    m_alphaLocation = context->getUniformLocation(program, "alpha");
-    m_edgeLocation = context->getUniformLocation(program, "edge");
+    static const char* shaderUniforms[] = {
+        "s_texture",
+        "s_mask",
+        "alpha",
+        "edge",
+    };
+    int locations[4];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_samplerLocation = locations[0];
+    m_maskSamplerLocation = locations[1];
+    m_alphaLocation = locations[2];
+    m_edgeLocation = locations[3];
     ASSERT(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation != -1);
 }
 
@@ -629,14 +757,26 @@ FragmentShaderYUVVideo::FragmentShaderYUVVideo()
 {
 }
 
-void FragmentShaderYUVVideo::init(WebGraphicsContext3D* context, unsigned program)
+void FragmentShaderYUVVideo::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_yTextureLocation = context->getUniformLocation(program, "y_texture");
-    m_uTextureLocation = context->getUniformLocation(program, "u_texture");
-    m_vTextureLocation = context->getUniformLocation(program, "v_texture");
-    m_alphaLocation = context->getUniformLocation(program, "alpha");
-    m_ccMatrixLocation = context->getUniformLocation(program, "cc_matrix");
-    m_yuvAdjLocation = context->getUniformLocation(program, "yuv_adj");
+    static const char* shaderUniforms[] = {
+        "y_texture",
+        "u_texture",
+        "v_texture",
+        "alpha",
+        "cc_matrix",
+        "yuv_adj",
+    };
+    int locations[6];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_yTextureLocation = locations[0];
+    m_uTextureLocation = locations[1];
+    m_vTextureLocation = locations[2];
+    m_alphaLocation = locations[3];
+    m_ccMatrixLocation = locations[4];
+    m_yuvAdjLocation = locations[5];
 
     ASSERT(m_yTextureLocation != -1 && m_uTextureLocation != -1 && m_vTextureLocation != -1
            && m_alphaLocation != -1 && m_ccMatrixLocation != -1 && m_yuvAdjLocation != -1);
@@ -672,9 +812,16 @@ FragmentShaderColor::FragmentShaderColor()
 {
 }
 
-void FragmentShaderColor::init(WebGraphicsContext3D* context, unsigned program)
+void FragmentShaderColor::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_colorLocation = context->getUniformLocation(program, "color");
+    static const char* shaderUniforms[] = {
+        "color",
+    };
+    int locations[1];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_colorLocation = locations[0];
     ASSERT(m_colorLocation != -1);
 }
 
@@ -697,11 +844,20 @@ FragmentShaderCheckerboard::FragmentShaderCheckerboard()
 {
 }
 
-void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned program)
+void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
 {
-    m_alphaLocation = context->getUniformLocation(program, "alpha");
-    m_texTransformLocation = context->getUniformLocation(program, "texTransform");
-    m_frequencyLocation = context->getUniformLocation(program, "frequency");
+    static const char* shaderUniforms[] = {
+        "alpha",
+        "texTransform",
+        "frequency",
+    };
+    int locations[3];
+
+    getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGTH(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, baseUniformIndex);
+
+    m_alphaLocation = locations[0];
+    m_texTransformLocation = locations[1];
+    m_frequencyLocation = locations[2];
     ASSERT(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyLocation != -1);
 }
 
index a80cfb7..00872e4 100644 (file)
@@ -41,7 +41,7 @@ class VertexShaderPosTex {
 public:
     VertexShaderPosTex();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -54,7 +54,7 @@ class VertexShaderPosTexYUVStretch {
 public:
     VertexShaderPosTexYUVStretch();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -71,7 +71,7 @@ class VertexShaderPos {
 public:
     VertexShaderPos();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -82,7 +82,7 @@ private:
 
 class VertexShaderPosTexIdentity {
 public:
-    void init(WebKit::WebGraphicsContext3D*, unsigned program) { }
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex) { }
     String getShaderString() const;
 };
 
@@ -90,7 +90,7 @@ class VertexShaderPosTexTransform {
 public:
     VertexShaderPosTexTransform();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -105,7 +105,7 @@ class VertexShaderQuad {
 public:
     VertexShaderQuad();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -120,7 +120,7 @@ class VertexShaderTile {
 public:
     VertexShaderTile();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -137,7 +137,7 @@ class VertexShaderVideoTransform {
 public:
     VertexShaderVideoTransform();
 
-    bool init(WebKit::WebGraphicsContext3D*, unsigned program);
+    bool init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -152,7 +152,7 @@ class FragmentTexAlphaBinding {
 public:
     FragmentTexAlphaBinding();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     int alphaLocation() const { return m_alphaLocation; }
     int edgeLocation() const { return -1; }
     int fragmentTexTransformLocation() const { return -1; }
@@ -167,7 +167,7 @@ class FragmentTexOpaqueBinding {
 public:
     FragmentTexOpaqueBinding();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     int alphaLocation() const { return -1; }
     int edgeLocation() const { return -1; }
     int fragmentTexTransformLocation() const { return -1; }
@@ -223,7 +223,7 @@ public:
 class FragmentShaderOESImageExternal : public FragmentTexAlphaBinding {
 public:
     String getShaderString() const;
-    bool init(WebKit::WebGraphicsContext3D*, unsigned program);
+    bool init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
 private:
     int m_samplerLocation;
 };
@@ -232,7 +232,7 @@ class FragmentShaderRGBATexAlphaAA {
 public:
     FragmentShaderRGBATexAlphaAA();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     String getShaderString() const;
 
     int alphaLocation() const { return m_alphaLocation; }
@@ -249,7 +249,7 @@ class FragmentTexClampAlphaAABinding {
 public:
     FragmentTexClampAlphaAABinding();
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     int alphaLocation() const { return m_alphaLocation; }
     int samplerLocation() const { return m_samplerLocation; }
     int fragmentTexTransformLocation() const { return m_fragmentTexTransformLocation; }
@@ -278,7 +278,7 @@ public:
     FragmentShaderRGBATexAlphaMask();
     String getShaderString() const;
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     int alphaLocation() const { return m_alphaLocation; }
     int samplerLocation() const { return m_samplerLocation; }
     int maskSamplerLocation() const { return m_maskSamplerLocation; }
@@ -294,7 +294,7 @@ public:
     FragmentShaderRGBATexAlphaMaskAA();
     String getShaderString() const;
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     int alphaLocation() const { return m_alphaLocation; }
     int samplerLocation() const { return m_samplerLocation; }
     int maskSamplerLocation() const { return m_maskSamplerLocation; }
@@ -312,7 +312,7 @@ public:
     FragmentShaderYUVVideo();
     String getShaderString() const;
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
 
     int yTextureLocation() const { return m_yTextureLocation; }
     int uTextureLocation() const { return m_uTextureLocation; }
@@ -335,7 +335,7 @@ public:
     FragmentShaderColor();
     String getShaderString() const;
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     int colorLocation() const { return m_colorLocation; }
 
 private:
@@ -347,7 +347,7 @@ public:
     FragmentShaderCheckerboard();
     String getShaderString() const;
 
-    void init(WebKit::WebGraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program, bool usingBindUniform, int* baseUniformIndex);
     int alphaLocation() const { return m_alphaLocation; }
     int texTransformLocation() const { return m_texTransformLocation; }
     int frequencyLocation() const { return m_frequencyLocation; }
index 262784d..33243c8 100644 (file)
@@ -34,8 +34,9 @@
 namespace WebCore {
 
 #if USE(ACCELERATED_COMPOSITING)
-AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D* context)
+AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D* context, bool usingBindUniforms)
     : m_context(context)
+    , m_usingBindUniforms(usingBindUniforms)
 {
     ASSERT(m_context);
     GLC(m_context, m_fbo = m_context->createFramebuffer());
@@ -90,7 +91,7 @@ void AcceleratedTextureCopier::copyTexture(CCGraphicsContext* ccContext, unsigne
     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST));
 
     if (!m_blitProgram->initialized())
-        m_blitProgram->initialize(context);
+        m_blitProgram->initialize(context, m_usingBindUniforms);
 
     // TODO: Use EXT_framebuffer_blit if available.
     GLC(context, context->useProgram(m_blitProgram->program()));
index 646189a..c2bcd42 100644 (file)
@@ -53,16 +53,16 @@ protected:
 class AcceleratedTextureCopier : public TextureCopier {
     WTF_MAKE_NONCOPYABLE(AcceleratedTextureCopier);
 public:
-    static PassOwnPtr<AcceleratedTextureCopier> create(WebKit::WebGraphicsContext3D* context)
+    static PassOwnPtr<AcceleratedTextureCopier> create(WebKit::WebGraphicsContext3D* context, bool usingBindUniforms)
     {
-        return adoptPtr(new AcceleratedTextureCopier(context));
+        return adoptPtr(new AcceleratedTextureCopier(context, usingBindUniforms));
     }
     virtual ~AcceleratedTextureCopier();
 
     virtual void copyTexture(CCGraphicsContext*, unsigned sourceTextureId, unsigned destTextureId, const IntSize&);
 
 protected:
-    explicit AcceleratedTextureCopier(WebKit::WebGraphicsContext3D*);
+    AcceleratedTextureCopier(WebKit::WebGraphicsContext3D*, bool usingBindUniforms);
 
 private:
     typedef ProgramBinding<VertexShaderPosTexIdentity, FragmentShaderRGBATex> BlitProgram;
@@ -71,6 +71,7 @@ private:
     Platform3DObject m_fbo;
     Platform3DObject m_positionBuffer;
     OwnPtr<BlitProgram> m_blitProgram;
+    bool m_usingBindUniforms;
 };
 
 #endif // USE(ACCELERATED_COMPOSITING)
index 3a5f3cd..df67fef 100644 (file)
@@ -1,3 +1,14 @@
+2012-07-03  Alex Sakhartchouk  <alexst@chromium.org>
+
+        [chromium] Avoid calling getUniformLocation??() in the compositor startup
+        https://bugs.webkit.org/show_bug.cgi?id=90217
+
+        Reviewed by Adrienne Walker.
+
+        Fixing the build error.
+
+        * tests/TextureCopierTest.cpp:
+
 2012-07-03  Erik Arvidsson  <arv@chromium.org>
 
         [V8] Remove enableFasterDOMStoreAccess which is never used
index 2c90c4e..b3ef4c2 100644 (file)
@@ -78,7 +78,7 @@ TEST(TextureCopierTest, testDrawArraysCopy)
     int sourceTextureId = 1;
     int destTextureId = 2;
     IntSize size(256, 128);
-    OwnPtr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create(ccContext->context3D()));
+    OwnPtr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create(ccContext->context3D(), false));
     copier->copyTexture(ccContext.get(), sourceTextureId, destTextureId, size);
 }