Changeset 95341 in webkit
- Timestamp:
- Sep 16, 2011 5:33:09 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r95336 r95341 1 2011-09-16 Adrienne Walker <enne@google.com> 2 3 [chromium] Move quad drawing code from LayerChromium to LayerRendererChromium 4 https://bugs.webkit.org/show_bug.cgi?id=68272 5 6 Reviewed by James Robinson. 7 8 All the OpenGL code is in LayerRendererChromium and the CCLayerImpl 9 tree, so move the static drawTexturedQuad/toGLMatrix functions to 10 LayerRendererChromium, where they really belong. 11 12 Just moving code around. Tested by existing compositor tests. 13 14 * platform/graphics/chromium/LayerChromium.cpp: 15 * platform/graphics/chromium/LayerChromium.h: 16 * platform/graphics/chromium/LayerRendererChromium.cpp: 17 (WebCore::LayerRendererChromium::toGLMatrix): 18 (WebCore::LayerRendererChromium::drawTexturedQuad): 19 * platform/graphics/chromium/LayerRendererChromium.h: 20 * platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp: 21 (WebCore::CCCanvasLayerImpl::draw): 22 * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: 23 (WebCore::CCHeadsUpDisplay::draw): 24 * platform/graphics/chromium/cc/CCLayerImpl.cpp: 25 (WebCore::CCLayerImpl::drawDebugBorder): 26 * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp: 27 (WebCore::CCPluginLayerImpl::draw): 28 * platform/graphics/chromium/cc/CCRenderSurface.cpp: 29 (WebCore::CCRenderSurface::drawSurface): 30 * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp: 31 (WebCore::CCTiledLayerImpl::drawTiles): 32 * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp: 33 (WebCore::CCVideoLayerImpl::drawYUV): 34 (WebCore::CCVideoLayerImpl::drawRGBA): 35 1 36 2011-09-16 Shawn Singh <shawnsingh@chromium.org> 2 37 -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
r95148 r95341 36 36 37 37 #include "cc/CCLayerImpl.h" 38 #include "cc/CCLayerTreeHost.h" 38 39 #include "GraphicsContext3D.h" 39 #include "LayerRendererChromium.h"40 40 #if USE(SKIA) 41 41 #include "NativeImageSkia.h" … … 295 295 } 296 296 297 void LayerChromium::toGLMatrix(float* flattened, const TransformationMatrix& m)298 {299 flattened[0] = m.m11();300 flattened[1] = m.m12();301 flattened[2] = m.m13();302 flattened[3] = m.m14();303 flattened[4] = m.m21();304 flattened[5] = m.m22();305 flattened[6] = m.m23();306 flattened[7] = m.m24();307 flattened[8] = m.m31();308 flattened[9] = m.m32();309 flattened[10] = m.m33();310 flattened[11] = m.m34();311 flattened[12] = m.m41();312 flattened[13] = m.m42();313 flattened[14] = m.m43();314 flattened[15] = m.m44();315 }316 317 297 void LayerChromium::pushPropertiesTo(CCLayerImpl* layer) 318 298 { … … 342 322 } 343 323 344 void LayerChromium::drawTexturedQuad(GraphicsContext3D* context, const TransformationMatrix& projectionMatrix, const TransformationMatrix& drawMatrix,345 float width, float height, float opacity, const FloatQuad& quad,346 int matrixLocation, int alphaLocation, int quadLocation)347 {348 static float glMatrix[16];349 350 TransformationMatrix renderMatrix = drawMatrix;351 352 // Apply a scaling factor to size the quad from 1x1 to its intended size.353 renderMatrix.scale3d(width, height, 1);354 355 // Apply the projection matrix before sending the transform over to the shader.356 toGLMatrix(&glMatrix[0], projectionMatrix * renderMatrix);357 358 GLC(context, context->uniformMatrix4fv(matrixLocation, false, &glMatrix[0], 1));359 360 if (quadLocation != -1) {361 float point[8];362 point[0] = quad.p1().x();363 point[1] = quad.p1().y();364 point[2] = quad.p2().x();365 point[3] = quad.p2().y();366 point[4] = quad.p3().x();367 point[5] = quad.p3().y();368 point[6] = quad.p4().x();369 point[7] = quad.p4().y();370 GLC(context, context->uniform2fv(quadLocation, point, 4));371 }372 373 if (alphaLocation != -1)374 GLC(context, context->uniform1f(alphaLocation, opacity));375 376 GLC(context, context->drawElements(GraphicsContext3D::TRIANGLES, 6, GraphicsContext3D::UNSIGNED_SHORT, 0));377 }378 379 324 PassRefPtr<CCLayerImpl> LayerChromium::createCCLayerImpl() 380 325 { -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r95336 r95341 184 184 void setBorderWidth(float); 185 185 186 static void drawTexturedQuad(GraphicsContext3D*, const TransformationMatrix& projectionMatrix, const TransformationMatrix& layerMatrix,187 float width, float height, float opacity, const FloatQuad&,188 int matrixLocation, int alphaLocation, int quadLocation);189 190 186 virtual void pushPropertiesTo(CCLayerImpl*); 191 187 … … 225 221 // hold context-dependent resources such as textures. 226 222 virtual void cleanupResources(); 227 228 static void toGLMatrix(float*, const TransformationMatrix&);229 223 230 224 FloatRect m_dirtyRect; -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r95320 r95341 347 347 } 348 348 349 void LayerRendererChromium::toGLMatrix(float* flattened, const TransformationMatrix& m) 350 { 351 flattened[0] = m.m11(); 352 flattened[1] = m.m12(); 353 flattened[2] = m.m13(); 354 flattened[3] = m.m14(); 355 flattened[4] = m.m21(); 356 flattened[5] = m.m22(); 357 flattened[6] = m.m23(); 358 flattened[7] = m.m24(); 359 flattened[8] = m.m31(); 360 flattened[9] = m.m32(); 361 flattened[10] = m.m33(); 362 flattened[11] = m.m34(); 363 flattened[12] = m.m41(); 364 flattened[13] = m.m42(); 365 flattened[14] = m.m43(); 366 flattened[15] = m.m44(); 367 } 368 369 void LayerRendererChromium::drawTexturedQuad(const TransformationMatrix& drawMatrix, 370 float width, float height, float opacity, const FloatQuad& quad, 371 int matrixLocation, int alphaLocation, int quadLocation) 372 { 373 static float glMatrix[16]; 374 375 TransformationMatrix renderMatrix = drawMatrix; 376 377 // Apply a scaling factor to size the quad from 1x1 to its intended size. 378 renderMatrix.scale3d(width, height, 1); 379 380 // Apply the projection matrix before sending the transform over to the shader. 381 toGLMatrix(&glMatrix[0], m_projectionMatrix * renderMatrix); 382 383 GLC(m_context, m_context->uniformMatrix4fv(matrixLocation, false, &glMatrix[0], 1)); 384 385 if (quadLocation != -1) { 386 float point[8]; 387 point[0] = quad.p1().x(); 388 point[1] = quad.p1().y(); 389 point[2] = quad.p2().x(); 390 point[3] = quad.p2().y(); 391 point[4] = quad.p3().x(); 392 point[5] = quad.p3().y(); 393 point[6] = quad.p4().x(); 394 point[7] = quad.p4().y(); 395 GLC(m_context, m_context->uniform2fv(quadLocation, point, 4)); 396 } 397 398 if (alphaLocation != -1) 399 GLC(m_context, m_context->uniform1f(alphaLocation, opacity)); 400 401 GLC(m_context, m_context->drawElements(GraphicsContext3D::TRIANGLES, 6, GraphicsContext3D::UNSIGNED_SHORT, 0)); 402 } 403 349 404 void LayerRendererChromium::finish() 350 405 { -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r95135 r95341 151 151 void setContentsTextureMemoryUseBytes(size_t contentsTextureMemoryUseBytes) { m_contentsTextureMemoryUseBytes = contentsTextureMemoryUseBytes; } 152 152 153 static void toGLMatrix(float*, const TransformationMatrix&); 154 void drawTexturedQuad(const TransformationMatrix& layerMatrix, 155 float width, float height, float opacity, const FloatQuad&, 156 int matrixLocation, int alphaLocation, int quadLocation); 157 153 158 private: 154 159 LayerRendererChromium(CCLayerTreeHostImpl*, PassRefPtr<GraphicsContext3D>); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp
r95135 r95341 67 67 GLC(context, context->useProgram(program->program())); 68 68 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); 69 LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), drawTransform(), 70 bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(), 69 layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(), 71 70 program->vertexShader().matrixLocation(), 72 71 program->fragmentShader().alphaLocation(), -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp
r94703 r95341 152 152 TransformationMatrix matrix; 153 153 matrix.translate3d(hudSize.width() * 0.5, hudSize.height() * 0.5, 0); 154 LayerChromium::drawTexturedQuad(context, m_layerRenderer->projectionMatrix(), 155 matrix, hudSize.width(), hudSize.height(), 156 1.0f, m_layerRenderer->sharedGeometryQuad(), program->vertexShader().matrixLocation(), 157 program->fragmentShader().alphaLocation(), 158 -1); 154 m_layerRenderer->drawTexturedQuad(matrix, hudSize.width(), hudSize.height(), 155 1.0f, m_layerRenderer->sharedGeometryQuad(), program->vertexShader().matrixLocation(), 156 program->fragmentShader().alphaLocation(), 157 -1); 159 158 m_hudTexture->unreserve(); 160 159 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
r95135 r95341 36 36 #include <wtf/text/WTFString.h> 37 37 38 namespace {39 void toGLMatrix(float* flattened, const WebCore::TransformationMatrix& m)40 {41 flattened[0] = m.m11();42 flattened[1] = m.m12();43 flattened[2] = m.m13();44 flattened[3] = m.m14();45 flattened[4] = m.m21();46 flattened[5] = m.m22();47 flattened[6] = m.m23();48 flattened[7] = m.m24();49 flattened[8] = m.m31();50 flattened[9] = m.m32();51 flattened[10] = m.m33();52 flattened[11] = m.m34();53 flattened[12] = m.m41();54 flattened[13] = m.m42();55 flattened[14] = m.m43();56 flattened[15] = m.m44();57 }58 }59 60 61 38 namespace WebCore { 62 39 … … 168 145 TransformationMatrix renderMatrix = drawTransform(); 169 146 renderMatrix.scale3d(bounds().width(), bounds().height(), 1); 170 toGLMatrix(&glMatrix[0], layerRenderer->projectionMatrix() * renderMatrix);147 LayerRendererChromium::toGLMatrix(&glMatrix[0], layerRenderer->projectionMatrix() * renderMatrix); 171 148 GLC(context, context->uniformMatrix4fv(program->vertexShader().matrixLocation(), false, &glMatrix[0], 1)); 172 149 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp
r95135 r95341 65 65 GLC(context, context->useProgram(program->program())); 66 66 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); 67 LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), drawTransform(), 68 bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(), 67 layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(), 69 68 program->vertexShader().matrixLocation(), 70 69 program->fragmentShader().alphaLocation(), -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp
r95135 r95341 203 203 FloatQuad quad = deviceTransform.inverse().mapQuad(layerQuad.floatQuad()); 204 204 205 LayerChromium::drawTexturedQuad(layerRenderer->context(), layerRenderer->projectionMatrix(), drawTransform, 206 m_contentRect.width(), m_contentRect.height(), m_drawOpacity, quad, 205 layerRenderer->drawTexturedQuad(drawTransform, m_contentRect.width(), m_contentRect.height(), m_drawOpacity, quad, 207 206 program->vertexShader().matrixLocation(), program->fragmentShader().alphaLocation(), shaderQuadLocation); 208 207 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp
r95135 r95341 320 320 GLC(context, context->uniform4f(program->vertexShader().vertexTexTransformLocation(), vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); 321 321 322 LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(),globalTransform,322 layerRenderer->drawTexturedQuad(globalTransform, 323 323 tileRect.width(), tileRect.height(), opacity, quad, 324 324 program->vertexShader().matrixLocation(), -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp
r95135 r95341 132 132 GLC(context, context->uniform3fv(program->fragmentShader().yuvAdjLocation(), const_cast<float*>(yuvAdjust), 1)); 133 133 134 LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), drawTransform(), 135 bounds().width(), bounds().height(), drawOpacity(), FloatQuad(), 134 layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), FloatQuad(), 136 135 program->vertexShader().matrixLocation(), 137 136 program->fragmentShader().alphaLocation(), … … 159 158 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); 160 159 161 LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), drawTransform(), 162 bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(), 160 layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(), 163 161 program->vertexShader().matrixLocation(), 164 162 program->fragmentShader().alphaLocation(),
Note: See TracChangeset
for help on using the changeset viewer.