Changeset 76537 in webkit
- Timestamp:
- Jan 24, 2011 11:42:08 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r76531 r76537 1 2011-01-24 Shane Stephens <shanestephens@google.com> 2 3 Reviewed by Chris Marrin. 4 5 TransformationMatrix multiply operations apply operands in wrong order. 6 https://bugs.webkit.org/show_bug.cgi?id=52780 7 8 Rename TranformationMatrix::multLeft into multiply (the method does a multRight, 9 not a multLeft). 10 11 Remove TransformationMatrix::multiply, which was actually doing a multLeft. 12 13 Fix TransformationMatrix::operator* and operator*= such that the operand is 14 applied to the right-hand side of the matrix that the method is called on. 15 i.e., previously "a * b" used to compute "b * a", and "a *= b" used to store 16 "b * a" in "a". This has now been fixed so "a * b" computes "a * b" and 17 "a *= b" stores "a * b" in "a". 18 19 Convert all call sites for these methods to provide operands in the correct order. 20 21 No new tests as patch adds no new functionality. 22 23 * css/WebKitCSSMatrix.cpp: 24 (WebCore::WebKitCSSMatrix::multiply): 25 * platform/graphics/transforms/Matrix3DTransformOperation.h: 26 (WebCore::Matrix3DTransformOperation::apply): 27 * platform/graphics/transforms/MatrixTransformOperation.h: 28 (WebCore::MatrixTransformOperation::apply): 29 * platform/graphics/transforms/TransformationMatrix.cpp: 30 (WebCore::TransformationMatrix::scaleNonUniform): 31 (WebCore::TransformationMatrix::scale3d): 32 (WebCore::TransformationMatrix::rotate3d): 33 (WebCore::TransformationMatrix::skew): 34 (WebCore::TransformationMatrix::applyPerspective): 35 (WebCore::TransformationMatrix::multiply): 36 (WebCore::TransformationMatrix::recompose): 37 * platform/graphics/transforms/TransformationMatrix.h: 38 (WebCore::TransformationMatrix::operator*=): 39 (WebCore::TransformationMatrix::operator*): 40 * rendering/RenderLayer.cpp: 41 (WebCore::transparencyClipBox): 42 * rendering/RenderObject.cpp: 43 (WebCore::RenderObject::getTransformFromContainer): 44 * rendering/TransformState.cpp: 45 (WebCore::TransformState::applyTransform): 46 (WebCore::HitTestingTransformState::applyTransform): 47 1 48 2011-01-24 Andrei Popescu <andreip@google.com> 2 49 -
trunk/Source/WebCore/css/WebKitCSSMatrix.cpp
r76170 r76537 92 92 return 0; 93 93 94 TransformationMatrix tmp(secondMatrix->m_matrix); 95 tmp.multiply(m_matrix); 96 return WebKitCSSMatrix::create(tmp); 94 return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).multiply(secondMatrix->m_matrix)); 97 95 } 98 96 -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
r76475 r76537 435 435 436 436 // Apply the projection matrix before sending the transform over to the shader. 437 renderMatrix.multiply(projectionMatrix); 438 439 toGLMatrix(&glMatrix[0], renderMatrix); 437 toGLMatrix(&glMatrix[0], projectionMatrix * renderMatrix); 440 438 441 439 GLC(context, context->uniformMatrix4fv(matrixLocation, false, &glMatrix[0], 1)); … … 459 457 TransformationMatrix renderMatrix = drawTransform(); 460 458 renderMatrix.scale3d(bounds().width(), bounds().height(), 1); 461 renderMatrix.multiply(layerRenderer()->projectionMatrix()); 462 toGLMatrix(&glMatrix[0], renderMatrix); 459 toGLMatrix(&glMatrix[0], layerRenderer()->projectionMatrix() * renderMatrix); 463 460 GraphicsContext3D* context = layerRendererContext(); 464 461 GLC(context, context->uniformMatrix4fv(sv->borderShaderMatrixLocation(), false, &glMatrix[0], 1)); -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r76475 r76537 388 388 TransformationMatrix renderMatrix = matrix; 389 389 renderMatrix.scale3d(layer->bounds().width(), layer->bounds().height(), 1); 390 renderMatrix .multiply(m_projectionMatrix);390 renderMatrix = m_projectionMatrix * renderMatrix; 391 391 392 392 FloatRect layerRect(-0.5, -0.5, 1, 1); … … 434 434 layerLocalTransform.translate3d(position.x(), position.y(), layer->anchorPointZ()); 435 435 // LT = Tr[l] * M[l] 436 layerLocalTransform.mult Left(layer->transform());436 layerLocalTransform.multiply(layer->transform()); 437 437 // LT = Tr[l] * M[l] * Tr[c] 438 438 layerLocalTransform.translate3d(centerOffsetX, centerOffsetY, -layer->anchorPointZ()); 439 439 440 440 TransformationMatrix combinedTransform = parentMatrix; 441 combinedTransform = combinedTransform.mult Left(layerLocalTransform);441 combinedTransform = combinedTransform.multiply(layerLocalTransform); 442 442 443 443 FloatRect layerRect(-0.5 * layer->bounds().width(), -0.5 * layer->bounds().height(), layer->bounds().width(), layer->bounds().height()); … … 549 549 550 550 // Apply the sublayer transform at the center of the layer. 551 sublayerMatrix.mult Left(layer->sublayerTransform());551 sublayerMatrix.multiply(layer->sublayerTransform()); 552 552 553 553 // The origin of the sublayers is the top left corner of the layer, not the -
trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp
r71538 r76537 391 391 GL_CMD(glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, unitRect)) 392 392 393 TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix).mult Left(modelViewMatrix).multLeft(TransformationMatrix(393 TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix).multiply(modelViewMatrix).multiply(TransformationMatrix( 394 394 targetRect.width(), 0, 0, 0, 395 395 0, targetRect.height(), 0, 0, … … 607 607 608 608 // Create the model-view-projection matrix to display on screen. 609 TransformationMatrix matrix = createProjectionMatrix(surfaceSize, true).mult Left(transform).multLeft(609 TransformationMatrix matrix = createProjectionMatrix(surfaceSize, true).multiply(transform).multiply( 610 610 TransformationMatrix( 611 611 surface.m_actualSize.width(), 0, 0, 0, -
trunk/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp
r75870 r76537 530 530 localTransform 531 531 .translate3d(originX + m_state.pos.x(), originY + m_state.pos.y(), m_state.anchorPoint.z()) 532 .mult Left(m_baseTransform)532 .multiply(m_baseTransform) 533 533 .translate3d(-originX, -originY, -m_state.anchorPoint.z()); 534 534 535 535 // This is the actual 3D transform of this item, with the ancestors' transform baked in. 536 536 m_transformRelativeToRootLayer = TransformationMatrix(parent ? parent->m_transformRelativeToRootLayer : TransformationMatrix()) 537 .mult Left(localTransform);537 .multiply(localTransform); 538 538 539 539 // Now we have enough information to determine if the layer is facing backwards. … … 563 563 m_transformRelativeToRootLayer 564 564 .translate(m_size.width() / 2, m_size.height() /2) 565 .mult Left(m_state.childrenTransform)565 .multiply(m_state.childrenTransform) 566 566 .translate(-m_size.width() / 2, -m_size.height() /2); 567 567 } -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp
r71538 r76537 319 319 TransformationMatrix() 320 320 .translate3d(originX + m_state.pos.x(), originY + m_state.pos.y(), m_state.anchorPoint.z()) 321 .mult Left(m_state.transform)321 .multiply(m_state.transform) 322 322 .translate3d(-originX, -originY, -m_state.anchorPoint.z()); 323 323 m_transforms.localDirty = false; … … 353 353 354 354 if (m_layerType != TransparencyLayer) { 355 m_transforms.replica = TransformationMatrix(m_transforms.target).mult Left(m_state.replicaLayer->m_transforms.local);355 m_transforms.replica = TransformationMatrix(m_transforms.target).multiply(m_state.replicaLayer->m_transforms.local); 356 356 return; 357 357 } … … 362 362 TransformationMatrix() 363 363 .translate(originX, originY) 364 .mult Left(m_state.replicaLayer->m_transforms.local)364 .multiply(m_state.replicaLayer->m_transforms.local) 365 365 .translate(-originX, -originY); 366 366 } … … 378 378 computeLocalTransform(); 379 379 380 m_transforms.target = TransformationMatrix(parent ? parent->m_transforms.forDescendants : TransformationMatrix()).mult Left(m_transforms.local);380 m_transforms.target = TransformationMatrix(parent ? parent->m_transforms.forDescendants : TransformationMatrix()).multiply(m_transforms.local); 381 381 m_transforms.forDescendants = (m_layerType == ClipLayer ? TransformationMatrix() : m_transforms.target); 382 382 … … 409 409 m_transforms.perspective = TransformationMatrix() 410 410 .translate(centerPoint.x(), centerPoint.y()) 411 .mult Left(m_state.childrenTransform)411 .multiply(m_state.childrenTransform) 412 412 .translate(-centerPoint.x(), -centerPoint.y()); 413 413 m_transforms.perspectiveDirty = false; 414 m_transforms.forDescendants.mult Left(m_transforms.perspective);414 m_transforms.forDescendants.multiply(m_transforms.perspective); 415 415 } 416 416 -
trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h
r69884 r76537 56 56 virtual bool apply(TransformationMatrix& transform, const IntSize&) const 57 57 { 58 transform.mult Left(TransformationMatrix(m_matrix));58 transform.multiply(TransformationMatrix(m_matrix)); 59 59 return false; 60 60 } -
trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h
r69884 r76537 63 63 { 64 64 TransformationMatrix matrix(m_a, m_b, m_c, m_d, m_e, m_f); 65 transform.mult Left(TransformationMatrix(matrix));65 transform.multiply(matrix); 66 66 return false; 67 67 } -
trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
r76170 r76537 56 56 // with no guarantee. 57 57 58 // A Note About row-major vs. column major matrixes58 // A clarification about the storage of matrix elements 59 59 // 60 // The clients of this class (CSSMatrix and SVGMatrix) assume a column-major ordering. 61 // That means that when the matrix is initialized with 16 values, the first 4 values 62 // go in the 4 rows of the first column, etc. And in the dereferencing calls, the first 63 // digit is the column (e.g., m23() is column 2 row 3). Because C++ uses row-major arrays 64 // the internal matrix is stored in row-major order, so m[2][0] means row 2, column 0. This 65 // has no bearing on how the matrix is viewed on the outside, since all access is done 66 // with function calls. But it does help make the code more clear if you know that. 60 // This class uses a 2 dimensional array internally to store the elements of the matrix. The first index into 61 // the array refers to the column that the element lies in; the second index refers to the row. 67 62 // 68 // FIXME: Multiply calls are named for what they do in the internal, row-major world. 69 // multLeft is actually a multRight in a column-major world, and multiply is a multLeft 70 // in a column-major world. For now I've left it that way to avoid too many confusing 71 // changes to the code. In particular AffineTransform uses these same terms for the 72 // opposite operations. So we have to be VERY careful when we change them. 63 // In other words, this is the layout of the matrix: 64 // 65 // | m_matrix[0][0] m_matrix[1][0] m_matrix[2][0] m_matrix[3][0] | 66 // | m_matrix[0][1] m_matrix[1][1] m_matrix[2][1] m_matrix[3][1] | 67 // | m_matrix[0][2] m_matrix[1][2] m_matrix[2][2] m_matrix[3][2] | 68 // | m_matrix[0][3] m_matrix[1][3] m_matrix[2][3] m_matrix[3][3] | 73 69 74 70 typedef double Vector4[4]; … … 635 631 mat.m_matrix[1][1] = sy; 636 632 637 mult Left(mat);633 multiply(mat); 638 634 return *this; 639 635 } … … 646 642 mat.m_matrix[2][2] = sz; 647 643 648 mult Left(mat);644 multiply(mat); 649 645 return *this; 650 646 } … … 733 729 mat.m_matrix[3][3] = 1.0f; 734 730 } 735 mult Left(mat);731 multiply(mat); 736 732 return *this; 737 733 } … … 784 780 mat.m_matrix[3][3] = 1.0f; 785 781 786 rmat.mult Left(mat);782 rmat.multiply(mat); 787 783 788 784 rx /= 2.0f; … … 804 800 mat.m_matrix[3][3] = 1.0f; 805 801 806 rmat.mult Left(mat);807 808 mult Left(rmat);802 rmat.multiply(mat); 803 804 multiply(rmat); 809 805 return *this; 810 806 } … … 870 866 mat.m_matrix[1][0] = tan(sx); // and the x shear in the second row 871 867 872 mult Left(mat);868 multiply(mat); 873 869 return *this; 874 870 } … … 880 876 mat.m_matrix[2][3] = -1/p; 881 877 882 mult Left(mat);878 multiply(mat); 883 879 return *this; 884 880 } … … 897 893 // *this = mat * *this 898 894 // 899 TransformationMatrix& TransformationMatrix::mult Left(const TransformationMatrix& mat)895 TransformationMatrix& TransformationMatrix::multiply(const TransformationMatrix& mat) 900 896 { 901 897 Matrix4 tmp; … … 1106 1102 0, 0, 0, 1); 1107 1103 1108 mult Left(rotationMatrix);1104 multiply(rotationMatrix); 1109 1105 1110 1106 // now apply skew … … 1112 1108 TransformationMatrix tmp; 1113 1109 tmp.setM32((float) decomp.skewYZ); 1114 mult Left(tmp);1110 multiply(tmp); 1115 1111 } 1116 1112 … … 1118 1114 TransformationMatrix tmp; 1119 1115 tmp.setM31((float) decomp.skewXZ); 1120 mult Left(tmp);1116 multiply(tmp); 1121 1117 } 1122 1118 … … 1124 1120 TransformationMatrix tmp; 1125 1121 tmp.setM21((float) decomp.skewXY); 1126 mult Left(tmp);1122 multiply(tmp); 1127 1123 } 1128 1124 -
trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
r76248 r76537 209 209 210 210 // this = this * mat 211 TransformationMatrix& multiply(const TransformationMatrix& t) { return *this *= t; } 212 213 // this = mat * this 214 TransformationMatrix& multLeft(const TransformationMatrix& mat); 215 211 TransformationMatrix& multiply(const TransformationMatrix&); 212 216 213 TransformationMatrix& scale(double); 217 214 TransformationMatrix& scaleNonUniform(double sx, double sy); … … 297 294 298 295 bool operator!=(const TransformationMatrix& other) const { return !(*this == other); } 299 300 // *this = *this * t (i.e., a multRight)296 297 // *this = *this * t 301 298 TransformationMatrix& operator*=(const TransformationMatrix& t) 302 299 { 303 *this = *this * t; 304 return *this; 305 } 306 307 // result = *this * t (i.e., a multRight) 300 return multiply(t); 301 } 302 303 // result = *this * t 308 304 TransformationMatrix operator*(const TransformationMatrix& t) const 309 305 { 310 TransformationMatrix result = t;311 result.mult Left(*this);306 TransformationMatrix result = *this; 307 result.multiply(t); 312 308 return result; 313 309 } -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r76378 r76537 946 946 TransformationMatrix transform; 947 947 transform.translate(x, y); 948 transform = *l->transform() * transform;948 transform = transform * *l->transform(); 949 949 950 950 IntRect clipRect = l->boundingBox(l); -
trunk/Source/WebCore/rendering/RenderObject.cpp
r76083 r76537 1987 1987 RenderLayer* layer; 1988 1988 if (hasLayer() && (layer = toRenderBoxModelObject(this)->layer()) && layer->transform()) 1989 transform.mult Left(layer->currentTransform());1989 transform.multiply(layer->currentTransform()); 1990 1990 1991 1991 #if ENABLE(3D_RENDERING) … … 1999 1999 2000 2000 transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(), 0); 2001 transform .multiply(perspectiveMatrix);2001 transform = perspectiveMatrix * transform; 2002 2002 transform.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(), 0); 2003 2003 } -
trunk/Source/WebCore/rendering/TransformState.cpp
r54503 r76537 61 61 if (m_accumulatedTransform) { 62 62 if (m_direction == ApplyTransformDirection) 63 m_accumulatedTransform.set(new TransformationMatrix(transformFromContainer * *m_accumulatedTransform)); 64 else 63 65 m_accumulatedTransform->multiply(transformFromContainer); 64 else65 m_accumulatedTransform->multLeft(transformFromContainer);66 66 } else if (accumulate == AccumulateTransform) { 67 67 // Make one if we started to accumulate … … 141 141 void HitTestingTransformState::applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation accumulate) 142 142 { 143 m_accumulatedTransform.mult Left(transformFromContainer);143 m_accumulatedTransform.multiply(transformFromContainer); 144 144 if (accumulate == FlattenTransform) 145 145 flattenWithTransform(m_accumulatedTransform);
Note: See TracChangeset
for help on using the changeset viewer.