Changeset 127911 in webkit


Ignore:
Timestamp:
Sep 7, 2012 1:19:26 PM (12 years ago)
Author:
anilsson@rim.com
Message:

[CSS Shaders] [BlackBerry] Refactor CustomFilterMesh and CustomFilter*Program
https://bugs.webkit.org/show_bug.cgi?id=94725

Reviewed by Rob Buis.

Separate the MeshGenerator from the CustomFilterMesh into
CustomFilterMeshGenerator.h/cpp. This allows the BlackBerry port to
reuse the mesh generator in its accelerated compositing implementation.

Also add support for creating a "PlatformCompiledProgram" from a
CustomFilterValidatedProgram, so the BlackBerry port can reuse the
shader validation code in its accelerated compositing implementation.

It turns out the GraphicsContext3D is not needed for ANGLE to function,
so this patch removes an ASSERT that required a context before
validating the shaders using ANGLE. This allows the BlackBerry port to
reuse the validation code without triggering the assert. In the future,
the validation code could be moved to a separate class to make it more
obvious that it isn't really related to GraphicsContext3D.

In general, this refactoring can be useful for any port that uses
OpenGL to implement accelerated compositing.

Inspired by an original patch by Joshua Netterfield.

No new tests, because this patch implements no new functionality.

  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/filters/CustomFilterGlobalContext.cpp:

(WebCore::CustomFilterGlobalContext::getValidatedProgram):

  • platform/graphics/filters/CustomFilterMesh.cpp:

(WebCore::CustomFilterMesh::CustomFilterMesh):

  • platform/graphics/filters/CustomFilterMeshGenerator.cpp: Added.

(WebCore):
(WebCore::CustomFilterMeshGenerator::CustomFilterMeshGenerator):
(WebCore::CustomFilterMeshGenerator::addAttachedMeshIndex):
(WebCore::CustomFilterMeshGenerator::generateAttachedMesh):
(WebCore::CustomFilterMeshGenerator::addDetachedMeshVertexAndIndex):
(WebCore::CustomFilterMeshGenerator::generateDetachedMesh):
(WebCore::CustomFilterMeshGenerator::addPositionAttribute):
(WebCore::CustomFilterMeshGenerator::addTexCoordAttribute):
(WebCore::CustomFilterMeshGenerator::addMeshCoordAttribute):
(WebCore::CustomFilterMeshGenerator::addTriangleCoordAttribute):
(WebCore::CustomFilterMeshGenerator::addAttachedMeshVertexAttributes):
(WebCore::CustomFilterMeshGenerator::addDetachedMeshVertexAttributes):
(WebCore::CustomFilterMeshGenerator::dumpBuffers):

  • platform/graphics/filters/CustomFilterMeshGenerator.h: Added.

(WebCore):
(CustomFilterMeshGenerator):
(WebCore::CustomFilterMeshGenerator::vertices):
(WebCore::CustomFilterMeshGenerator::indices):
(WebCore::CustomFilterMeshGenerator::points):
(WebCore::CustomFilterMeshGenerator::pointsCount):
(WebCore::CustomFilterMeshGenerator::tiles):
(WebCore::CustomFilterMeshGenerator::tilesCount):
(WebCore::CustomFilterMeshGenerator::indicesCount):
(WebCore::CustomFilterMeshGenerator::floatsPerVertex):
(WebCore::CustomFilterMeshGenerator::verticesCount):
(WebCore::CustomFilterMeshGenerator::addTile):

  • platform/graphics/filters/CustomFilterValidatedProgram.cpp:

(WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram):
(WebCore::CustomFilterValidatedProgram::compiledProgram):
(WebCore::CustomFilterValidatedProgram::~CustomFilterValidatedProgram):
(WebCore):
(WebCore::CustomFilterValidatedProgram::platformCompiledProgram):
(WebCore::CustomFilterValidatedProgram::platformDestroy):

  • platform/graphics/filters/CustomFilterValidatedProgram.h:

(WebCore):
(CustomFilterValidatedProgram):

  • platform/graphics/filters/blackberry/CustomFilterValidatedProgramBlackBerry.cpp: Added.

(WebCore):
(WebCore::CustomFilterValidatedProgram::platformCompiledProgram):
(WebCore::CustomFilterValidatedProgram::platformDestroy):

Location:
trunk/Source/WebCore
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r127907 r127911  
     12012-09-07  Arvid Nilsson  <anilsson@rim.com>
     2
     3        [CSS Shaders] [BlackBerry] Refactor CustomFilterMesh and CustomFilter*Program
     4        https://bugs.webkit.org/show_bug.cgi?id=94725
     5
     6        Reviewed by Rob Buis.
     7
     8        Separate the MeshGenerator from the CustomFilterMesh into
     9        CustomFilterMeshGenerator.h/cpp. This allows the BlackBerry port to
     10        reuse the mesh generator in its accelerated compositing implementation.
     11
     12        Also add support for creating a "PlatformCompiledProgram" from a
     13        CustomFilterValidatedProgram, so the BlackBerry port can reuse the
     14        shader validation code in its accelerated compositing implementation.
     15
     16        It turns out the GraphicsContext3D is not needed for ANGLE to function,
     17        so this patch removes an ASSERT that required a context before
     18        validating the shaders using ANGLE. This allows the BlackBerry port to
     19        reuse the validation code without triggering the assert. In the future,
     20        the validation code could be moved to a separate class to make it more
     21        obvious that it isn't really related to GraphicsContext3D.
     22
     23        In general, this refactoring can be useful for any port that uses
     24        OpenGL to implement accelerated compositing.
     25
     26        Inspired by an original patch by Joshua Netterfield.
     27
     28        No new tests, because this patch implements no new functionality.
     29
     30        * GNUmakefile.list.am:
     31        * Target.pri:
     32        * WebCore.gypi:
     33        * WebCore.vcproj/WebCore.vcproj:
     34        * WebCore.xcodeproj/project.pbxproj:
     35        * platform/graphics/filters/CustomFilterGlobalContext.cpp:
     36        (WebCore::CustomFilterGlobalContext::getValidatedProgram):
     37        * platform/graphics/filters/CustomFilterMesh.cpp:
     38        (WebCore::CustomFilterMesh::CustomFilterMesh):
     39        * platform/graphics/filters/CustomFilterMeshGenerator.cpp: Added.
     40        (WebCore):
     41        (WebCore::CustomFilterMeshGenerator::CustomFilterMeshGenerator):
     42        (WebCore::CustomFilterMeshGenerator::addAttachedMeshIndex):
     43        (WebCore::CustomFilterMeshGenerator::generateAttachedMesh):
     44        (WebCore::CustomFilterMeshGenerator::addDetachedMeshVertexAndIndex):
     45        (WebCore::CustomFilterMeshGenerator::generateDetachedMesh):
     46        (WebCore::CustomFilterMeshGenerator::addPositionAttribute):
     47        (WebCore::CustomFilterMeshGenerator::addTexCoordAttribute):
     48        (WebCore::CustomFilterMeshGenerator::addMeshCoordAttribute):
     49        (WebCore::CustomFilterMeshGenerator::addTriangleCoordAttribute):
     50        (WebCore::CustomFilterMeshGenerator::addAttachedMeshVertexAttributes):
     51        (WebCore::CustomFilterMeshGenerator::addDetachedMeshVertexAttributes):
     52        (WebCore::CustomFilterMeshGenerator::dumpBuffers):
     53        * platform/graphics/filters/CustomFilterMeshGenerator.h: Added.
     54        (WebCore):
     55        (CustomFilterMeshGenerator):
     56        (WebCore::CustomFilterMeshGenerator::vertices):
     57        (WebCore::CustomFilterMeshGenerator::indices):
     58        (WebCore::CustomFilterMeshGenerator::points):
     59        (WebCore::CustomFilterMeshGenerator::pointsCount):
     60        (WebCore::CustomFilterMeshGenerator::tiles):
     61        (WebCore::CustomFilterMeshGenerator::tilesCount):
     62        (WebCore::CustomFilterMeshGenerator::indicesCount):
     63        (WebCore::CustomFilterMeshGenerator::floatsPerVertex):
     64        (WebCore::CustomFilterMeshGenerator::verticesCount):
     65        (WebCore::CustomFilterMeshGenerator::addTile):
     66        * platform/graphics/filters/CustomFilterValidatedProgram.cpp:
     67        (WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram):
     68        (WebCore::CustomFilterValidatedProgram::compiledProgram):
     69        (WebCore::CustomFilterValidatedProgram::~CustomFilterValidatedProgram):
     70        (WebCore):
     71        (WebCore::CustomFilterValidatedProgram::platformCompiledProgram):
     72        (WebCore::CustomFilterValidatedProgram::platformDestroy):
     73        * platform/graphics/filters/CustomFilterValidatedProgram.h:
     74        (WebCore):
     75        (CustomFilterValidatedProgram):
     76        * platform/graphics/filters/blackberry/CustomFilterValidatedProgramBlackBerry.cpp: Added.
     77        (WebCore):
     78        (WebCore::CustomFilterValidatedProgram::platformCompiledProgram):
     79        (WebCore::CustomFilterValidatedProgram::platformDestroy):
     80
    1812012-09-07  Dana Jansens  <danakj@chromium.org>
    282
  • trunk/Source/WebCore/GNUmakefile.list.am

    r127889 r127911  
    42534253        Source/WebCore/platform/graphics/filters/CustomFilterMesh.cpp \
    42544254        Source/WebCore/platform/graphics/filters/CustomFilterMesh.h \
     4255        Source/WebCore/platform/graphics/filters/CustomFilterMeshGenerator.cpp \
     4256        Source/WebCore/platform/graphics/filters/CustomFilterMeshGenerator.h \
    42554257        Source/WebCore/platform/graphics/filters/CustomFilterNumberParameter.h \
    42564258        Source/WebCore/platform/graphics/filters/CustomFilterOperation.cpp \
  • trunk/Source/WebCore/Target.pri

    r127877 r127911  
    20452045    platform/graphics/filters/CustomFilterGlobalContext.h \
    20462046    platform/graphics/filters/CustomFilterMesh.h \
     2047    platform/graphics/filters/CustomFilterMeshGenerator.h \
    20472048    platform/graphics/filters/CustomFilterNumberParameter.h \
    20482049    platform/graphics/filters/CustomFilterCompiledProgram.h \
     
    34473448        platform/graphics/filters/CustomFilterCompiledProgram.cpp \
    34483449        platform/graphics/filters/CustomFilterMesh.cpp \
     3450        platform/graphics/filters/CustomFilterMeshGenerator.cpp \
    34493451        platform/graphics/filters/CustomFilterValidatedProgram.cpp \
    34503452        platform/graphics/filters/DistantLightSource.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r127891 r127911  
    49134913            'platform/graphics/filters/CustomFilterGlobalContext.h',
    49144914            'platform/graphics/filters/CustomFilterMesh.h',
     4915            'platform/graphics/filters/CustomFilterMeshGenerator.h',
    49154916            'platform/graphics/filters/CustomFilterNumberParameter.h',
    49164917            'platform/graphics/filters/CustomFilterOperation.cpp',
     
    49264927            'platform/graphics/filters/CustomFilterValidatedProgram.h',
    49274928            'platform/graphics/filters/CustomFilterMesh.cpp',
     4929            'platform/graphics/filters/CustomFilterMeshGenerator.cpp',
    49284930            'platform/graphics/filters/CustomFilterTransformParameter.h',
    49294931            'platform/graphics/filters/DistantLightSource.cpp',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r127869 r127911  
    3188631886                                        </File>
    3188731887                                        <File
     31888                                                RelativePath="..\platform\graphics\filters\CustomFilterMeshGenerator.cpp"
     31889                                                >
     31890                                        </File>
     31891                                        <File
     31892                                                RelativePath="..\platform\graphics\filters\CustomFilterMeshGenerator.h"
     31893                                                >
     31894                                        </File>
     31895                                        <File
    3188831896                                                RelativePath="..\platform\graphics\filters\CustomFilterNumberParameter.h"
    3188931897                                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r127869 r127911  
    19881988                7BD117EC15B8DB0100C974A3 /* DOMTransactionStep.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BD117EA15B8DB0100C974A3 /* DOMTransactionStep.h */; };
    19891989                7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */; };
     1990                7E12E90F15FA5D3A005E4126 /* CustomFilterMeshGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E12E90D15FA5D3A005E4126 /* CustomFilterMeshGenerator.h */; };
     1991                7E12E91015FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E12E90E15FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp */; };
    19901992                7E33CD01127F340D00BE8F17 /* PurgePriority.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E33CD00127F340D00BE8F17 /* PurgePriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
    19911993                7E37EF2E1339208800B29250 /* SubresourceLoaderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E37EF2D1339208800B29250 /* SubresourceLoaderCF.cpp */; };
     
    91939195                7C522D4A15B478B2009B7C95 /* InspectorOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorOverlay.h; sourceTree = "<group>"; };
    91949196                7C60128060078BB70E367A95 /* DNSResolveQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNSResolveQueue.cpp; sourceTree = "<group>"; };
     9197                7E12E90D15FA5D3A005E4126 /* CustomFilterMeshGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterMeshGenerator.h; path = filters/CustomFilterMeshGenerator.h; sourceTree = "<group>"; };
     9198                7E12E90E15FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CustomFilterMeshGenerator.cpp; path = filters/CustomFilterMeshGenerator.cpp; sourceTree = "<group>"; };
    91959199                7E33CD00127F340D00BE8F17 /* PurgePriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgePriority.h; sourceTree = "<group>"; };
    91969200                7E37EF2D1339208800B29250 /* SubresourceLoaderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SubresourceLoaderCF.cpp; path = cf/SubresourceLoaderCF.cpp; sourceTree = "<group>"; };
     
    1815118155                        isa = PBXGroup;
    1815218156                        children = (
     18157                                7E12E90D15FA5D3A005E4126 /* CustomFilterMeshGenerator.h */,
     18158                                7E12E90E15FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp */,
    1815318159                                509EC10815E848CA00E82581 /* CustomFilterTransformParameter.h */,
    1815418160                                49ECEB5C1499790D00CDD3A4 /* arm */,
     
    2551225518                                0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */,
    2551325519                                4F377FF515FA356A00E5D60D /* WebCoreMemoryInstrumentation.h in Headers */,
     25520                                7E12E90F15FA5D3A005E4126 /* CustomFilterMeshGenerator.h in Headers */,
    2551425521                        );
    2551525522                        runOnlyForDeploymentPostprocessing = 0;
     
    2860428611                                76F2E2EB15F74CEF005FF664 /* RenderDialog.cpp in Sources */,
    2860528612                                0F605AEC15F94848004DF0C0 /* ScrollingConstraints.cpp in Sources */,
     28613                                7E12E91015FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp in Sources */,
    2860628614                        );
    2860728615                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp

    r127217 r127911  
    8888PassRefPtr<CustomFilterValidatedProgram> CustomFilterGlobalContext::getValidatedProgram(const CustomFilterProgramInfo& programInfo)
    8989{
    90     // Check that the context is already prepared.
    91     ASSERT(m_context);
    92 
    9390    CustomFilterValidatedProgramsMap::iterator iter = m_programs.find(programInfo);
    9491    if (iter != m_programs.end())
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterMesh.cpp

    r122189 r127911  
    3232#if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS)
    3333#include "CustomFilterMesh.h"
     34#include "CustomFilterMeshGenerator.h"
    3435#include "GraphicsContext3D.h"
    3536
    3637namespace WebCore {
    37    
    38 #ifndef NDEBUG
    39 // Use "call 'WebCore::s_dumpCustomFilterMeshBuffers' = 1" in GDB to activate printing of the mesh buffers.
    40 static bool s_dumpCustomFilterMeshBuffers = false;
    41 #endif
    4238
    43 class MeshGenerator {
    44 public:
    45     // Lines and columns are the values passed in CSS. The result is vertex mesh that has 'rows' numbers of rows
    46     // and 'columns' number of columns with a total of 'rows + 1' * 'columns + 1' vertices.
    47     // MeshBox is the filtered area calculated defined using the border-box, padding-box, content-box or filter-box
    48     // attributes. A value of (0, 0, 1, 1) will cover the entire output surface.
    49     MeshGenerator(unsigned columns, unsigned rows, const FloatRect& meshBox, CustomFilterOperation::MeshType meshType)
    50         : m_meshType(meshType)
    51         , m_points(columns + 1, rows + 1)
    52         , m_tiles(columns, rows)
    53         , m_tileSizeInPixels(meshBox.width() / m_tiles.width(), meshBox.height() / m_tiles.height())
    54         , m_tileSizeInDeviceSpace(1.0f / m_tiles.width(), 1.0f / m_tiles.height())
    55         , m_meshBox(meshBox)
    56     {
    57         // Build the two buffers needed to draw triangles:
    58         // * m_vertices has a number of float attributes that will be passed to the vertex shader
    59         // for each computed vertex. This number is calculated in floatsPerVertex() based on the meshType.
    60         // * m_indices is a buffer that will have 3 indices per triangle. Each index will point inside
    61         // the m_vertices buffer.
    62         m_vertices.reserveCapacity(verticesCount() * floatsPerVertex());
    63         m_indices.reserveCapacity(indicesCount());
    64        
    65         // Based on the meshType there can be two types of meshes.
    66         // * attached: each triangle uses vertices from the neighbor triangles. This is useful to save some GPU memory
    67         // when there's no need to explode the tiles.
    68         // * detached: each triangle has its own vertices. This means each triangle can be moved independently and a vec3
    69         // attribute is passed, so that each vertex can be uniquely identified.
    70         if (m_meshType == CustomFilterOperation::ATTACHED)
    71             generateAttachedMesh();
    72         else
    73             generateDetachedMesh();
    74        
    75 #ifndef NDEBUG
    76         if (s_dumpCustomFilterMeshBuffers)
    77             dumpBuffers();
    78 #endif
    79     }
    80 
    81     const Vector<float>& vertices() const { return m_vertices; }
    82     const Vector<uint16_t>& indices() const { return m_indices; }
    83 
    84     const IntSize& points() const { return m_points; }
    85     unsigned pointsCount() const { return m_points.width() * m_points.height(); }
    86    
    87     const IntSize& tiles() const { return m_tiles; }
    88     unsigned tilesCount() const { return m_tiles.width() * m_tiles.height(); }
    89    
    90     unsigned indicesCount() const
    91     {
    92         const unsigned trianglesPerTile = 2;
    93         const unsigned indicesPerTriangle = 3;
    94         return tilesCount() * trianglesPerTile * indicesPerTriangle;
    95     }
    96    
    97     unsigned floatsPerVertex() const
    98     {
    99         static const unsigned AttachedMeshVertexSize = 4 + // vec4 a_position
    100                                                        2 + // vec2 a_texCoord
    101                                                        2; // vec2 a_meshCoord
    102 
    103         static const unsigned DetachedMeshVertexSize = AttachedMeshVertexSize +
    104                                                        3; // vec3 a_triangleCoord
    105 
    106         return m_meshType == CustomFilterOperation::ATTACHED ? AttachedMeshVertexSize : DetachedMeshVertexSize;
    107     }
    108    
    109     unsigned verticesCount() const
    110     {
    111         return m_meshType == CustomFilterOperation::ATTACHED ? pointsCount() : indicesCount();
    112     }
    113 
    114 private:
    115     typedef void (MeshGenerator::*AddTriangleVertexFunction)(int quadX, int quadY, int triangleX, int triangleY, int triangle);
    116    
    117     template <AddTriangleVertexFunction addTriangleVertex>
    118     void addTile(int quadX, int quadY)
    119     {
    120         ((*this).*(addTriangleVertex))(quadX, quadY, 0, 0, 1);
    121         ((*this).*(addTriangleVertex))(quadX, quadY, 1, 0, 2);
    122         ((*this).*(addTriangleVertex))(quadX, quadY, 1, 1, 3);
    123         ((*this).*(addTriangleVertex))(quadX, quadY, 0, 0, 4);
    124         ((*this).*(addTriangleVertex))(quadX, quadY, 1, 1, 5);
    125         ((*this).*(addTriangleVertex))(quadX, quadY, 0, 1, 6);
    126     }
    127    
    128     void addAttachedMeshIndex(int quadX, int quadY, int triangleX, int triangleY, int triangle)
    129     {
    130         UNUSED_PARAM(triangle);
    131         m_indices.append((quadY + triangleY) * m_points.width() + (quadX + triangleX));
    132     }
    133    
    134     void generateAttachedMesh()
    135     {
    136         for (int j = 0; j < m_points.height(); ++j) {
    137             for (int i = 0; i < m_points.width(); ++i)
    138                 addAttachedMeshVertexAttributes(i, j);
    139         }
    140        
    141         for (int j = 0; j < m_tiles.height(); ++j) {
    142             for (int i = 0; i < m_tiles.width(); ++i)
    143                 addTile<&MeshGenerator::addAttachedMeshIndex>(i, j);
    144         }
    145     }
    146    
    147     void addDetachedMeshVertexAndIndex(int quadX, int quadY, int triangleX, int triangleY, int triangle)
    148     {
    149         addDetachedMeshVertexAttributes(quadX, quadY, triangleX, triangleY, triangle);
    150         m_indices.append(m_indices.size());
    151     }
    152    
    153     void generateDetachedMesh()
    154     {
    155         for (int j = 0; j < m_tiles.height(); ++j) {
    156             for (int i = 0; i < m_tiles.width(); ++i)
    157                 addTile<&MeshGenerator::addDetachedMeshVertexAndIndex>(i, j);
    158         }
    159     }
    160    
    161     void addPositionAttribute(int quadX, int quadY)
    162     {
    163         // vec4 a_position
    164         m_vertices.append(m_tileSizeInPixels.width() * quadX - 0.5f + m_meshBox.x());
    165         m_vertices.append(m_tileSizeInPixels.height() * quadY - 0.5f + m_meshBox.y());
    166         m_vertices.append(0.0f); // z
    167         m_vertices.append(1.0f);
    168     }
    169 
    170     void addTexCoordAttribute(int quadX, int quadY)
    171     {
    172         // vec2 a_texCoord
    173         m_vertices.append(m_tileSizeInPixels.width() * quadX + m_meshBox.x());
    174         m_vertices.append(m_tileSizeInPixels.height() * quadY + m_meshBox.y());
    175     }
    176 
    177     void addMeshCoordAttribute(int quadX, int quadY)
    178     {
    179         // vec2 a_meshCoord
    180         m_vertices.append(m_tileSizeInDeviceSpace.width() * quadX);
    181         m_vertices.append(m_tileSizeInDeviceSpace.height() * quadY);
    182     }
    183 
    184     void addTriangleCoordAttribute(int quadX, int quadY, int triangle)
    185     {
    186         // vec3 a_triangleCoord
    187         m_vertices.append(quadX);
    188         m_vertices.append(quadY);
    189         m_vertices.append(triangle);
    190     }
    191 
    192     void addAttachedMeshVertexAttributes(int quadX, int quadY)
    193     {
    194         addPositionAttribute(quadX, quadY);
    195         addTexCoordAttribute(quadX, quadY);
    196         addMeshCoordAttribute(quadX, quadY);
    197     }
    198 
    199     void addDetachedMeshVertexAttributes(int quadX, int quadY, int triangleX, int triangleY, int triangle)
    200     {
    201         addAttachedMeshVertexAttributes(quadX + triangleX, quadY + triangleY);
    202         addTriangleCoordAttribute(quadX, quadY, triangle);
    203     }
    204    
    205 #ifndef NDEBUG
    206     void dumpBuffers() const
    207     {
    208         printf("Mesh buffers: Points.width(): %d, Points.height(): %d meshBox: %f, %f, %f, %f, type: %s\n",
    209                m_points.width(), m_points.height(), m_meshBox.x(), m_meshBox.y(), m_meshBox.width(), m_meshBox.height(),
    210                (m_meshType == CustomFilterOperation::ATTACHED) ? "Attached" : "Detached");
    211         printf("---Vertex:\n\t");
    212         for (unsigned i = 0; i < m_vertices.size(); ++i) {
    213             printf("%f ", m_vertices.at(i));
    214             if (!((i + 1) % floatsPerVertex()))
    215                 printf("\n\t");
    216         }
    217         printf("\n---Indices: ");
    218         for (unsigned i = 0; i < m_indices.size(); ++i)
    219             printf("%d ", m_indices.at(i));
    220         printf("\n");
    221     }
    222 #endif
    223 
    224 private:
    225     Vector<float> m_vertices;
    226     Vector<uint16_t> m_indices;
    227    
    228     CustomFilterOperation::MeshType m_meshType;
    229     IntSize m_points;
    230     IntSize m_tiles;
    231     FloatSize m_tileSizeInPixels;
    232     FloatSize m_tileSizeInDeviceSpace;
    233     FloatRect m_meshBox;
    234 };
    235 
    236 CustomFilterMesh::CustomFilterMesh(GraphicsContext3D* context, unsigned columns, unsigned rows,
     39CustomFilterMesh::CustomFilterMesh(GraphicsContext3D* context, unsigned columns, unsigned rows,
    23740                                   const FloatRect& meshBox, CustomFilterOperation::MeshType meshType)
    23841    : m_context(context)
     
    24245    , m_meshType(meshType)
    24346{
    244     MeshGenerator generator(columns, rows, meshBox, meshType);
     47    CustomFilterMeshGenerator generator(columns, rows, meshBox, meshType);
    24548    m_indicesCount = generator.indicesCount();
    24649    m_bytesPerVertex = generator.floatsPerVertex() * sizeof(float);   
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp

    r127540 r127911  
    7171    : m_globalContext(globalContext)
    7272    , m_programInfo(programInfo)
     73    , m_platformCompiledProgram(0)
    7374    , m_isInitialized(false)
    7475{
     
    103104PassRefPtr<CustomFilterCompiledProgram> CustomFilterValidatedProgram::compiledProgram()
    104105{
    105     ASSERT(m_isInitialized && !m_validatedVertexShader.isNull() && !m_validatedFragmentShader.isNull());
     106    ASSERT(m_isInitialized && m_globalContext && !m_validatedVertexShader.isNull() && !m_validatedFragmentShader.isNull());
    106107    if (!m_compiledProgram)
    107108        m_compiledProgram = CustomFilterCompiledProgram::create(m_globalContext->context(), m_validatedVertexShader, m_validatedFragmentShader);
     
    264265CustomFilterValidatedProgram::~CustomFilterValidatedProgram()
    265266{
     267    platformDestroy();
     268
    266269    if (m_globalContext)
    267270        m_globalContext->removeValidatedProgram(this);
    268271}
    269272
     273#if !PLATFORM(BLACKBERRY)
     274PlatformCompiledProgram* CustomFilterValidatedProgram::platformCompiledProgram()
     275{
     276    return 0;
     277}
     278
     279void CustomFilterValidatedProgram::platformDestroy()
     280{
     281}
     282#endif
     283
    270284} // namespace WebCore
    271285
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h

    r127217 r127911  
    4040#include <wtf/text/WTFString.h>
    4141
     42// PlatformCompiledProgram defines a type that is compatible with the framework used to implement accelerated compositing on a particular platform.
     43#if PLATFORM(BLACKBERRY)
     44namespace WebCore {
     45class LayerCompiledProgram;
     46}
     47typedef WebCore::LayerCompiledProgram PlatformCompiledProgram;
     48#else
     49typedef void PlatformCompiledProgram;
     50#endif
     51
    4252namespace WebCore {
    4353
     
    7282    PassRefPtr<CustomFilterCompiledProgram> compiledProgram();
    7383
     84    PlatformCompiledProgram* platformCompiledProgram();
     85
    7486    bool isInitialized() const { return m_isInitialized; }
    7587
     
    7991private:
    8092    CustomFilterValidatedProgram(CustomFilterGlobalContext*, const CustomFilterProgramInfo&);
     93
     94    void platformDestroy();
    8195
    8296    static String defaultVertexShaderString();
     
    96110
    97111    RefPtr<CustomFilterCompiledProgram> m_compiledProgram;
     112    PlatformCompiledProgram* m_platformCompiledProgram;
    98113
    99114    bool m_isInitialized;
Note: See TracChangeset for help on using the changeset viewer.