⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 100047 in webkit


Ignore:
Timestamp:
Nov 11, 2011, 4:57:48 PM (15 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Add translation/scaling to WebExternalTextureLayer
https://bugs.webkit.org/show_bug.cgi?id=72087

Patch by Antoine Labour <piman@chromium.org> on 2011-11-11
Reviewed by James Robinson.

Source/WebCore:

Covered by WebLayerTest.

  • platform/graphics/chromium/PluginLayerChromium.cpp:

(WebCore::PluginLayerChromium::PluginLayerChromium):
(WebCore::PluginLayerChromium::setUVRect):
(WebCore::PluginLayerChromium::pushPropertiesTo):

  • platform/graphics/chromium/PluginLayerChromium.h:

(WebCore::PluginLayerChromium::uvRect):

  • platform/graphics/chromium/ShaderChromium.cpp:

(WebCore::VertexShaderPosTexStretch::VertexShaderPosTexStretch):
(WebCore::VertexShaderPosTexStretch::init):
(WebCore::VertexShaderPosTexStretch::getShaderString):

  • platform/graphics/chromium/ShaderChromium.h:

(WebCore::VertexShaderPosTexStretch::matrixLocation):
(WebCore::VertexShaderPosTexStretch::offsetLocation):
(WebCore::VertexShaderPosTexStretch::scaleLocation):

  • platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:

(WebCore::CCPluginLayerImpl::CCPluginLayerImpl):
(WebCore::CCPluginLayerImpl::draw):

  • platform/graphics/chromium/cc/CCPluginLayerImpl.h:

(WebCore::CCPluginLayerImpl::setUVRect):

Source/WebKit/chromium:

  • public/WebExternalTextureLayer.h:
  • src/WebExternalTextureLayer.cpp:

(WebKit::WebExternalTextureLayer::setUVRect):
(WebKit::WebExternalTextureLayer::uvRect):

Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r100046 r100047  
     12011-11-11  Antoine Labour  <piman@chromium.org>
     2
     3        [chromium] Add translation/scaling to WebExternalTextureLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=72087
     5
     6        Reviewed by James Robinson.
     7
     8        Covered by WebLayerTest.
     9
     10        * platform/graphics/chromium/PluginLayerChromium.cpp:
     11        (WebCore::PluginLayerChromium::PluginLayerChromium):
     12        (WebCore::PluginLayerChromium::setUVRect):
     13        (WebCore::PluginLayerChromium::pushPropertiesTo):
     14        * platform/graphics/chromium/PluginLayerChromium.h:
     15        (WebCore::PluginLayerChromium::uvRect):
     16        * platform/graphics/chromium/ShaderChromium.cpp:
     17        (WebCore::VertexShaderPosTexStretch::VertexShaderPosTexStretch):
     18        (WebCore::VertexShaderPosTexStretch::init):
     19        (WebCore::VertexShaderPosTexStretch::getShaderString):
     20        * platform/graphics/chromium/ShaderChromium.h:
     21        (WebCore::VertexShaderPosTexStretch::matrixLocation):
     22        (WebCore::VertexShaderPosTexStretch::offsetLocation):
     23        (WebCore::VertexShaderPosTexStretch::scaleLocation):
     24        * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
     25        (WebCore::CCPluginLayerImpl::CCPluginLayerImpl):
     26        (WebCore::CCPluginLayerImpl::draw):
     27        * platform/graphics/chromium/cc/CCPluginLayerImpl.h:
     28        (WebCore::CCPluginLayerImpl::setUVRect):
     29
    1302011-11-11  Stephen Chenney  <schenney@chromium.org>
    231
  • trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp

    r97550 r100047  
    4646    , m_textureId(0)
    4747    , m_flipped(true)
     48    , m_uvRect(0, 0, 1, 1)
    4849{
    4950}
     
    6667}
    6768
     69void PluginLayerChromium::setUVRect(const FloatRect& rect)
     70{
     71    m_uvRect = rect;
     72    setNeedsCommit();
     73}
     74
    6875void PluginLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
    6976{
     
    7380    pluginLayer->setTextureId(m_textureId);
    7481    pluginLayer->setFlipped(m_flipped);
     82    pluginLayer->setUVRect(m_uvRect);
    7583}
    7684
  • trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h

    r97550 r100047  
    4646    void setFlipped(bool);
    4747    bool flipped() const { return m_flipped; }
     48    void setUVRect(const FloatRect&);
     49    const FloatRect& uvRect() const { return m_uvRect; }
    4850
    4951    virtual void pushPropertiesTo(CCLayerImpl*);
     
    5557    unsigned m_textureId;
    5658    bool m_flipped;
     59    FloatRect m_uvRect;
    5760};
    5861
  • trunk/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp

    r95901 r100047  
    6464}
    6565
     66VertexShaderPosTexStretch::VertexShaderPosTexStretch()
     67    : m_matrixLocation(-1)
     68    , m_offsetLocation(-1)
     69    , m_scaleLocation(-1)
     70{
     71}
     72
     73void VertexShaderPosTexStretch::init(GraphicsContext3D* context, unsigned program)
     74{
     75    m_matrixLocation = context->getUniformLocation(program, "matrix");
     76    m_offsetLocation = context->getUniformLocation(program, "offset");
     77    m_scaleLocation = context->getUniformLocation(program, "scale");
     78    ASSERT(m_matrixLocation != -1 && m_offsetLocation != -1 && m_scaleLocation != -1);
     79}
     80
     81String VertexShaderPosTexStretch::getShaderString() const
     82{
     83    return SHADER(
     84        attribute vec4 a_position;
     85        attribute vec2 a_texCoord;
     86        uniform mat4 matrix;
     87        uniform vec2 offset;
     88        uniform vec2 scale;
     89        varying vec2 v_texCoord;
     90        void main()
     91        {
     92            gl_Position = matrix * a_position;
     93            v_texCoord = scale * a_texCoord + offset;
     94        }
     95    );
     96}
     97
    6698VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch()
    6799    : m_matrixLocation(-1)
  • trunk/Source/WebCore/platform/graphics/chromium/ShaderChromium.h

    r95901 r100047  
    5252};
    5353
     54class VertexShaderPosTexStretch {
     55public:
     56    VertexShaderPosTexStretch();
     57
     58    void init(GraphicsContext3D*, unsigned program);
     59    String getShaderString() const;
     60
     61    int matrixLocation() const { return m_matrixLocation; }
     62    int offsetLocation() const { return m_offsetLocation; }
     63    int scaleLocation() const { return m_scaleLocation; }
     64
     65private:
     66    int m_matrixLocation;
     67    int m_offsetLocation;
     68    int m_scaleLocation;
     69};
     70
    5471class VertexShaderPosTexYUVStretch {
    5572public:
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp

    r97550 r100047  
    4444        samplerLocation = program->fragmentShader().samplerLocation();
    4545        matrixLocation = program->vertexShader().matrixLocation();
     46        offsetLocation = program->vertexShader().offsetLocation();
     47        scaleLocation = program->vertexShader().scaleLocation();
    4648        alphaLocation = program->fragmentShader().alphaLocation();
    4749    }
     
    4951    int samplerLocation;
    5052    int matrixLocation;
     53    int offsetLocation;
     54    int scaleLocation;
    5155    int alphaLocation;
    5256};
     
    6064    , m_textureId(0)
    6165    , m_flipped(true)
     66    , m_uvRect(0, 0, 1, 1)
    6267{
    6368}
     
    8994    GLC(context, context->useProgram(binding.programId));
    9095    GLC(context, context->uniform1i(binding.samplerLocation, 0));
     96    GLC(context, context->uniform2f(binding.offsetLocation, m_uvRect.x(), m_uvRect.y()));
     97    GLC(context, context->uniform2f(binding.scaleLocation, m_uvRect.width(), m_uvRect.height()));
    9198    layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(),
    9299                                    binding.matrixLocation,
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h

    r97550 r100047  
    2727#define CCPluginLayerImpl_h
    2828
     29#include "FloatRect.h"
    2930#include "ProgramBinding.h"
    3031#include "ShaderChromium.h"
     
    4142    virtual ~CCPluginLayerImpl();
    4243
    43     typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Program;
    44     typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexFlipAlpha> ProgramFlip;
     44    typedef ProgramBinding<VertexShaderPosTexStretch, FragmentShaderRGBATexAlpha> Program;
     45    typedef ProgramBinding<VertexShaderPosTexStretch, FragmentShaderRGBATexFlipAlpha> ProgramFlip;
    4546
    4647    virtual void draw(LayerRendererChromium*);
     
    5051    void setTextureId(unsigned id) { m_textureId = id; }
    5152    void setFlipped(bool flipped) { m_flipped = flipped; }
     53    void setUVRect(const FloatRect& rect) { m_uvRect = rect; }
    5254
    5355private:
     
    5860    unsigned m_textureId;
    5961    bool m_flipped;
     62    FloatRect m_uvRect;
    6063};
    6164
  • trunk/Source/WebKit/chromium/ChangeLog

    r100041 r100047  
     12011-11-11  Antoine Labour  <piman@chromium.org>
     2
     3        [chromium] Add translation/scaling to WebExternalTextureLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=72087
     5
     6        Reviewed by James Robinson.
     7
     8        * public/WebExternalTextureLayer.h:
     9        * src/WebExternalTextureLayer.cpp:
     10        (WebKit::WebExternalTextureLayer::setUVRect):
     11        (WebKit::WebExternalTextureLayer::uvRect):
     12
    1132011-11-11  Adam Klein  <adamk@chromium.org>
    214
  • trunk/Source/WebKit/chromium/public/WebExternalTextureLayer.h

    r98035 r100047  
    2828
    2929#include "WebCommon.h"
     30#include "WebFloatRect.h"
    3031#include "WebLayer.h"
    3132
     
    6364    WEBKIT_EXPORT bool flipped() const;
    6465
     66    // Sets the rect in UV space of the texture that is mapped to the layer
     67    // bounds.
     68    WEBKIT_EXPORT void setUVRect(const WebFloatRect&);
     69    WEBKIT_EXPORT WebFloatRect uvRect() const;
     70
    6571#if WEBKIT_IMPLEMENTATION
    6672    WebExternalTextureLayer(const WTF::PassRefPtr<WebExternalTextureLayerImpl>&);
  • trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp

    r97550 r100047  
    5757}
    5858
     59void WebExternalTextureLayer::setUVRect(const WebFloatRect& rect)
     60{
     61    unwrap<WebExternalTextureLayerImpl>()->setUVRect(rect);
     62}
     63
     64WebFloatRect WebExternalTextureLayer::uvRect() const
     65{
     66    return WebFloatRect(constUnwrap<WebExternalTextureLayerImpl>()->uvRect());
     67}
     68
    5969WebExternalTextureLayer::WebExternalTextureLayer(const PassRefPtr<WebExternalTextureLayerImpl>& node)
    6070    : WebLayer(node)
  • trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp

    r98630 r100047  
    3030#include "WebExternalTextureLayer.h"
    3131#include "WebFloatPoint.h"
     32#include "WebFloatRect.h"
    3233#include "WebLayerClient.h"
    3334#include "WebRect.h"
     
    128129    EXPECT_TRUE(textureLayer.flipped());
    129130
     131    EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     132    WebFloatRect uvRect(0.1, 0.1, 0.9, 0.9);
     133    textureLayer.setUVRect(uvRect);
     134    Mock::VerifyAndClearExpectations(&client);
     135    EXPECT_TRUE(textureLayer.flipped());
     136
    130137
    131138    // Content layer.
Note: See TracChangeset for help on using the changeset viewer.