Changeset 116795 in webkit
- Timestamp:
- May 11, 2012 12:45:39 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r116793 r116795 1 2012-05-11 Alexandru Chiculita <achicu@adobe.com> 2 3 [CSS Shaders] Make CSS Shaders render to texture framebuffers 4 https://bugs.webkit.org/show_bug.cgi?id=85113 5 6 Reviewed by Dean Jackson. 7 8 Added a test to check that colors are not switched and the resulting image is not mirrored. 9 10 * css3/filters/custom/effect-color-check-expected.png: Added. 11 * css3/filters/custom/effect-color-check-expected.txt: Added. 12 * css3/filters/custom/effect-color-check.html: Added. 13 * css3/filters/resources/color-fill.fs: Added. 14 * platform/chromium-linux/css3/filters/custom/custom-filter-shader-cache-expected.png: 15 * platform/chromium-linux/css3/filters/custom/effect-custom-combined-missing-expected.png: 16 * platform/chromium-linux/css3/filters/custom/effect-custom-expected.png: 17 * platform/chromium-mac/css3/filters/custom/effect-color-check-expected.png: Added. 18 * platform/chromium/test_expectations.txt: 19 1 20 2012-05-11 Thiago Marcos P. Santos <thiago.santos@intel.com> 2 21 -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r116784 r116795 2790 2790 BUGWK84800 SKIP WIN LINUX : css3/filters/custom/filter-repaint-custom-rotated.html = FAIL 2791 2791 BUGWK84800 SKIP WIN LINUX : css3/filters/custom/filter-repaint-custom.html = FAIL 2792 BUGWK84800 SKIP WIN LINUX : css3/filters/custom/effect-color-check.html = FAIL 2792 2793 2793 2794 // <style scoped> not yet enabled. -
trunk/Source/WebCore/ChangeLog
r116794 r116795 1 2012-05-11 Alexandru Chiculita <achicu@adobe.com> 2 3 [CSS Shaders] Make CSS Shaders render to texture framebuffers 4 https://bugs.webkit.org/show_bug.cgi?id=85113 5 6 Reviewed by Dean Jackson. 7 8 Added the required members to store the framebuffer, the texture and the depth buffer. Also removed the m_drawingBuffer 9 because context->readPixels doesn't require one anymore. 10 11 ReadPixels is not flipping the result, so I've also removed the flipping projection matrix that was specific only to Chromium. 12 13 Added a test to check that colors are not switched and the resulting image is not mirrored. 14 15 Test: css3/filters/custom/effect-color-check.html 16 17 * platform/graphics/filters/FECustomFilter.cpp: 18 (WebCore::FECustomFilter::FECustomFilter): 19 (WebCore::FECustomFilter::~FECustomFilter): 20 (WebCore): 21 (WebCore::FECustomFilter::deleteRenderBuffers): 22 (WebCore::FECustomFilter::platformApplySoftware): 23 (WebCore::FECustomFilter::initializeContext): 24 (WebCore::FECustomFilter::resizeContext): 25 (WebCore::FECustomFilter::bindProgramAndBuffers): 26 * platform/graphics/filters/FECustomFilter.h: 27 (FECustomFilter): 28 1 29 2012-05-11 Anders Carlsson <andersca@apple.com> 2 30 -
trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
r114992 r116795 78 78 : FilterEffect(filter) 79 79 , m_hostWindow(hostWindow) 80 , m_frameBuffer(0) 81 , m_depthBuffer(0) 82 , m_destTexture(0) 80 83 , m_program(program) 81 84 , m_parameters(parameters) … … 94 97 } 95 98 99 FECustomFilter::~FECustomFilter() 100 { 101 deleteRenderBuffers(); 102 } 103 104 void FECustomFilter::deleteRenderBuffers() 105 { 106 if (m_frameBuffer) { 107 m_context->deleteFramebuffer(m_frameBuffer); 108 m_frameBuffer = 0; 109 } 110 if (m_depthBuffer) { 111 m_context->deleteRenderbuffer(m_depthBuffer); 112 m_depthBuffer = 0; 113 } 114 if (m_destTexture) { 115 m_context->deleteTexture(m_destTexture); 116 m_destTexture = 0; 117 } 118 } 119 96 120 void FECustomFilter::platformApplySoftware() 97 121 { … … 107 131 bool hadContext = m_context; 108 132 if (!m_context) 109 initializeContext( newContextSize);133 initializeContext(); 110 134 111 135 if (!hadContext || m_contextSize != newContextSize) 112 136 resizeContext(newContextSize); 113 137 114 138 // Do not draw the filter if the input image cannot fit inside a single GPU texture. 115 139 if (m_inputTexture->tiles().numTilesX() != 1 || m_inputTexture->tiles().numTilesY() != 1) … … 119 143 if (!m_shader->isInitialized()) 120 144 return; 145 146 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_frameBuffer); 147 m_context->viewport(0, 0, newContextSize.width(), newContextSize.height()); 121 148 122 149 m_context->clearColor(0, 0, 0, 0); … … 127 154 m_context->drawElements(GraphicsContext3D::TRIANGLES, m_mesh->indicesCount(), GraphicsContext3D::UNSIGNED_SHORT, 0); 128 155 129 m_drawingBuffer->commit(); 130 131 RefPtr<ImageData> imageData = m_context->paintRenderingResultsToImageData(m_drawingBuffer.get()); 132 Uint8ClampedArray* gpuResult = imageData->data(); 133 ASSERT(gpuResult->length() == dstPixelArray->length()); 134 memcpy(dstPixelArray->data(), gpuResult->data(), gpuResult->length()); 135 } 136 137 void FECustomFilter::initializeContext(const IntSize& contextSize) 156 ASSERT(static_cast<size_t>(newContextSize.width() * newContextSize.height() * 4) == dstPixelArray->length()); 157 m_context->readPixels(0, 0, newContextSize.width(), newContextSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, dstPixelArray->data()); 158 } 159 160 void FECustomFilter::initializeContext() 138 161 { 139 162 GraphicsContext3D::Attributes attributes; … … 143 166 ASSERT(!m_context.get()); 144 167 m_context = GraphicsContext3D::create(attributes, m_hostWindow, GraphicsContext3D::RenderOffscreen); 145 m_ drawingBuffer = DrawingBuffer::create(m_context.get(), contextSize, DrawingBuffer::Discard, DrawingBuffer::Alpha);168 m_context->enable(GraphicsContext3D::DEPTH_TEST); 146 169 147 170 m_shader = m_program->createShaderWithContext(m_context.get()); … … 153 176 void FECustomFilter::resizeContext(const IntSize& newContextSize) 154 177 { 155 m_inputTexture = 0;156 m_drawingBuffer->reset(newContextSize);157 m_context->reshape(newContextSize.width(), newContextSize.height());158 m_context->viewport(0, 0, newContextSize.width(), newContextSize.height());159 178 m_inputTexture = Texture::create(m_context.get(), Texture::RGBA8, newContextSize.width(), newContextSize.height()); 179 180 if (!m_frameBuffer) 181 m_frameBuffer = m_context->createFramebuffer(); 182 if (!m_depthBuffer) 183 m_depthBuffer = m_context->createRenderbuffer(); 184 if (!m_destTexture) { 185 m_destTexture = m_context->createTexture(); 186 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_destTexture); 187 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); 188 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); 189 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); 190 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); 191 } 192 193 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_destTexture); 194 m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, newContextSize.width(), newContextSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE); 195 196 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_frameBuffer); 197 m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_destTexture, 0); 198 199 m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthBuffer); 200 m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT16, newContextSize.width(), newContextSize.height()); 201 m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer); 202 160 203 m_contextSize = newContextSize; 161 204 } … … 223 266 if (m_shader->projectionMatrixLocation() != -1) { 224 267 TransformationMatrix projectionMatrix; 225 #if PLATFORM(CHROMIUM)226 // We flip-y the projection matrix here because Chromium will flip-y the resulting image for us.227 orthogonalProjectionMatrix(projectionMatrix, -0.5, 0.5, 0.5, -0.5);228 #else229 268 orthogonalProjectionMatrix(projectionMatrix, -0.5, 0.5, -0.5, 0.5); 230 #endif231 269 float glProjectionMatrix[16]; 232 270 projectionMatrix.toColumnMajorFloatArray(glProjectionMatrix); -
trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.h
r114992 r116795 36 36 #include "Filter.h" 37 37 #include "FilterEffect.h" 38 #include "GraphicsTypes3D.h" 38 39 #include <wtf/RefPtr.h> 39 40 … … 70 71 unsigned meshRows, unsigned meshColumns, CustomFilterOperation::MeshBoxType, 71 72 CustomFilterOperation::MeshType); 73 ~FECustomFilter(); 72 74 73 void initializeContext(const IntSize& contextSize); 75 void initializeContext(); 76 void deleteRenderBuffers(); 74 77 void resizeContext(const IntSize& newContextSize); 75 78 void bindVertexAttribute(int attributeLocation, unsigned size, unsigned& offset); … … 81 84 82 85 RefPtr<GraphicsContext3D> m_context; 83 RefPtr<DrawingBuffer> m_drawingBuffer;84 86 RefPtr<Texture> m_inputTexture; 85 87 RefPtr<CustomFilterShader> m_shader; 86 88 RefPtr<CustomFilterMesh> m_mesh; 87 89 IntSize m_contextSize; 90 91 Platform3DObject m_frameBuffer; 92 Platform3DObject m_depthBuffer; 93 Platform3DObject m_destTexture; 88 94 89 95 RefPtr<CustomFilterProgram> m_program;
Note: See TracChangeset
for help on using the changeset viewer.