summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/animation_curve.h3
-rw-r--r--cc/damage_tracker.cc8
-rw-r--r--cc/damage_tracker_unittest.cc26
-rw-r--r--cc/delegated_renderer_layer_impl_unittest.cc49
-rw-r--r--cc/direct_renderer.cc38
-rw-r--r--cc/direct_renderer.h6
-rw-r--r--cc/draw_quad.h2
-rw-r--r--cc/draw_quad_unittest.cc11
-rw-r--r--cc/float_quad_unittest.cc48
-rw-r--r--cc/gl_renderer.cc58
-rw-r--r--cc/gl_renderer.h10
-rw-r--r--cc/gl_renderer_unittest.cc6
-rw-r--r--cc/heads_up_display_layer.cc6
-rw-r--r--cc/layer.cc11
-rw-r--r--cc/layer.h41
-rw-r--r--cc/layer_animation_controller.cc6
-rw-r--r--cc/layer_animation_controller.h8
-rw-r--r--cc/layer_animation_controller_unittest.cc7
-rw-r--r--cc/layer_impl.cc24
-rw-r--r--cc/layer_impl.h36
-rw-r--r--cc/layer_impl_unittest.cc4
-rw-r--r--cc/layer_iterator_unittest.cc3
-rw-r--r--cc/layer_sorter.cc7
-rw-r--r--cc/layer_sorter.h6
-rw-r--r--cc/layer_sorter_unittest.cc96
-rw-r--r--cc/layer_tree_host.cc8
-rw-r--r--cc/layer_tree_host.h4
-rw-r--r--cc/layer_tree_host_common.cc167
-rw-r--r--cc/layer_tree_host_common.h4
-rw-r--r--cc/layer_tree_host_common_unittest.cc1002
-rw-r--r--cc/layer_tree_host_impl.cc22
-rw-r--r--cc/layer_tree_host_impl.h4
-rw-r--r--cc/layer_tree_host_impl_unittest.cc163
-rw-r--r--cc/layer_tree_host_unittest.cc56
-rw-r--r--cc/layer_unittest.cc12
-rw-r--r--cc/math_util.cc114
-rw-r--r--cc/math_util.h34
-rw-r--r--cc/math_util_unittest.cc262
-rw-r--r--cc/nine_patch_layer_impl_unittest.cc6
-rw-r--r--cc/occlusion_tracker.cc25
-rw-r--r--cc/occlusion_tracker.h4
-rw-r--r--cc/occlusion_tracker_unittest.cc209
-rw-r--r--cc/overdraw_metrics.cc12
-rw-r--r--cc/overdraw_metrics.h11
-rw-r--r--cc/quad_culler.cc2
-rw-r--r--cc/quad_culler_unittest.cc86
-rw-r--r--cc/render_pass.cc6
-rw-r--r--cc/render_pass.h13
-rw-r--r--cc/render_pass_unittest.cc13
-rw-r--r--cc/render_surface.cc4
-rw-r--r--cc/render_surface.h31
-rw-r--r--cc/render_surface_impl.cc14
-rw-r--r--cc/render_surface_impl.h26
-rw-r--r--cc/render_surface_unittest.cc20
-rw-r--r--cc/shared_quad_state.cc2
-rw-r--r--cc/shared_quad_state.h8
-rw-r--r--cc/software_renderer.cc35
-rw-r--r--cc/software_renderer_unittest.cc8
-rw-r--r--cc/solid_color_layer_impl.cc2
-rw-r--r--cc/solid_color_layer_impl.h1
-rw-r--r--cc/stream_video_draw_quad.cc4
-rw-r--r--cc/stream_video_draw_quad.h8
-rw-r--r--cc/test/animation_test_common.cc4
-rw-r--r--cc/test/animation_test_common.h6
-rw-r--r--cc/test/geometry_test_utils.cc29
-rw-r--r--cc/test/geometry_test_utils.h7
-rw-r--r--cc/test/render_pass_test_common.cc7
-rw-r--r--cc/thread_proxy.h2
-rw-r--r--cc/tiled_layer.cc3
-rw-r--r--cc/tiled_layer_impl.cc1
-rw-r--r--cc/tiled_layer_impl.h1
-rw-r--r--cc/tiled_layer_unittest.cc16
-rw-r--r--cc/video_layer_impl.cc9
-rw-r--r--cc/video_layer_impl.h7
-rw-r--r--content/common/cc_messages.cc128
-rw-r--r--content/common/cc_messages.h9
-rw-r--r--content/common/cc_messages_unittest.cc10
-rw-r--r--ui/compositor/layer.cc2
-rw-r--r--webkit/compositor_bindings/web_layer_impl.cc52
79 files changed, 1581 insertions, 1634 deletions
diff --git a/cc/animation_curve.h b/cc/animation_curve.h
index e2932e9..0629dea 100644
--- a/cc/animation_curve.h
+++ b/cc/animation_curve.h
@@ -5,9 +5,10 @@
#ifndef CC_ANIMATION_CURVE_H_
#define CC_ANIMATION_CURVE_H_
+#include <public/WebTransformationMatrix.h>
+
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
-#include <public/WebTransformationMatrix.h>
namespace cc {
diff --git a/cc/damage_tracker.cc b/cc/damage_tracker.cc
index e10461d..0a9e9c2 100644
--- a/cc/damage_tracker.cc
+++ b/cc/damage_tracker.cc
@@ -10,8 +10,6 @@
#include "cc/render_surface_impl.h"
#include <public/WebFilterOperations.h>
-using WebKit::WebTransformationMatrix;
-
namespace cc {
scoped_ptr<DamageTracker> DamageTracker::create()
@@ -306,12 +304,12 @@ void DamageTracker::extendDamageForRenderSurface(LayerImpl* layer, gfx::RectF& t
// If there was damage, transform it to target space, and possibly contribute its reflection if needed.
if (!damageRectInLocalSpace.IsEmpty()) {
- const WebTransformationMatrix& drawTransform = renderSurface->drawTransform();
+ const gfx::Transform& drawTransform = renderSurface->drawTransform();
gfx::RectF damageRectInTargetSpace = MathUtil::mapClippedRect(drawTransform, damageRectInLocalSpace);
targetDamageRect.Union(damageRectInTargetSpace);
if (layer->replicaLayer()) {
- const WebTransformationMatrix& replicaDrawTransform = renderSurface->replicaDrawTransform();
+ const gfx::Transform& replicaDrawTransform = renderSurface->replicaDrawTransform();
targetDamageRect.Union(MathUtil::mapClippedRect(replicaDrawTransform, damageRectInLocalSpace));
}
}
@@ -323,7 +321,7 @@ void DamageTracker::extendDamageForRenderSurface(LayerImpl* layer, gfx::RectF& t
bool replicaIsNew = false;
removeRectFromCurrentFrame(replicaMaskLayer->id(), replicaIsNew);
- const WebTransformationMatrix& replicaDrawTransform = renderSurface->replicaDrawTransform();
+ const gfx::Transform& replicaDrawTransform = renderSurface->replicaDrawTransform();
gfx::RectF replicaMaskLayerRect = MathUtil::mapClippedRect(replicaDrawTransform, gfx::RectF(gfx::PointF(), replicaMaskLayer->bounds()));
saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect);
diff --git a/cc/damage_tracker_unittest.cc b/cc/damage_tracker_unittest.cc
index 008dc93..42eaaaf 100644
--- a/cc/damage_tracker_unittest.cc
+++ b/cc/damage_tracker_unittest.cc
@@ -285,8 +285,8 @@ TEST_F(DamageTrackerTest, verifyDamageForTransformedLayer)
scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
LayerImpl* child = root->children()[0];
- WebTransformationMatrix rotation;
- rotation.rotate(45);
+ gfx::Transform rotation;
+ rotation.Rotate(45);
clearDamageForAllSurfaces(root.get());
child->setAnchorPoint(gfx::PointF(0.5, 0.5));
@@ -328,11 +328,11 @@ TEST_F(DamageTrackerTest, verifyDamageForPerspectiveClippedLayer)
scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
LayerImpl* child = root->children()[0];
- WebTransformationMatrix transform;
- transform.translate3d(500, 500, 0);
- transform.applyPerspective(1);
- transform.rotate3d(0, 45, 0);
- transform.translate3d(-50, -50, 0);
+ gfx::Transform transform;
+ transform.Translate3d(500, 500, 0);
+ transform.ApplyPerspectiveDepth(1);
+ MathUtil::rotateEulerAngles(&transform, 0, 45, 0);
+ transform.Translate3d(-50, -50, 0);
// Set up the child
child->setPosition(gfx::PointF(0, 0));
@@ -833,8 +833,8 @@ TEST_F(DamageTrackerTest, verifyDamageForReplica)
scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(7);
grandChild1Replica->setPosition(gfx::PointF());
grandChild1Replica->setAnchorPoint(gfx::PointF());
- WebTransformationMatrix reflection;
- reflection.scale3d(-1, 1, 1);
+ gfx::Transform reflection;
+ reflection.Scale3d(-1, 1, 1);
grandChild1Replica->setTransform(reflection);
grandChild1->setReplicaLayer(grandChild1Replica.Pass());
}
@@ -986,8 +986,8 @@ TEST_F(DamageTrackerTest, verifyDamageForReplicaMask)
scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6);
grandChild1Replica->setPosition(gfx::PointF());
grandChild1Replica->setAnchorPoint(gfx::PointF());
- WebTransformationMatrix reflection;
- reflection.scale3d(-1, 1, 1);
+ gfx::Transform reflection;
+ reflection.Scale3d(-1, 1, 1);
grandChild1Replica->setTransform(reflection);
grandChild1->setReplicaLayer(grandChild1Replica.Pass());
}
@@ -1048,8 +1048,8 @@ TEST_F(DamageTrackerTest, verifyDamageForReplicaMaskWithAnchor)
scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6);
grandChild1Replica->setPosition(gfx::PointF());
grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the anchor being tested.
- WebTransformationMatrix reflection;
- reflection.scale3d(-1, 1, 1);
+ gfx::Transform reflection;
+ reflection.Scale3d(-1, 1, 1);
grandChild1Replica->setTransform(reflection);
grandChild1->setReplicaLayer(grandChild1Replica.Pass());
}
diff --git a/cc/delegated_renderer_layer_impl_unittest.cc b/cc/delegated_renderer_layer_impl_unittest.cc
index 46a7488..eb8a5dd 100644
--- a/cc/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/delegated_renderer_layer_impl_unittest.cc
@@ -19,11 +19,10 @@
#include "cc/test/mock_quad_culler.h"
#include "cc/test/render_pass_test_common.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using WebKit::FakeWebCompositorOutputSurface;
using WebKit::FakeWebGraphicsContext3D;
-using WebKit::WebTransformationMatrix;
using namespace WebKitTests;
@@ -66,7 +65,7 @@ protected:
scoped_ptr<LayerTreeHostImpl> m_hostImpl;
};
-static TestRenderPass* addRenderPass(ScopedPtrVector<RenderPass>& passList, RenderPass::Id id, gfx::Rect outputRect, WebTransformationMatrix rootTransform)
+static TestRenderPass* addRenderPass(ScopedPtrVector<RenderPass>& passList, RenderPass::Id id, gfx::Rect outputRect, gfx::Transform rootTransform)
{
scoped_ptr<TestRenderPass> pass(TestRenderPass::Create());
pass->SetNew(id, outputRect, outputRect, rootTransform);
@@ -80,7 +79,7 @@ static SolidColorDrawQuad* addQuad(TestRenderPass* pass, gfx::Rect rect, SkColor
MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_list);
AppendQuadsData data(pass->id);
SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQuadState::Create());
- sharedState->SetAll(WebTransformationMatrix(), rect, rect, rect, false, 1);
+ sharedState->SetAll(gfx::Transform(), rect, rect, rect, false, 1);
scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
quad->SetNew(sharedState, rect, color);
SolidColorDrawQuad* quadPtr = quad.get();
@@ -94,7 +93,7 @@ static void addRenderPassQuad(TestRenderPass* toPass, TestRenderPass* contributi
AppendQuadsData data(toPass->id);
gfx::Rect outputRect = contributingPass->output_rect;
SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQuadState::Create());
- sharedState->SetAll(WebTransformationMatrix(), outputRect, outputRect, outputRect, false, 1);
+ sharedState->SetAll(gfx::Transform(), outputRect, outputRect, outputRect, false, 1);
scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create();
quad->SetNew(sharedState, outputRect, contributingPass->id, false, 0, outputRect, 0, 0, 0, 0);
quadSink.append(quad.PassAs<DrawQuad>(), data);
@@ -129,17 +128,17 @@ public:
delegatedRendererLayer->setBounds(gfx::Size(10, 10));
delegatedRendererLayer->setContentBounds(gfx::Size(10, 10));
delegatedRendererLayer->setDrawsContent(true);
- WebTransformationMatrix transform;
- transform.translate(1, 1);
+ gfx::Transform transform;
+ transform.Translate(1, 1);
delegatedRendererLayer->setTransform(transform);
ScopedPtrVector<RenderPass> delegatedRenderPasses;
- TestRenderPass* pass1 = addRenderPass(delegatedRenderPasses, RenderPass::Id(9, 6), gfx::Rect(6, 6, 6, 6), WebTransformationMatrix());
+ TestRenderPass* pass1 = addRenderPass(delegatedRenderPasses, RenderPass::Id(9, 6), gfx::Rect(6, 6, 6, 6), gfx::Transform());
addQuad(pass1, gfx::Rect(0, 0, 6, 6), 33u);
- TestRenderPass* pass2 = addRenderPass(delegatedRenderPasses, RenderPass::Id(9, 7), gfx::Rect(7, 7, 7, 7), WebTransformationMatrix());
+ TestRenderPass* pass2 = addRenderPass(delegatedRenderPasses, RenderPass::Id(9, 7), gfx::Rect(7, 7, 7, 7), gfx::Transform());
addQuad(pass2, gfx::Rect(0, 0, 7, 7), 22u);
addRenderPassQuad(pass2, pass1);
- TestRenderPass* pass3 = addRenderPass(delegatedRenderPasses, RenderPass::Id(9, 8), gfx::Rect(8, 8, 8, 8), WebTransformationMatrix());
+ TestRenderPass* pass3 = addRenderPass(delegatedRenderPasses, RenderPass::Id(9, 8), gfx::Rect(8, 8, 8, 8), gfx::Transform());
addRenderPassQuad(pass3, pass2);
delegatedRendererLayer->setRenderPasses(delegatedRenderPasses);
@@ -260,16 +259,16 @@ TEST_F(DelegatedRendererLayerImplTestSimple, QuadsFromRootRenderPassAreModifiedF
// The DelegatedRendererLayer is at position 3,3 compared to its target, and has a translation transform of 1,1.
// So its root RenderPass' quads should all be transformed by that combined amount.
- WebTransformationMatrix transform;
- transform.translate(4, 4);
+ gfx::Transform transform;
+ transform.Translate(4, 4);
EXPECT_TRANSFORMATION_MATRIX_EQ(transform, frame.renderPasses[3]->quad_list[0]->quadTransform());
// Quads from non-root RenderPasses should not be shifted though.
ASSERT_EQ(2u, frame.renderPasses[2]->quad_list.size());
- EXPECT_TRANSFORMATION_MATRIX_EQ(WebTransformationMatrix(), frame.renderPasses[2]->quad_list[0]->quadTransform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(WebTransformationMatrix(), frame.renderPasses[2]->quad_list[1]->quadTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), frame.renderPasses[2]->quad_list[0]->quadTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), frame.renderPasses[2]->quad_list[1]->quadTransform());
ASSERT_EQ(1u, frame.renderPasses[1]->quad_list.size());
- EXPECT_TRANSFORMATION_MATRIX_EQ(WebTransformationMatrix(), frame.renderPasses[1]->quad_list[0]->quadTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), frame.renderPasses[1]->quad_list[0]->quadTransform());
}
class DelegatedRendererLayerImplTestOwnSurface : public DelegatedRendererLayerImplTestSimple {
@@ -373,14 +372,14 @@ TEST_F(DelegatedRendererLayerImplTestOwnSurface, QuadsFromRootRenderPassAreNotMo
// Because the DelegatedRendererLayer owns a RenderSurfaceImpl, its root RenderPass' quads do not need to be
// modified at all.
- EXPECT_TRANSFORMATION_MATRIX_EQ(WebTransformationMatrix(), frame.renderPasses[3]->quad_list[0]->quadTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), frame.renderPasses[3]->quad_list[0]->quadTransform());
// Quads from non-root RenderPasses should not be shifted though.
ASSERT_EQ(2u, frame.renderPasses[2]->quad_list.size());
- EXPECT_TRANSFORMATION_MATRIX_EQ(WebTransformationMatrix(), frame.renderPasses[2]->quad_list[0]->quadTransform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(WebTransformationMatrix(), frame.renderPasses[2]->quad_list[1]->quadTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), frame.renderPasses[2]->quad_list[0]->quadTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), frame.renderPasses[2]->quad_list[1]->quadTransform());
ASSERT_EQ(1u, frame.renderPasses[1]->quad_list.size());
- EXPECT_TRANSFORMATION_MATRIX_EQ(WebTransformationMatrix(), frame.renderPasses[1]->quad_list[0]->quadTransform());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), frame.renderPasses[1]->quad_list[0]->quadTransform());
}
class DelegatedRendererLayerImplTestSharedData : public DelegatedRendererLayerImplTest {
@@ -398,17 +397,17 @@ public:
delegatedRendererLayer->setBounds(gfx::Size(20, 20));
delegatedRendererLayer->setContentBounds(gfx::Size(20, 20));
delegatedRendererLayer->setDrawsContent(true);
- WebTransformationMatrix transform;
- transform.translate(10, 10);
+ gfx::Transform transform;
+ transform.Translate(10, 10);
delegatedRendererLayer->setTransform(transform);
ScopedPtrVector<RenderPass> delegatedRenderPasses;
gfx::Rect passRect(0, 0, 50, 50);
- TestRenderPass* pass = addRenderPass(delegatedRenderPasses, RenderPass::Id(9, 6), passRect, WebTransformationMatrix());
+ TestRenderPass* pass = addRenderPass(delegatedRenderPasses, RenderPass::Id(9, 6), passRect, gfx::Transform());
MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_list);
AppendQuadsData data(pass->id);
SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQuadState::Create());
- sharedState->SetAll(WebTransformationMatrix(), passRect, passRect, passRect, false, 1);
+ sharedState->SetAll(gfx::Transform(), passRect, passRect, passRect, false, 1);
scoped_ptr<SolidColorDrawQuad> colorQuad;
colorQuad = SolidColorDrawQuad::Create();
@@ -467,8 +466,8 @@ TEST_F(DelegatedRendererLayerImplTestSharedData, SharedData)
// The state should be transformed only once.
EXPECT_RECT_EQ(gfx::Rect(30, 30, 50, 50), sharedState->clipped_rect_in_target);
- WebTransformationMatrix expected;
- expected.translate(30, 30);
+ gfx::Transform expected;
+ expected.Translate(30, 30);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected, sharedState->content_to_target_transform);
}
diff --git a/cc/direct_renderer.cc b/cc/direct_renderer.cc
index c24ca01..9f13114 100644
--- a/cc/direct_renderer.cc
+++ b/cc/direct_renderer.cc
@@ -9,42 +9,40 @@
#include "base/debug/trace_event.h"
#include "cc/math_util.h"
#include "ui/gfx/rect_conversions.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
-using WebKit::WebTransformationMatrix;
-
-static WebTransformationMatrix orthoProjectionMatrix(float left, float right, float bottom, float top)
+static gfx::Transform orthoProjectionMatrix(float left, float right, float bottom, float top)
{
// Use the standard formula to map the clipping frustum to the cube from
// [-1, -1, -1] to [1, 1, 1].
float deltaX = right - left;
float deltaY = top - bottom;
- WebTransformationMatrix proj;
+ gfx::Transform proj;
if (!deltaX || !deltaY)
return proj;
- proj.setM11(2.0f / deltaX);
- proj.setM41(-(right + left) / deltaX);
- proj.setM22(2.0f / deltaY);
- proj.setM42(-(top + bottom) / deltaY);
+ proj.matrix().setDouble(0, 0, 2.0f / deltaX);
+ proj.matrix().setDouble(0, 3, -(right + left) / deltaX);
+ proj.matrix().setDouble(1, 1, 2.0f / deltaY);
+ proj.matrix().setDouble(1, 3, -(top + bottom) / deltaY);
// Z component of vertices is always set to zero as we don't use the depth buffer
// while drawing.
- proj.setM33(0);
+ proj.matrix().setDouble(2, 2, 0);
return proj;
}
-static WebTransformationMatrix windowMatrix(int x, int y, int width, int height)
+static gfx::Transform windowMatrix(int x, int y, int width, int height)
{
- WebTransformationMatrix canvas;
+ gfx::Transform canvas;
// Map to window position and scale up to pixel coordinates.
- canvas.translate3d(x, y, 0);
- canvas.scale3d(width, height, 0);
+ canvas.Translate3d(x, y, 0);
+ canvas.Scale3d(width, height, 0);
// Map from ([-1, -1] to [1, 1]) -> ([0, 0] to [1, 1])
- canvas.translate3d(0.5, 0.5, 0.5);
- canvas.scale3d(0.5, 0.5, 0.5);
+ canvas.Translate3d(0.5, 0.5, 0.5);
+ canvas.Scale3d(0.5, 0.5, 0.5);
return canvas;
}
@@ -71,11 +69,11 @@ gfx::RectF DirectRenderer::quadVertexRect()
}
// static
-void DirectRenderer::quadRectTransform(WebKit::WebTransformationMatrix* quadRectTransform, const WebKit::WebTransformationMatrix& quadTransform, const gfx::RectF& quadRect)
+void DirectRenderer::quadRectTransform(gfx::Transform* quadRectTransform, const gfx::Transform& quadTransform, const gfx::RectF& quadRect)
{
*quadRectTransform = quadTransform;
- quadRectTransform->translate(0.5 * quadRect.width() + quadRect.x(), 0.5 * quadRect.height() + quadRect.y());
- quadRectTransform->scaleNonUniform(quadRect.width(), quadRect.height());
+ quadRectTransform->Translate(0.5 * quadRect.width() + quadRect.x(), 0.5 * quadRect.height() + quadRect.y());
+ quadRectTransform->Scale(quadRect.width(), quadRect.height());
}
// static
@@ -176,7 +174,7 @@ gfx::RectF DirectRenderer::computeScissorRectForRenderPass(const DrawingFrame& f
if (frame.rootDamageRect == frame.rootRenderPass->output_rect)
return renderPassScissor;
- WebTransformationMatrix inverseTransform = frame.currentRenderPass->transform_to_root_target.inverse();
+ gfx::Transform inverseTransform = MathUtil::inverse(frame.currentRenderPass->transform_to_root_target);
gfx::RectF damageRectInRenderPassSpace = MathUtil::projectClippedRect(inverseTransform, frame.rootDamageRect);
renderPassScissor.Intersect(damageRectInRenderPassSpace);
diff --git a/cc/direct_renderer.h b/cc/direct_renderer.h
index 27c42a6..c22c1a1 100644
--- a/cc/direct_renderer.h
+++ b/cc/direct_renderer.h
@@ -39,8 +39,8 @@ public:
gfx::RectF rootDamageRect;
- WebKit::WebTransformationMatrix projectionMatrix;
- WebKit::WebTransformationMatrix windowMatrix;
+ gfx::Transform projectionMatrix;
+ gfx::Transform windowMatrix;
bool flippedY;
};
@@ -71,7 +71,7 @@ protected:
};
static gfx::RectF quadVertexRect();
- static void quadRectTransform(WebKit::WebTransformationMatrix* quadRectTransform, const WebKit::WebTransformationMatrix& quadTransform, const gfx::RectF& quadRect);
+ static void quadRectTransform(gfx::Transform* quadRectTransform, const gfx::Transform& quadTransform, const gfx::RectF& quadRect);
static void initializeMatrices(DrawingFrame&, const gfx::Rect& drawRect, bool flipY);
static gfx::Rect moveScissorToWindowSpace(const DrawingFrame&, gfx::RectF scissorRect);
static gfx::RectF computeScissorRectForRenderPass(const DrawingFrame& frame);
diff --git a/cc/draw_quad.h b/cc/draw_quad.h
index 492630c..c1982c1 100644
--- a/cc/draw_quad.h
+++ b/cc/draw_quad.h
@@ -35,7 +35,7 @@ class CC_EXPORT DrawQuad {
const SharedQuadState* copied_shared_quad_state) const;
// TODO(danakj): Chromify or remove these SharedQuadState helpers.
- const WebKit::WebTransformationMatrix& quadTransform() const { return shared_quad_state->content_to_target_transform; }
+ const gfx::Transform& quadTransform() const { return shared_quad_state->content_to_target_transform; }
gfx::Rect visibleContentRect() const { return shared_quad_state->visible_content_rect; }
gfx::Rect clippedRectInTarget() const { return shared_quad_state->clipped_rect_in_target; }
gfx::Rect clipRect() const { return shared_quad_state->clip_rect; }
diff --git a/cc/draw_quad_unittest.cc b/cc/draw_quad_unittest.cc
index f541070..ecd978d 100644
--- a/cc/draw_quad_unittest.cc
+++ b/cc/draw_quad_unittest.cc
@@ -7,6 +7,7 @@
#include "cc/checkerboard_draw_quad.h"
#include "cc/debug_border_draw_quad.h"
#include "cc/io_surface_draw_quad.h"
+#include "cc/math_util.h"
#include "cc/render_pass_draw_quad.h"
#include "cc/solid_color_draw_quad.h"
#include "cc/stream_video_draw_quad.h"
@@ -15,16 +16,14 @@
#include "cc/tile_draw_quad.h"
#include "cc/yuv_video_draw_quad.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
namespace {
TEST(DrawQuadTest, copySharedQuadState)
{
- WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0);
+ gfx::Transform quadTransform = MathUtil::createGfxTransform(1, 0.5, 0, 1, 0.5, 0);
gfx::Rect visibleContentRect(10, 12, 14, 16);
gfx::Rect clippedRectInTarget(19, 21, 23, 25);
gfx::Rect clipRect = clippedRectInTarget;
@@ -45,7 +44,7 @@ TEST(DrawQuadTest, copySharedQuadState)
scoped_ptr<SharedQuadState> createSharedQuadState()
{
- WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0);
+ gfx::Transform quadTransform = MathUtil::createGfxTransform(1, 0.5, 0, 1, 0.5, 0);
gfx::Rect visibleContentRect(10, 12, 14, 16);
gfx::Rect clippedRectInTarget(19, 21, 23, 25);
gfx::Rect clipRect = clippedRectInTarget;
@@ -325,7 +324,7 @@ TEST(DrawQuadTest, copyStreamVideoDrawQuad)
{
gfx::Rect opaqueRect(3, 7, 10, 12);
unsigned textureId = 64;
- WebTransformationMatrix matrix(0.5, 1, 0.25, 0.75, 0, 1);
+ gfx::Transform matrix = MathUtil::createGfxTransform(0.5, 1, 0.25, 0.75, 0, 1);
CREATE_SHARED_STATE();
CREATE_QUAD_3_NEW(StreamVideoDrawQuad, opaqueRect, textureId, matrix);
diff --git a/cc/float_quad_unittest.cc b/cc/float_quad_unittest.cc
index 93ebc60..a13c582 100644
--- a/cc/float_quad_unittest.cc
+++ b/cc/float_quad_unittest.cc
@@ -6,27 +6,25 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/rect_f.h"
#include "ui/gfx/quad_f.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
namespace {
-// TODO(danakj) Move this test to ui/gfx/ when we don't use WebTransformationMatrix.
+// TODO(danakj) Move this test to ui/gfx/ when we don't need MathUtil::mapQuad.
TEST(FloatQuadTest, IsRectilinearTest)
{
const int numRectilinear = 8;
- WebTransformationMatrix rectilinearTrans[numRectilinear];
- rectilinearTrans[1].rotate(90);
- rectilinearTrans[2].rotate(180);
- rectilinearTrans[3].rotate(270);
- rectilinearTrans[4].skewX(0.00000000001);
- rectilinearTrans[5].skewY(0.00000000001);
- rectilinearTrans[6].scale(0.00001);
- rectilinearTrans[6].rotate(180);
- rectilinearTrans[7].scale(100000);
- rectilinearTrans[7].rotate(180);
+ gfx::Transform rectilinearTrans[numRectilinear];
+ rectilinearTrans[1].Rotate(90);
+ rectilinearTrans[2].Rotate(180);
+ rectilinearTrans[3].Rotate(270);
+ rectilinearTrans[4].SkewX(0.00000000001);
+ rectilinearTrans[5].SkewY(0.00000000001);
+ rectilinearTrans[6].Scale(0.00001, 0.00001);
+ rectilinearTrans[6].Rotate(180);
+ rectilinearTrans[7].Scale(100000, 100000);
+ rectilinearTrans[7].Rotate(180);
for (int i = 0; i < numRectilinear; ++i) {
bool clipped = false;
@@ -36,17 +34,17 @@ TEST(FloatQuadTest, IsRectilinearTest)
}
const int numNonRectilinear = 10;
- WebTransformationMatrix nonRectilinearTrans[numNonRectilinear];
- nonRectilinearTrans[0].rotate(359.999);
- nonRectilinearTrans[1].rotate(0.0000001);
- nonRectilinearTrans[2].rotate(89.999999);
- nonRectilinearTrans[3].rotate(90.0000001);
- nonRectilinearTrans[4].rotate(179.999999);
- nonRectilinearTrans[5].rotate(180.0000001);
- nonRectilinearTrans[6].rotate(269.999999);
- nonRectilinearTrans[7].rotate(270.0000001);
- nonRectilinearTrans[8].skewX(0.00001);
- nonRectilinearTrans[9].skewY(0.00001);
+ gfx::Transform nonRectilinearTrans[numNonRectilinear];
+ nonRectilinearTrans[0].Rotate(359.999);
+ nonRectilinearTrans[1].Rotate(0.0000001);
+ nonRectilinearTrans[2].Rotate(89.999999);
+ nonRectilinearTrans[3].Rotate(90.0000001);
+ nonRectilinearTrans[4].Rotate(179.999999);
+ nonRectilinearTrans[5].Rotate(180.0000001);
+ nonRectilinearTrans[6].Rotate(269.999999);
+ nonRectilinearTrans[7].Rotate(270.0000001);
+ nonRectilinearTrans[8].SkewX(0.00001);
+ nonRectilinearTrans[9].SkewY(0.00001);
for (int i = 0; i < numNonRectilinear; ++i) {
bool clipped = false;
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc
index e8454cc..94f8d83 100644
--- a/cc/gl_renderer.cc
+++ b/cc/gl_renderer.cc
@@ -43,7 +43,6 @@ using namespace std;
using WebKit::WebGraphicsContext3D;
using WebKit::WebGraphicsMemoryAllocation;
using WebKit::WebSharedGraphicsContext3D;
-using WebKit::WebTransformationMatrix;
namespace cc {
@@ -329,9 +328,9 @@ void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde
// Use the full quadRect for debug quads to not move the edges based on partial swaps.
const gfx::Rect& layerRect = quad->rect;
- WebTransformationMatrix renderMatrix = quad->quadTransform();
- renderMatrix.translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerRect.height() + layerRect.y());
- renderMatrix.scaleNonUniform(layerRect.width(), layerRect.height());
+ gfx::Transform renderMatrix = quad->quadTransform();
+ renderMatrix.Translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerRect.height() + layerRect.y());
+ renderMatrix.Scale(layerRect.width(), layerRect.height());
GLRenderer::toGLMatrix(&glMatrix[0], frame.projectionMatrix * renderMatrix);
GLC(context(), context()->uniformMatrix4fv(program->vertexShader().matrixLocation(), 1, false, &glMatrix[0]));
@@ -435,8 +434,8 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
DrawingFrame& frame, const RenderPassDrawQuad* quad,
const WebKit::WebFilterOperations& filters,
- const WebTransformationMatrix& contentsDeviceTransform,
- const WebTransformationMatrix& contentsDeviceTransformInverse)
+ const gfx::Transform& contentsDeviceTransform,
+ const gfx::Transform& contentsDeviceTransformInverse)
{
// This method draws a background filter, which applies a filter to any pixels behind the quad and seen through its background.
// The algorithm works as follows:
@@ -492,10 +491,10 @@ scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
if (usingBackgroundTexture) {
// Copy the readback pixels from device to the background texture for the surface.
- WebTransformationMatrix deviceToFramebufferTransform;
- deviceToFramebufferTransform.translate(quad->rect.width() / 2.0, quad->rect.height() / 2.0);
- deviceToFramebufferTransform.scale3d(quad->rect.width(), quad->rect.height(), 1);
- deviceToFramebufferTransform.multiply(contentsDeviceTransformInverse);
+ gfx::Transform deviceToFramebufferTransform;
+ deviceToFramebufferTransform.Translate(quad->rect.width() / 2.0, quad->rect.height() / 2.0);
+ deviceToFramebufferTransform.Scale3d(quad->rect.width(), quad->rect.height(), 1);
+ deviceToFramebufferTransform.PreconcatTransform(contentsDeviceTransformInverse);
copyTextureToFramebuffer(frame, filteredDeviceBackgroundTextureId, deviceRect, deviceToFramebufferTransform);
}
@@ -517,15 +516,15 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
if (!renderPass)
return;
- WebTransformationMatrix quadRectMatrix;
+ gfx::Transform quadRectMatrix;
quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect);
- WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * frame.projectionMatrix * quadRectMatrix).to2dTransform();
+ gfx::Transform contentsDeviceTransform = MathUtil::to2dTransform(frame.windowMatrix * frame.projectionMatrix * quadRectMatrix);
// Can only draw surface if device matrix is invertible.
- if (!contentsDeviceTransform.isInvertible())
+ if (!contentsDeviceTransform.IsInvertible())
return;
- WebTransformationMatrix contentsDeviceTransformInverse = contentsDeviceTransform.inverse();
+ gfx::Transform contentsDeviceTransformInverse = MathUtil::inverse(contentsDeviceTransform);
scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters(
frame, quad, renderPass->background_filters,
contentsDeviceTransform, contentsDeviceTransformInverse);
@@ -749,8 +748,8 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua
gfx::QuadF localQuad;
- WebTransformationMatrix deviceTransform = WebTransformationMatrix(frame.windowMatrix * frame.projectionMatrix * quad->quadTransform()).to2dTransform();
- if (!deviceTransform.isInvertible())
+ gfx::Transform deviceTransform = MathUtil::to2dTransform(frame.windowMatrix * frame.projectionMatrix * quad->quadTransform());
+ if (!deviceTransform.IsInvertible())
return;
bool clipped = false;
@@ -840,7 +839,7 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua
LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge);
// Map device space quad to local space. deviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to project.
- WebTransformationMatrix deviceTransformInverse = deviceTransform.inverse();
+ gfx::Transform deviceTransformInverse = MathUtil::inverse(deviceTransform);
localQuad = MathUtil::mapQuad(deviceTransformInverse, deviceQuad.ToQuadF(), clipped);
// We should not DCHECK(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become
@@ -1063,24 +1062,9 @@ void GLRenderer::ensureScissorTestDisabled()
m_isScissorEnabled = false;
}
-void GLRenderer::toGLMatrix(float* flattened, const WebTransformationMatrix& m)
+void GLRenderer::toGLMatrix(float* glMatrix, const gfx::Transform& transform)
{
- flattened[0] = m.m11();
- flattened[1] = m.m12();
- flattened[2] = m.m13();
- flattened[3] = m.m14();
- flattened[4] = m.m21();
- flattened[5] = m.m22();
- flattened[6] = m.m23();
- flattened[7] = m.m24();
- flattened[8] = m.m31();
- flattened[9] = m.m32();
- flattened[10] = m.m33();
- flattened[11] = m.m34();
- flattened[12] = m.m41();
- flattened[13] = m.m42();
- flattened[14] = m.m43();
- flattened[15] = m.m44();
+ transform.matrix().asColMajorf(glMatrix);
}
void GLRenderer::setShaderQuadF(const gfx::QuadF& quad, int quadLocation)
@@ -1106,9 +1090,9 @@ void GLRenderer::setShaderOpacity(float opacity, int alphaLocation)
GLC(m_context, m_context->uniform1f(alphaLocation, opacity));
}
-void GLRenderer::drawQuadGeometry(const DrawingFrame& frame, const WebKit::WebTransformationMatrix& drawTransform, const gfx::RectF& quadRect, int matrixLocation)
+void GLRenderer::drawQuadGeometry(const DrawingFrame& frame, const gfx::Transform& drawTransform, const gfx::RectF& quadRect, int matrixLocation)
{
- WebTransformationMatrix quadRectMatrix;
+ gfx::Transform quadRectMatrix;
quadRectTransform(&quadRectMatrix, drawTransform, quadRect);
static float glMatrix[16];
toGLMatrix(&glMatrix[0], frame.projectionMatrix * quadRectMatrix);
@@ -1117,7 +1101,7 @@ void GLRenderer::drawQuadGeometry(const DrawingFrame& frame, const WebKit::WebTr
GLC(m_context, m_context->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
}
-void GLRenderer::copyTextureToFramebuffer(const DrawingFrame& frame, int textureId, const gfx::Rect& rect, const WebTransformationMatrix& drawMatrix)
+void GLRenderer::copyTextureToFramebuffer(const DrawingFrame& frame, int textureId, const gfx::Rect& rect, const gfx::Transform& drawMatrix)
{
const RenderPassProgram* program = renderPassProgram();
diff --git a/cc/gl_renderer.h b/cc/gl_renderer.h
index 7116413..f8381ec 100644
--- a/cc/gl_renderer.h
+++ b/cc/gl_renderer.h
@@ -87,15 +87,15 @@ protected:
virtual void ensureScissorTestDisabled() OVERRIDE;
private:
- static void toGLMatrix(float*, const WebKit::WebTransformationMatrix&);
+ static void toGLMatrix(float*, const gfx::Transform&);
static int priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::PriorityCutoff);
void drawCheckerboardQuad(const DrawingFrame&, const CheckerboardDrawQuad*);
void drawDebugBorderQuad(const DrawingFrame&, const DebugBorderDrawQuad*);
scoped_ptr<ScopedResource> drawBackgroundFilters(
DrawingFrame&, const RenderPassDrawQuad*, const WebKit::WebFilterOperations&,
- const WebKit::WebTransformationMatrix& contentsDeviceTransform,
- const WebKit::WebTransformationMatrix& contentsDeviceTransformInverse);
+ const gfx::Transform& contentsDeviceTransform,
+ const gfx::Transform& contentsDeviceTransformInverse);
void drawRenderPassQuad(DrawingFrame&, const RenderPassDrawQuad*);
void drawSolidColorQuad(const DrawingFrame&, const SolidColorDrawQuad*);
void drawStreamVideoQuad(const DrawingFrame&, const StreamVideoDrawQuad*);
@@ -106,9 +106,9 @@ private:
void setShaderOpacity(float opacity, int alphaLocation);
void setShaderQuadF(const gfx::QuadF&, int quadLocation);
- void drawQuadGeometry(const DrawingFrame&, const WebKit::WebTransformationMatrix& drawTransform, const gfx::RectF& quadRect, int matrixLocation);
+ void drawQuadGeometry(const DrawingFrame&, const gfx::Transform& drawTransform, const gfx::RectF& quadRect, int matrixLocation);
- void copyTextureToFramebuffer(const DrawingFrame&, int textureId, const gfx::Rect&, const WebKit::WebTransformationMatrix& drawMatrix);
+ void copyTextureToFramebuffer(const DrawingFrame&, int textureId, const gfx::Rect&, const gfx::Transform& drawMatrix);
bool useScopedTexture(DrawingFrame&, const ScopedResource*, const gfx::Rect& viewportRect);
diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc
index f948743..4189db7 100644
--- a/cc/gl_renderer_unittest.cc
+++ b/cc/gl_renderer_unittest.cc
@@ -13,7 +13,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using namespace WebKit;
using namespace WebKitTests;
@@ -60,7 +60,7 @@ public:
m_rootLayer->createRenderSurface();
RenderPass::Id renderPassId = m_rootLayer->renderSurface()->renderPassId();
scoped_ptr<RenderPass> rootRenderPass = RenderPass::Create();
- rootRenderPass->SetNew(renderPassId, gfx::Rect(), gfx::Rect(), WebTransformationMatrix());
+ rootRenderPass->SetNew(renderPassId, gfx::Rect(), gfx::Rect(), gfx::Transform());
m_renderPassesInDrawOrder.push_back(rootRenderPass.get());
m_renderPasses.set(renderPassId, rootRenderPass.Pass());
}
@@ -531,7 +531,7 @@ TEST(GLRendererTest2, activeTextureState)
cc::RenderPass::Id id(1, 1);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
- pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), WebTransformationMatrix());
+ pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), gfx::Transform());
pass->AppendOneOfEveryQuadType(resourceProvider.get());
context->setInDraw();
diff --git a/cc/heads_up_display_layer.cc b/cc/heads_up_display_layer.cc
index ef11dee..374e650 100644
--- a/cc/heads_up_display_layer.cc
+++ b/cc/heads_up_display_layer.cc
@@ -32,8 +32,8 @@ void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*,
int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize;
gfx::Size bounds;
- WebKit::WebTransformationMatrix matrix;
- matrix.makeIdentity();
+ gfx::Transform matrix;
+ matrix.MakeIdentity();
if (settings.showPlatformLayerTree || settings.showDebugRects()) {
int width = std::min(maxTextureSize, layerTreeHost()->deviceViewportSize().width());
@@ -41,7 +41,7 @@ void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*,
bounds = gfx::Size(width, height);
} else {
bounds = gfx::Size(256, 128);
- matrix.translate(layerTreeHost()->deviceViewportSize().width() - 256, 0);
+ matrix.Translate(layerTreeHost()->deviceViewportSize().width() - 256, 0);
}
setBounds(bounds);
diff --git a/cc/layer.cc b/cc/layer.cc
index 63f5e94..c7b7ebc 100644
--- a/cc/layer.cc
+++ b/cc/layer.cc
@@ -16,7 +16,6 @@
#include <public/WebSize.h>
using namespace std;
-using WebKit::WebTransformationMatrix;
namespace cc {
@@ -384,7 +383,7 @@ void Layer::setPosition(const gfx::PointF& position)
setNeedsCommit();
}
-void Layer::setSublayerTransform(const WebTransformationMatrix& sublayerTransform)
+void Layer::setSublayerTransform(const gfx::Transform& sublayerTransform)
{
if (m_sublayerTransform == sublayerTransform)
return;
@@ -392,7 +391,7 @@ void Layer::setSublayerTransform(const WebTransformationMatrix& sublayerTransfor
setNeedsCommit();
}
-void Layer::setTransform(const WebTransformationMatrix& transform)
+void Layer::setTransform(const gfx::Transform& transform)
{
if (m_transform == transform)
return;
@@ -480,7 +479,7 @@ void Layer::setForceRenderSurface(bool force)
setNeedsCommit();
}
-void Layer::setImplTransform(const WebTransformationMatrix& transform)
+void Layer::setImplTransform(const gfx::Transform& transform)
{
if (m_implTransform == transform)
return;
@@ -726,12 +725,12 @@ void Layer::setOpacityFromAnimation(float opacity)
m_opacity = opacity;
}
-const WebKit::WebTransformationMatrix& Layer::transform() const
+const gfx::Transform& Layer::transform() const
{
return m_transform;
}
-void Layer::setTransformFromAnimation(const WebTransformationMatrix& transform)
+void Layer::setTransformFromAnimation(const gfx::Transform& transform)
{
// This is called due to an ongoing accelerated animation. Since this animation is
// also being run on the impl thread, there is no need to request a commit to push
diff --git a/cc/layer.h b/cc/layer.h
index ef75286..67f3932 100644
--- a/cc/layer.h
+++ b/cc/layer.h
@@ -5,6 +5,10 @@
#ifndef CC_LAYER_H_
#define CC_LAYER_H_
+#include <public/WebFilterOperations.h>
+#include <string>
+#include <vector>
+
#include "base/memory/ref_counted.h"
#include "cc/cc_export.h"
#include "cc/layer_animation_controller.h"
@@ -14,10 +18,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h"
-#include <public/WebFilterOperations.h>
-#include <public/WebTransformationMatrix.h>
-#include <string>
-#include <vector>
+#include "ui/gfx/transform.h"
namespace WebKit {
class WebAnimationDelegate;
@@ -51,11 +52,11 @@ public:
virtual int id() const OVERRIDE;
virtual void setOpacityFromAnimation(float) OVERRIDE;
virtual float opacity() const OVERRIDE;
- virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix&) OVERRIDE;
+ virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE;
// A layer's transform operates layer space. That is, entirely in logical,
// non-page-scaled pixels (that is, they have page zoom baked in, but not page scale).
// The root layer is a special case -- it operates in physical pixels.
- virtual const WebKit::WebTransformationMatrix& transform() const OVERRIDE;
+ virtual const gfx::Transform& transform() const OVERRIDE;
Layer* rootLayer();
Layer* parent() { return m_parent; }
@@ -121,10 +122,10 @@ public:
void setFixedToContainerLayer(bool);
bool fixedToContainerLayer() const { return m_fixedToContainerLayer; }
- void setSublayerTransform(const WebKit::WebTransformationMatrix&);
- const WebKit::WebTransformationMatrix& sublayerTransform() const { return m_sublayerTransform; }
+ void setSublayerTransform(const gfx::Transform&);
+ const gfx::Transform& sublayerTransform() const { return m_sublayerTransform; }
- void setTransform(const WebKit::WebTransformationMatrix&);
+ void setTransform(const gfx::Transform&);
bool transformIsAnimating() const;
const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; }
@@ -163,8 +164,8 @@ public:
gfx::Vector2d scrollDelta() const { return gfx::Vector2d(); }
- void setImplTransform(const WebKit::WebTransformationMatrix&);
- const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; }
+ void setImplTransform(const gfx::Transform&);
+ const gfx::Transform& implTransform() const { return m_implTransform; }
void setDoubleSided(bool);
bool doubleSided() const { return m_doubleSided; }
@@ -225,12 +226,12 @@ public:
// This moves from layer space, with origin in the center to target space with origin in the top left.
// That is, it converts from logical, non-page-scaled, to target pixels (and if the target is the
// root render surface, then this converts to physical pixels).
- const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; }
- void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_drawTransform = matrix; }
+ const gfx::Transform& drawTransform() const { return m_drawTransform; }
+ void setDrawTransform(const gfx::Transform& matrix) { m_drawTransform = matrix; }
// This moves from content space, with origin the top left to screen space with origin in the top left.
// It converts logical, non-page-scaled pixels to physical pixels.
- const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; }
- void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix) { m_screenSpaceTransform = matrix; }
+ const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
+ void setScreenSpaceTransform(const gfx::Transform& matrix) { m_screenSpaceTransform = matrix; }
bool isClipped() const { return m_isClipped; }
void setIsClipped(bool isClipped) { m_isClipped = isClipped; }
@@ -386,8 +387,8 @@ private:
bool m_drawCheckerboardForMissingTiles;
bool m_forceRenderSurface;
- WebKit::WebTransformationMatrix m_transform;
- WebKit::WebTransformationMatrix m_sublayerTransform;
+ gfx::Transform m_transform;
+ gfx::Transform m_sublayerTransform;
// Replica layer used for reflections.
scoped_refptr<Layer> m_replicaLayer;
@@ -399,8 +400,8 @@ private:
Layer* m_renderTarget;
- WebKit::WebTransformationMatrix m_drawTransform;
- WebKit::WebTransformationMatrix m_screenSpaceTransform;
+ gfx::Transform m_drawTransform;
+ gfx::Transform m_screenSpaceTransform;
bool m_drawTransformIsAnimating;
bool m_screenSpaceTransformIsAnimating;
@@ -415,7 +416,7 @@ private:
bool m_automaticallyComputeRasterScale;
bool m_boundsContainPageScale;
- WebKit::WebTransformationMatrix m_implTransform;
+ gfx::Transform m_implTransform;
WebKit::WebAnimationDelegate* m_layerAnimationDelegate;
WebKit::WebLayerScrollClient* m_layerScrollClient;
diff --git a/cc/layer_animation_controller.cc b/cc/layer_animation_controller.cc
index 2dbdde8..805f8fc 100644
--- a/cc/layer_animation_controller.cc
+++ b/cc/layer_animation_controller.cc
@@ -6,9 +6,7 @@
#include "cc/active_animation.h"
#include "cc/keyframed_animation_curve.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
@@ -373,7 +371,7 @@ void LayerAnimationController::tickAnimations(double monotonicTime)
case ActiveAnimation::Transform: {
const TransformAnimationCurve* transformAnimationCurve = m_activeAnimations[i]->curve()->toTransformAnimationCurve();
- const WebTransformationMatrix matrix = transformAnimationCurve->getValue(trimmed);
+ const gfx::Transform matrix = transformAnimationCurve->getValue(trimmed).toTransform();
if (m_activeAnimations[i]->isFinishedAt(monotonicTime))
m_activeAnimations[i]->setRunState(ActiveAnimation::Finished, monotonicTime);
diff --git a/cc/layer_animation_controller.h b/cc/layer_animation_controller.h
index 3bf878c..be55afe 100644
--- a/cc/layer_animation_controller.h
+++ b/cc/layer_animation_controller.h
@@ -12,8 +12,8 @@
#include "cc/cc_export.h"
#include "cc/scoped_ptr_vector.h"
-namespace WebKit {
-class WebTransformationMatrix;
+namespace gfx {
+class Transform;
}
namespace cc {
@@ -28,8 +28,8 @@ public:
virtual int id() const = 0;
virtual void setOpacityFromAnimation(float) = 0;
virtual float opacity() const = 0;
- virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix&) = 0;
- virtual const WebKit::WebTransformationMatrix& transform() const = 0;
+ virtual void setTransformFromAnimation(const gfx::Transform&) = 0;
+ virtual const gfx::Transform& transform() const = 0;
};
class CC_EXPORT LayerAnimationController {
diff --git a/cc/layer_animation_controller_unittest.cc b/cc/layer_animation_controller_unittest.cc
index b0d6058..29b6e6e 100644
--- a/cc/layer_animation_controller_unittest.cc
+++ b/cc/layer_animation_controller_unittest.cc
@@ -9,17 +9,16 @@
#include "cc/test/animation_test_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using namespace WebKitTests;
-using WebKit::WebTransformationMatrix;
namespace cc {
namespace {
-void expectTranslateX(double translateX, const WebTransformationMatrix& matrix)
+void expectTranslateX(double translateX, const gfx::Transform& matrix)
{
- EXPECT_FLOAT_EQ(translateX, matrix.m41());
+ EXPECT_FLOAT_EQ(translateX, matrix.matrix().getDouble(0, 3));
}
scoped_ptr<ActiveAnimation> createActiveAnimation(scoped_ptr<AnimationCurve> curve, int id, ActiveAnimation::TargetProperty property)
diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc
index 937b812..81bc49f 100644
--- a/cc/layer_impl.cc
+++ b/cc/layer_impl.cc
@@ -18,8 +18,6 @@
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect_conversions.h"
-using WebKit::WebTransformationMatrix;
-
namespace cc {
LayerImpl::LayerImpl(int id)
@@ -236,14 +234,14 @@ InputHandlerClient::ScrollStatus LayerImpl::tryScroll(const gfx::PointF& screenS
return InputHandlerClient::ScrollOnMainThread;
}
- if (!screenSpaceTransform().isInvertible()) {
+ if (!screenSpaceTransform().IsInvertible()) {
TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform");
return InputHandlerClient::ScrollIgnored;
}
if (!nonFastScrollableRegion().IsEmpty()) {
bool clipped = false;
- gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(screenSpaceTransform().inverse(), screenSpacePoint, clipped);
+ gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(MathUtil::inverse(screenSpaceTransform()), screenSpacePoint, clipped);
gfx::PointF hitTestPointInLayerSpace = gfx::ScalePoint(hitTestPointInContentSpace, 1 / contentsScaleX(), 1 / contentsScaleY());
if (!clipped && nonFastScrollableRegion().Contains(gfx::ToRoundedPoint(hitTestPointInLayerSpace))) {
TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRegion");
@@ -308,10 +306,10 @@ void LayerImpl::dumpLayerProperties(std::string* str, int indent) const
str->append(indentStr);
base::StringAppendF(str, "drawTransform: %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f\n",
- m_drawTransform.m11(), m_drawTransform.m12(), m_drawTransform.m13(), m_drawTransform.m14(),
- m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_drawTransform.m24(),
- m_drawTransform.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_drawTransform.m34(),
- m_drawTransform.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_drawTransform.m44());
+ m_drawTransform.matrix().getDouble(0, 0), m_drawTransform.matrix().getDouble(0, 1), m_drawTransform.matrix().getDouble(0, 2), m_drawTransform.matrix().getDouble(0, 3),
+ m_drawTransform.matrix().getDouble(1, 0), m_drawTransform.matrix().getDouble(1, 1), m_drawTransform.matrix().getDouble(1, 2), m_drawTransform.matrix().getDouble(1, 3),
+ m_drawTransform.matrix().getDouble(2, 0), m_drawTransform.matrix().getDouble(2, 1), m_drawTransform.matrix().getDouble(2, 2), m_drawTransform.matrix().getDouble(2, 3),
+ m_drawTransform.matrix().getDouble(3, 0), m_drawTransform.matrix().getDouble(3, 1), m_drawTransform.matrix().getDouble(3, 2), m_drawTransform.matrix().getDouble(3, 3));
str->append(indentStr);
base::StringAppendF(str, "drawsContent: %s\n", m_drawsContent ? "yes" : "no");
@@ -433,12 +431,12 @@ void LayerImpl::setOpacityFromAnimation(float opacity)
setOpacity(opacity);
}
-const WebKit::WebTransformationMatrix& LayerImpl::transform() const
+const gfx::Transform& LayerImpl::transform() const
{
return m_transform;
}
-void LayerImpl::setTransformFromAnimation(const WebTransformationMatrix& transform)
+void LayerImpl::setTransformFromAnimation(const gfx::Transform& transform)
{
setTransform(transform);
}
@@ -595,7 +593,7 @@ void LayerImpl::setPreserves3D(bool preserves3D)
noteLayerPropertyChangedForSubtree();
}
-void LayerImpl::setSublayerTransform(const WebTransformationMatrix& sublayerTransform)
+void LayerImpl::setSublayerTransform(const gfx::Transform& sublayerTransform)
{
if (m_sublayerTransform == sublayerTransform)
return;
@@ -605,7 +603,7 @@ void LayerImpl::setSublayerTransform(const WebTransformationMatrix& sublayerTran
noteLayerPropertyChangedForDescendants();
}
-void LayerImpl::setTransform(const WebTransformationMatrix& transform)
+void LayerImpl::setTransform(const gfx::Transform& transform)
{
if (m_transform == transform)
return;
@@ -656,7 +654,7 @@ void LayerImpl::setScrollDelta(const gfx::Vector2dF& scrollDelta)
noteLayerPropertyChangedForSubtree();
}
-void LayerImpl::setImplTransform(const WebKit::WebTransformationMatrix& transform)
+void LayerImpl::setImplTransform(const gfx::Transform& transform)
{
if (m_implTransform == transform)
return;
diff --git a/cc/layer_impl.h b/cc/layer_impl.h
index 1dd36bb..02f94ec 100644
--- a/cc/layer_impl.h
+++ b/cc/layer_impl.h
@@ -5,6 +5,7 @@
#ifndef CC_LAYER_IMPL_H_
#define CC_LAYER_IMPL_H_
+#include <public/WebFilterOperations.h>
#include <string>
#include "base/logging.h"
@@ -21,8 +22,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h"
-#include <public/WebFilterOperations.h>
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
namespace cc {
@@ -49,8 +49,8 @@ public:
virtual int id() const OVERRIDE;
virtual void setOpacityFromAnimation(float) OVERRIDE;
virtual float opacity() const OVERRIDE;
- virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix&) OVERRIDE;
- virtual const WebKit::WebTransformationMatrix& transform() const OVERRIDE;
+ virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE;
+ virtual const gfx::Transform& transform() const OVERRIDE;
// Tree structure.
LayerImpl* parent() { return m_parent; }
@@ -145,8 +145,8 @@ public:
void setUseLCDText(bool useLCDText) { m_useLCDText = useLCDText; }
bool useLCDText() const { return m_useLCDText; }
- void setSublayerTransform(const WebKit::WebTransformationMatrix&);
- const WebKit::WebTransformationMatrix& sublayerTransform() const { return m_sublayerTransform; }
+ void setSublayerTransform(const gfx::Transform&);
+ const gfx::Transform& sublayerTransform() const { return m_sublayerTransform; }
// Debug layer name.
void setDebugName(const std::string& debugName) { m_debugName = debugName; }
@@ -193,8 +193,8 @@ public:
const gfx::Vector2dF& scrollDelta() const { return m_scrollDelta; }
void setScrollDelta(const gfx::Vector2dF&);
- const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; }
- void setImplTransform(const WebKit::WebTransformationMatrix& transform);
+ const gfx::Transform& implTransform() const { return m_implTransform; }
+ void setImplTransform(const gfx::Transform& transform);
const gfx::Vector2d& sentScrollDelta() const { return m_sentScrollDelta; }
void setSentScrollDelta(const gfx::Vector2d& sentScrollDelta) { m_sentScrollDelta = sentScrollDelta; }
@@ -228,13 +228,13 @@ public:
bool doubleSided() const { return m_doubleSided; }
void setDoubleSided(bool);
- void setTransform(const WebKit::WebTransformationMatrix&);
+ void setTransform(const gfx::Transform&);
bool transformIsAnimating() const;
- const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; }
- void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_drawTransform = matrix; }
- const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; }
- void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix) { m_screenSpaceTransform = matrix; }
+ const gfx::Transform& drawTransform() const { return m_drawTransform; }
+ void setDrawTransform(const gfx::Transform& matrix) { m_drawTransform = matrix; }
+ const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
+ void setScreenSpaceTransform(const gfx::Transform& matrix) { m_screenSpaceTransform = matrix; }
bool drawTransformIsAnimating() const { return m_drawTransformIsAnimating; }
void setDrawTransformIsAnimating(bool animating) { m_drawTransformIsAnimating = animating; }
@@ -357,8 +357,8 @@ private:
bool m_preserves3D;
bool m_useParentBackfaceVisibility;
bool m_drawCheckerboardForMissingTiles;
- WebKit::WebTransformationMatrix m_sublayerTransform;
- WebKit::WebTransformationMatrix m_transform;
+ gfx::Transform m_sublayerTransform;
+ gfx::Transform m_transform;
bool m_useLCDText;
bool m_drawsContent;
@@ -372,7 +372,7 @@ private:
gfx::Vector2dF m_scrollDelta;
gfx::Vector2d m_sentScrollDelta;
gfx::Vector2d m_maxScrollOffset;
- WebKit::WebTransformationMatrix m_implTransform;
+ gfx::Transform m_implTransform;
// The layer whose coordinate space this layer draws into. This can be
// either the same layer (m_renderTarget == this) or an ancestor of this
@@ -392,8 +392,8 @@ private:
WebKit::WebFilterOperations m_backgroundFilters;
SkImageFilter* m_filter;
- WebKit::WebTransformationMatrix m_drawTransform;
- WebKit::WebTransformationMatrix m_screenSpaceTransform;
+ gfx::Transform m_drawTransform;
+ gfx::Transform m_screenSpaceTransform;
bool m_drawTransformIsAnimating;
bool m_screenSpaceTransformIsAnimating;
diff --git a/cc/layer_impl_unittest.cc b/cc/layer_impl_unittest.cc
index f47dc1d..20df1ff 100644
--- a/cc/layer_impl_unittest.cc
+++ b/cc/layer_impl_unittest.cc
@@ -76,8 +76,8 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
gfx::Rect arbitraryRect = gfx::Rect(arbitraryPoint, arbitrarySize);
gfx::RectF arbitraryRectF = gfx::RectF(arbitraryPointF, gfx::SizeF(1.234f, 5.678f));
SkColor arbitraryColor = SkColorSetRGB(10, 20, 30);
- WebTransformationMatrix arbitraryTransform;
- arbitraryTransform.scale3d(0.1, 0.2, 0.3);
+ gfx::Transform arbitraryTransform;
+ arbitraryTransform.Scale3d(0.1, 0.2, 0.3);
WebFilterOperations arbitraryFilters;
arbitraryFilters.append(WebFilterOperation::createOpacityFilter(0.5));
SkAutoTUnref<SkImageFilter> arbitraryFilter(new SkBlurImageFilter(SK_Scalar1, SK_Scalar1));
diff --git a/cc/layer_iterator_unittest.cc b/cc/layer_iterator_unittest.cc
index 0d5be64..cdcbec1 100644
--- a/cc/layer_iterator_unittest.cc
+++ b/cc/layer_iterator_unittest.cc
@@ -8,9 +8,8 @@
#include "cc/layer_tree_host_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
-using WebKit::WebTransformationMatrix;
using ::testing::Mock;
using ::testing::_;
using ::testing::AtLeast;
diff --git a/cc/layer_sorter.cc b/cc/layer_sorter.cc
index 0ab998f..48ec30a 100644
--- a/cc/layer_sorter.cc
+++ b/cc/layer_sorter.cc
@@ -12,10 +12,9 @@
#include "base/logging.h"
#include "cc/math_util.h"
#include "cc/render_surface_impl.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using namespace std;
-using WebKit::WebTransformationMatrix;
namespace cc {
@@ -146,7 +145,7 @@ LayerShape::LayerShape()
{
}
-LayerShape::LayerShape(float width, float height, const WebTransformationMatrix& drawTransform)
+LayerShape::LayerShape(float width, float height, const gfx::Transform& drawTransform)
{
gfx::QuadF layerQuad(gfx::RectF(0, 0, width, height));
@@ -230,7 +229,7 @@ void LayerSorter::createGraphNodes(LayerList::iterator first, LayerList::iterato
DVLOG(2) << "Layer " << node.layer->id() << " (" << node.layer->bounds().width() << " x " << node.layer->bounds().height() << ")";
- WebTransformationMatrix drawTransform;
+ gfx::Transform drawTransform;
float layerWidth, layerHeight;
if (renderSurface) {
drawTransform = renderSurface->drawTransform();
diff --git a/cc/layer_sorter.h b/cc/layer_sorter.h
index fbf4e5d..fabab31 100644
--- a/cc/layer_sorter.h
+++ b/cc/layer_sorter.h
@@ -30,8 +30,8 @@ struct hash<cc::GraphEdge*> {
} // namespace BASE_HASH_NAMESPACE
#endif // COMPILER
-namespace WebKit {
-class WebTransformationMatrix;
+namespace gfx {
+class Transform;
}
namespace cc {
@@ -41,7 +41,7 @@ struct GraphEdge;
// Holds various useful properties derived from a layer's 3D outline.
struct CC_EXPORT LayerShape {
LayerShape();
- LayerShape(float width, float height, const WebKit::WebTransformationMatrix& drawTransform);
+ LayerShape(float width, float height, const gfx::Transform& drawTransform);
~LayerShape();
float layerZFromProjectedPoint(const gfx::PointF&) const;
diff --git a/cc/layer_sorter_unittest.cc b/cc/layer_sorter_unittest.cc
index 812bda5..9b13fce 100644
--- a/cc/layer_sorter_unittest.cc
+++ b/cc/layer_sorter_unittest.cc
@@ -8,9 +8,7 @@
#include "cc/math_util.h"
#include "cc/single_thread_proxy.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
namespace {
@@ -26,12 +24,12 @@ TEST(LayerSorterTest, BasicOverlap)
float weight = 0;
// Trivial test, with one layer directly obscuring the other.
- WebTransformationMatrix neg4Translate;
- neg4Translate.translate3d(0, 0, -4);
+ gfx::Transform neg4Translate;
+ neg4Translate.Translate3d(0, 0, -4);
LayerShape front(2, 2, neg4Translate);
- WebTransformationMatrix neg5Translate;
- neg5Translate.translate3d(0, 0, -5);
+ gfx::Transform neg5Translate;
+ neg5Translate.Translate3d(0, 0, -5);
LayerShape back(2, 2, neg5Translate);
overlapResult = LayerSorter::checkOverlap(&front, &back, zThreshold, weight);
@@ -43,8 +41,8 @@ TEST(LayerSorterTest, BasicOverlap)
EXPECT_EQ(1, weight);
// One layer translated off to the right. No overlap should be detected.
- WebTransformationMatrix rightTranslate;
- rightTranslate.translate3d(10, 0, -5);
+ gfx::Transform rightTranslate;
+ rightTranslate.Translate3d(10, 0, -5);
LayerShape backRight(2, 2, rightTranslate);
overlapResult = LayerSorter::checkOverlap(&front, &backRight, zThreshold, weight);
EXPECT_EQ(LayerSorter::None, overlapResult);
@@ -60,18 +58,18 @@ TEST(LayerSorterTest, RightAngleOverlap)
const float zThreshold = 0.1f;
float weight = 0;
- WebTransformationMatrix perspectiveMatrix;
- perspectiveMatrix.applyPerspective(1000);
+ gfx::Transform perspectiveMatrix;
+ perspectiveMatrix.ApplyPerspectiveDepth(1000);
// Two layers forming a right angle with a perspective viewing transform.
- WebTransformationMatrix leftFaceMatrix;
- leftFaceMatrix.translate3d(-1, 0, -5);
- leftFaceMatrix.rotate3d(0, 1, 0, -90);
- leftFaceMatrix.translate(-1, -1);
+ gfx::Transform leftFaceMatrix;
+ leftFaceMatrix.Translate3d(-1, 0, -5);
+ MathUtil::rotateAxisAngle(&leftFaceMatrix, 0, 1, 0, -90);
+ leftFaceMatrix.Translate(-1, -1);
LayerShape leftFace(2, 2, perspectiveMatrix * leftFaceMatrix);
- WebTransformationMatrix frontFaceMatrix;
- frontFaceMatrix.translate3d(0, 0, -4);
- frontFaceMatrix.translate(-1, -1);
+ gfx::Transform frontFaceMatrix;
+ frontFaceMatrix.Translate3d(0, 0, -4);
+ frontFaceMatrix.Translate(-1, -1);
LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
overlapResult = LayerSorter::checkOverlap(&frontFace, &leftFace, zThreshold, weight);
@@ -84,20 +82,20 @@ TEST(LayerSorterTest, IntersectingLayerOverlap)
const float zThreshold = 0.1f;
float weight = 0;
- WebTransformationMatrix perspectiveMatrix;
- perspectiveMatrix.applyPerspective(1000);
+ gfx::Transform perspectiveMatrix;
+ perspectiveMatrix.ApplyPerspectiveDepth(1000);
// Intersecting layers. An explicit order will be returned based on relative z
// values at the overlapping features but the weight returned should be zero.
- WebTransformationMatrix frontFaceMatrix;
- frontFaceMatrix.translate3d(0, 0, -4);
- frontFaceMatrix.translate(-1, -1);
+ gfx::Transform frontFaceMatrix;
+ frontFaceMatrix.Translate3d(0, 0, -4);
+ frontFaceMatrix.Translate(-1, -1);
LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
- WebTransformationMatrix throughMatrix;
- throughMatrix.translate3d(0, 0, -4);
- throughMatrix.rotate3d(0, 1, 0, 45);
- throughMatrix.translate(-1, -1);
+ gfx::Transform throughMatrix;
+ throughMatrix.Translate3d(0, 0, -4);
+ MathUtil::rotateAxisAngle(&throughMatrix, 0, 1, 0, 45);
+ throughMatrix.Translate(-1, -1);
LayerShape rotatedFace(2, 2, perspectiveMatrix * throughMatrix);
overlapResult = LayerSorter::checkOverlap(&frontFace, &rotatedFace, zThreshold, weight);
EXPECT_NE(LayerSorter::None, overlapResult);
@@ -122,19 +120,19 @@ TEST(LayerSorterTest, LayersAtAngleOverlap)
// C is in front of A and behind B (not what you'd expect by comparing centers).
// A and B don't overlap, so they're incomparable.
- WebTransformationMatrix transformA;
- transformA.translate3d(-6, 0, 1);
- transformA.translate(-4, -10);
+ gfx::Transform transformA;
+ transformA.Translate3d(-6, 0, 1);
+ transformA.Translate(-4, -10);
LayerShape layerA(8, 20, transformA);
- WebTransformationMatrix transformB;
- transformB.translate3d(6, 0, -1);
- transformB.translate(-4, -10);
+ gfx::Transform transformB;
+ transformB.Translate3d(6, 0, -1);
+ transformB.Translate(-4, -10);
LayerShape layerB(8, 20, transformB);
- WebTransformationMatrix transformC;
- transformC.rotate3d(0, 1, 0, 40);
- transformC.translate(-4, -10);
+ gfx::Transform transformC;
+ MathUtil::rotateAxisAngle(&transformC, 0, 1, 0, 40);
+ transformC.Translate(-4, -10);
LayerShape layerC(8, 20, transformC);
overlapResult = LayerSorter::checkOverlap(&layerA, &layerC, zThreshold, weight);
@@ -156,22 +154,22 @@ TEST(LayerSorterTest, LayersUnderPathologicalPerspectiveTransform)
// where w < 0. If the code uses the invalid value, it will think that a layer has
// different bounds than it really does, which can cause things to sort incorrectly.
- WebTransformationMatrix perspectiveMatrix;
- perspectiveMatrix.applyPerspective(1);
+ gfx::Transform perspectiveMatrix;
+ perspectiveMatrix.ApplyPerspectiveDepth(1);
- WebTransformationMatrix transformA;
- transformA.translate3d(-15, 0, -2);
- transformA.translate(-5, -5);
+ gfx::Transform transformA;
+ transformA.Translate3d(-15, 0, -2);
+ transformA.Translate(-5, -5);
LayerShape layerA(10, 10, perspectiveMatrix * transformA);
// With this sequence of transforms, when layer B is correctly clipped, it will be
// visible on the left half of the projection plane, in front of layerA. When it is
// not clipped, its bounds will actually incorrectly appear much smaller and the
// correct sorting dependency will not be found.
- WebTransformationMatrix transformB;
- transformB.translate3d(0, 0, 0.7);
- transformB.rotate3d(0, 45, 0);
- transformB.translate(-5, -5);
+ gfx::Transform transformB;
+ transformB.Translate3d(0, 0, 0.7);
+ MathUtil::rotateEulerAngles(&transformB, 0, 45, 0);
+ transformB.Translate(-5, -5);
LayerShape layerB(10, 10, perspectiveMatrix * transformB);
// Sanity check that the test case actually covers the intended scenario, where part
@@ -205,10 +203,10 @@ TEST(LayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff)
scoped_ptr<LayerImpl> layer4 = LayerImpl::create(4);
scoped_ptr<LayerImpl> layer5 = LayerImpl::create(5);
- WebTransformationMatrix BehindMatrix;
- BehindMatrix.translate3d(0, 0, 2);
- WebTransformationMatrix FrontMatrix;
- FrontMatrix.translate3d(0, 0, 1);
+ gfx::Transform BehindMatrix;
+ BehindMatrix.Translate3d(0, 0, 2);
+ gfx::Transform FrontMatrix;
+ FrontMatrix.Translate3d(0, 0, 1);
layer1->setBounds(gfx::Size(10, 10));
layer1->setContentBounds(gfx::Size(10, 10));
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
index f030a8e..b423eb7 100644
--- a/cc/layer_tree_host.cc
+++ b/cc/layer_tree_host.cc
@@ -734,14 +734,14 @@ void LayerTreeHost::applyScrollAndScale(const ScrollAndScaleSet& info)
gfx::PointF LayerTreeHost::adjustEventPointForPinchZoom(const gfx::PointF& zoomedViewportPoint)
const
{
- if (m_implTransform.isIdentity())
+ if (m_implTransform.IsIdentity())
return zoomedViewportPoint;
- DCHECK(m_implTransform.isInvertible());
+ DCHECK(m_implTransform.IsInvertible());
// Scale to screen space before applying implTransform inverse.
gfx::PointF zoomedScreenspacePoint = gfx::ScalePoint(zoomedViewportPoint, deviceScaleFactor());
- WebKit::WebTransformationMatrix inverseImplTransform = m_implTransform.inverse();
+ gfx::Transform inverseImplTransform = MathUtil::inverse(m_implTransform);
bool wasClipped = false;
gfx::PointF unzoomedScreenspacePoint = MathUtil::projectPoint(inverseImplTransform, zoomedScreenspacePoint, wasClipped);
@@ -753,7 +753,7 @@ gfx::PointF LayerTreeHost::adjustEventPointForPinchZoom(const gfx::PointF& zoome
return unzoomedViewportPoint;
}
-void LayerTreeHost::setImplTransform(const WebKit::WebTransformationMatrix& transform)
+void LayerTreeHost::setImplTransform(const gfx::Transform& transform)
{
m_implTransform = transform;
}
diff --git a/cc/layer_tree_host.h b/cc/layer_tree_host.h
index 9718a4d..ec8708d 100644
--- a/cc/layer_tree_host.h
+++ b/cc/layer_tree_host.h
@@ -206,7 +206,7 @@ public:
// logical pixels in the un-zoomed viewport, the latter being the coordinates
// required for hit-testing.
gfx::PointF adjustEventPointForPinchZoom(const gfx::PointF& zoomedViewportPoint) const;
- void setImplTransform(const WebKit::WebTransformationMatrix&);
+ void setImplTransform(const gfx::Transform&);
void startRateLimiter(WebKit::WebGraphicsContext3D*);
void stopRateLimiter(WebKit::WebGraphicsContext3D*);
@@ -289,7 +289,7 @@ private:
float m_pageScaleFactor;
float m_minPageScaleFactor, m_maxPageScaleFactor;
- WebKit::WebTransformationMatrix m_implTransform;
+ gfx::Transform m_implTransform;
bool m_triggerIdleUpdates;
SkColor m_backgroundColor;
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index ca7d450..41d6875 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -4,6 +4,8 @@
#include "cc/layer_tree_host_common.h"
+#include <algorithm>
+
#include "cc/layer.h"
#include "cc/layer_impl.h"
#include "cc/layer_iterator.h"
@@ -13,10 +15,7 @@
#include "cc/render_surface_impl.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect_conversions.h"
-#include <algorithm>
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
@@ -28,7 +27,7 @@ ScrollAndScaleSet::~ScrollAndScaleSet()
{
}
-gfx::Rect LayerTreeHostCommon::calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const WebTransformationMatrix& transform)
+gfx::Rect LayerTreeHostCommon::calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const gfx::Transform& transform)
{
// Is this layer fully contained within the target surface?
gfx::Rect layerInSurfaceSpace = MathUtil::mapClippedRect(transform, layerBoundRect);
@@ -45,7 +44,7 @@ gfx::Rect LayerTreeHostCommon::calculateVisibleRect(const gfx::Rect& targetSurfa
// This bounding rectangle may be larger than it needs to be (being
// axis-aligned), but is a reasonable filter on the space to consider.
// Non-invertible transforms will create an empty rect here.
- const WebTransformationMatrix surfaceToLayer = transform.inverse();
+ const gfx::Transform surfaceToLayer = MathUtil::inverse(transform);
gfx::Rect layerRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(surfaceToLayer, gfx::RectF(minimalSurfaceRect)));
layerRect.Intersect(layerBoundRect);
return layerRect;
@@ -86,21 +85,21 @@ static bool isLayerBackFaceVisible(LayerType* layer)
// rendering context by checking if the parent preserves 3d.
if (layerIsInExisting3DRenderingContext(layer))
- return layer->drawTransform().isBackFaceVisible();
+ return MathUtil::isBackFaceVisible(layer->drawTransform());
// In this case, either the layer establishes a new 3d rendering context, or is not in
// a 3d rendering context at all.
- return layer->transform().isBackFaceVisible();
+ return MathUtil::isBackFaceVisible(layer->transform());
}
template<typename LayerType>
-static bool isSurfaceBackFaceVisible(LayerType* layer, const WebTransformationMatrix& drawTransform)
+static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& drawTransform)
{
if (layerIsInExisting3DRenderingContext(layer))
- return drawTransform.isBackFaceVisible();
+ return MathUtil::isBackFaceVisible(drawTransform);
if (isRootLayerOfNewRenderingContext(layer))
- return layer->transform().isBackFaceVisible();
+ return MathUtil::isBackFaceVisible(layer->transform());
// If the renderSurface is not part of a new or existing rendering context, then the
// layers that contribute to this surface will decide back-face visibility for themselves.
@@ -131,7 +130,7 @@ static gfx::Rect calculateVisibleContentRect(LayerType* layer)
// In this case the target surface does clip layers that contribute to it. So, we
// have convert the current surface's clipRect from its ancestor surface space to
// the current surface space.
- targetSurfaceClipRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(layer->renderTarget()->renderSurface()->drawTransform().inverse(), layer->renderTarget()->renderSurface()->clipRect()));
+ targetSurfaceClipRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(MathUtil::inverse(layer->renderTarget()->renderSurface()->drawTransform()), layer->renderTarget()->renderSurface()->clipRect()));
targetSurfaceClipRect.Intersect(layer->drawableContentRect());
}
@@ -141,12 +140,12 @@ static gfx::Rect calculateVisibleContentRect(LayerType* layer)
return LayerTreeHostCommon::calculateVisibleRect(targetSurfaceClipRect, gfx::Rect(gfx::Point(), layer->contentBounds()), layer->drawTransform());
}
-static bool isScaleOrTranslation(const WebTransformationMatrix& m)
+static bool isScaleOrTranslation(const gfx::Transform& m)
{
- return !m.m12() && !m.m13() && !m.m14()
- && !m.m21() && !m.m23() && !m.m24()
- && !m.m31() && !m.m32() && !m.m43()
- && m.m44();
+ return !m.matrix().getDouble(1, 0) && !m.matrix().getDouble(2, 0) && !m.matrix().getDouble(3, 0)
+ && !m.matrix().getDouble(0, 1) && !m.matrix().getDouble(2, 1) && !m.matrix().getDouble(3, 1)
+ && !m.matrix().getDouble(0, 2) && !m.matrix().getDouble(1, 2) && !m.matrix().getDouble(2, 3)
+ && m.matrix().getDouble(3, 3);
}
static inline bool transformToParentIsKnown(LayerImpl*)
@@ -265,7 +264,7 @@ static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
return false;
}
-WebTransformationMatrix computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer, const WebTransformationMatrix& parentMatrix)
+gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer, const gfx::Transform& parentMatrix)
{
// For every layer that has non-zero scrollDelta, we have to compute a transform that can undo the
// scrollDelta translation. In particular, we want this matrix to premultiply a fixed-position layer's
@@ -284,23 +283,23 @@ WebTransformationMatrix computeScrollCompensationForThisLayer(LayerImpl* scrolli
// that fixed position layer is fixed onto the same renderTarget as this scrollingLayer.
//
- WebTransformationMatrix partialLayerOriginTransform = parentMatrix;
- partialLayerOriginTransform.multiply(scrollingLayer->implTransform());
+ gfx::Transform partialLayerOriginTransform = parentMatrix;
+ partialLayerOriginTransform.PreconcatTransform(scrollingLayer->implTransform());
- WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3
- scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // Step 2
- scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse()); // Step 1
+ gfx::Transform scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3
+ scrollCompensationForThisLayer.Translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // Step 2
+ scrollCompensationForThisLayer.PreconcatTransform(MathUtil::inverse(partialLayerOriginTransform)); // Step 1
return scrollCompensationForThisLayer;
}
-WebTransformationMatrix computeScrollCompensationMatrixForChildren(Layer* currentLayer, const WebTransformationMatrix& currentParentMatrix, const WebTransformationMatrix& currentScrollCompensation)
+gfx::Transform computeScrollCompensationMatrixForChildren(Layer* currentLayer, const gfx::Transform& currentParentMatrix, const gfx::Transform& currentScrollCompensation)
{
// The main thread (i.e. Layer) does not need to worry about scroll compensation.
// So we can just return an identity matrix here.
- return WebTransformationMatrix();
+ return gfx::Transform();
}
-WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* layer, const WebTransformationMatrix& parentMatrix, const WebTransformationMatrix& currentScrollCompensationMatrix)
+gfx::Transform computeScrollCompensationMatrixForChildren(LayerImpl* layer, const gfx::Transform& parentMatrix, const gfx::Transform& currentScrollCompensationMatrix)
{
// "Total scroll compensation" is the transform needed to cancel out all scrollDelta translations that
// occurred since the nearest container layer, even if there are renderSurfaces in-between.
@@ -323,7 +322,7 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
return currentScrollCompensationMatrix;
// Start as identity matrix.
- WebTransformationMatrix nextScrollCompensationMatrix;
+ gfx::Transform nextScrollCompensationMatrix;
// If this layer is not a container, then it inherits the existing scroll compensations.
if (!layer->isContainerForFixedPositionLayers())
@@ -332,8 +331,8 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
// If the current layer has a non-zero scrollDelta, then we should compute its local scrollCompensation
// and accumulate it to the nextScrollCompensationMatrix.
if (!layer->scrollDelta().IsZero()) {
- WebTransformationMatrix scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix);
- nextScrollCompensationMatrix.multiply(scrollCompensationForThisLayer);
+ gfx::Transform scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix);
+ nextScrollCompensationMatrix.PreconcatTransform(scrollCompensationForThisLayer);
}
// If the layer created its own renderSurface, we have to adjust nextScrollCompensationMatrix.
@@ -341,16 +340,16 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
// Step 1 (right-most in the math): transform from the new surface to the original ancestor surface
// Step 2: apply the scroll compensation
// Step 3: transform back to the new surface.
- if (layer->renderSurface() && !nextScrollCompensationMatrix.isIdentity())
- nextScrollCompensationMatrix = layer->renderSurface()->drawTransform().inverse() * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform();
+ if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity())
+ nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()->drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform();
return nextScrollCompensationMatrix;
}
// There is no contentsScale on impl thread.
-static inline void updateLayerContentsScale(LayerImpl*, const WebTransformationMatrix&, float, float, bool) { }
+static inline void updateLayerContentsScale(LayerImpl*, const gfx::Transform&, float, float, bool) { }
-static inline void updateLayerContentsScale(Layer* layer, const WebTransformationMatrix& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatingTransformToScreen)
+static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatingTransformToScreen)
{
float rasterScale = layer->rasterScale();
if (!rasterScale) {
@@ -387,8 +386,8 @@ static inline void updateLayerContentsScale(Layer* layer, const WebTransformatio
// Recursively walks the layer tree starting at the given node and computes all the
// necessary transformations, clipRects, render surfaces, etc.
template<typename LayerType, typename LayerList, typename RenderSurfaceType, typename LayerSorter>
-static void calculateDrawTransformsInternal(LayerType* layer, const WebTransformationMatrix& parentMatrix,
- const WebTransformationMatrix& fullHierarchyMatrix, const WebTransformationMatrix& currentScrollCompensationMatrix,
+static void calculateDrawTransformsInternal(LayerType* layer, const gfx::Transform& parentMatrix,
+ const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScrollCompensationMatrix,
const gfx::Rect& clipRectFromAncestor, bool ancestorClipsSubtree,
RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceLayerList, LayerList& layerList,
LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, gfx::Rect& drawableContentRectOfSubtree)
@@ -405,7 +404,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// projection applied at draw time flips the Y axis appropriately.
//
// 2. The anchor point, when given as a PointF object, is specified in "unit layer space",
- // where the bounds of the layer map to [0, 1]. However, as a WebTransformationMatrix object,
+ // where the bounds of the layer map to [0, 1]. However, as a Transform object,
// the transform to the anchor point is specified in "layer space", where the bounds
// of the layer map to [bounds.width(), bounds.height()].
//
@@ -458,7 +457,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// S is the scale adjustment (to scale up a canonical quad to the layer's size)
//
// When a render surface has a replica layer, that layer's transform is used to draw a second copy of the surface.
- // Transforms named here are relative to the surface, unless they specify they are relative to the replica layer.
+ // gfx::Transforms named here are relative to the surface, unless they specify they are relative to the replica layer.
//
// We will denote a scale by device scale S[deviceScale]
//
@@ -503,16 +502,16 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
gfx::PointF anchorPoint = layer->anchorPoint();
gfx::PointF position = layer->position() - layer->scrollDelta();
- WebTransformationMatrix layerLocalTransform;
+ gfx::Transform layerLocalTransform;
// LT = Tr[origin] * Tr[origin2anchor]
- layerLocalTransform.translate3d(position.x() + anchorPoint.x() * bounds.width(), position.y() + anchorPoint.y() * bounds.height(), layer->anchorPointZ());
+ layerLocalTransform.Translate3d(position.x() + anchorPoint.x() * bounds.width(), position.y() + anchorPoint.y() * bounds.height(), layer->anchorPointZ());
// LT = Tr[origin] * Tr[origin2anchor] * M[layer]
- layerLocalTransform.multiply(layer->transform());
+ layerLocalTransform.PreconcatTransform(layer->transform());
// LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin]
- layerLocalTransform.translate3d(-anchorPoint.x() * bounds.width(), -anchorPoint.y() * bounds.height(), -layer->anchorPointZ());
+ layerLocalTransform.Translate3d(-anchorPoint.x() * bounds.width(), -anchorPoint.y() * bounds.height(), -layer->anchorPointZ());
- WebTransformationMatrix combinedTransform = parentMatrix;
- combinedTransform.multiply(layerLocalTransform);
+ gfx::Transform combinedTransform = parentMatrix;
+ combinedTransform.PreconcatTransform(layerLocalTransform);
// The layer's contentsSize is determined from the combinedTransform, which then informs the
// layer's drawTransform.
@@ -531,23 +530,23 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// The drawTransform that gets computed below is effectively the layer's drawTransform, unless
// the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms.
- WebTransformationMatrix drawTransform = combinedTransform;
+ gfx::Transform drawTransform = combinedTransform;
// M[draw] = M[parent] * LT * S[layer2content]
- drawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
+ drawTransform.Scale(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
// layerScreenSpaceTransform represents the transform between root layer's "screen space" and local content space.
- WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix;
+ gfx::Transform layerScreenSpaceTransform = fullHierarchyMatrix;
if (!layer->preserves3D())
MathUtil::flattenTransformTo2d(layerScreenSpaceTransform);
- layerScreenSpaceTransform.multiply(drawTransform);
+ layerScreenSpaceTransform.PreconcatTransform(drawTransform);
layer->setScreenSpaceTransform(layerScreenSpaceTransform);
gfx::RectF contentRect(gfx::PointF(), layer->contentBounds());
// fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurfaceImpl's space.
// nextHierarchyMatrix will only change if this layer uses a new RenderSurfaceImpl, otherwise remains the same.
- WebTransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix;
- WebTransformationMatrix sublayerMatrix;
+ gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix;
+ gfx::Transform sublayerMatrix;
gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::computeTransform2dScaleComponents(combinedTransform);
@@ -564,21 +563,21 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// The owning layer's draw transform has a scale from content to layer space which we need to undo and
// replace with a scale from the surface's subtree into layer space.
- drawTransform.scaleNonUniform(layer->contentsScaleX(), layer->contentsScaleY());
- drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
+ drawTransform.Scale(layer->contentsScaleX(), layer->contentsScaleY());
+ drawTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
renderSurface->setDrawTransform(drawTransform);
// The origin of the new surface is the upper left corner of the layer.
- WebTransformationMatrix layerDrawTransform;
- layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
- layerDrawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
+ gfx::Transform layerDrawTransform;
+ layerDrawTransform.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
+ layerDrawTransform.Scale(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
layer->setDrawTransform(layerDrawTransform);
// Inside the surface's subtree, we scale everything to the owning layer's scale.
// The sublayer matrix transforms centered layer rects into target
// surface content space.
- sublayerMatrix.makeIdentity();
- sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
+ sublayerMatrix.MakeIdentity();
+ sublayerMatrix.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
// The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity.
renderSurface->setDrawOpacity(drawOpacity);
@@ -594,7 +593,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// Update the aggregate hierarchy matrix to include the transform of the
// newly created RenderSurfaceImpl.
- nextHierarchyMatrix.multiply(renderSurface->drawTransform());
+ nextHierarchyMatrix.PreconcatTransform(renderSurface->drawTransform());
// The new renderSurface here will correctly clip the entire subtree. So, we do
// not need to continue propagating the clipping state further down the tree. This
@@ -665,9 +664,9 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
MathUtil::flattenTransformTo2d(sublayerMatrix);
// Apply the sublayer transform at the center of the layer.
- sublayerMatrix.translate(0.5 * bounds.width(), 0.5 * bounds.height());
- sublayerMatrix.multiply(layer->sublayerTransform());
- sublayerMatrix.translate(-0.5 * bounds.width(), -0.5 * bounds.height());
+ sublayerMatrix.Translate(0.5 * bounds.width(), 0.5 * bounds.height());
+ sublayerMatrix.PreconcatTransform(layer->sublayerTransform());
+ sublayerMatrix.Translate(-0.5 * bounds.width(), -0.5 * bounds.height());
LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->layerList() : layerList);
@@ -677,7 +676,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
if (!layerShouldBeSkipped(layer))
descendants.push_back(layer);
- WebTransformationMatrix nextScrollCompensationMatrix = computeScrollCompensationMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);;
+ gfx::Transform nextScrollCompensationMatrix = computeScrollCompensationMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);;
gfx::Rect accumulatedDrawableContentRectOfChildren;
for (size_t i = 0; i < layer->children().size(); ++i) {
@@ -756,26 +755,26 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// The owning layer's screenSpaceTransform has a scale from content to layer space which we need to undo and
// replace with a scale from the surface's subtree into layer space.
- WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransform();
- screenSpaceTransform.scaleNonUniform(layer->contentsScaleX(), layer->contentsScaleY());
- screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
+ gfx::Transform screenSpaceTransform = layer->screenSpaceTransform();
+ screenSpaceTransform.Scale(layer->contentsScaleX(), layer->contentsScaleY());
+ screenSpaceTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
renderSurface->setScreenSpaceTransform(screenSpaceTransform);
if (layer->replicaLayer()) {
- WebTransformationMatrix surfaceOriginToReplicaOriginTransform;
- surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
- surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer()->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(),
+ gfx::Transform surfaceOriginToReplicaOriginTransform;
+ surfaceOriginToReplicaOriginTransform.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
+ surfaceOriginToReplicaOriginTransform.Translate(layer->replicaLayer()->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(),
layer->replicaLayer()->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height());
- surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()->transform());
- surfaceOriginToReplicaOriginTransform.translate(-layer->replicaLayer()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y() * bounds.height());
- surfaceOriginToReplicaOriginTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
+ surfaceOriginToReplicaOriginTransform.PreconcatTransform(layer->replicaLayer()->transform());
+ surfaceOriginToReplicaOriginTransform.Translate(-layer->replicaLayer()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y() * bounds.height());
+ surfaceOriginToReplicaOriginTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
// Compute the replica's "originTransform" that maps from the replica's origin space to the target surface origin space.
- WebTransformationMatrix replicaOriginTransform = layer->renderSurface()->drawTransform() * surfaceOriginToReplicaOriginTransform;
+ gfx::Transform replicaOriginTransform = layer->renderSurface()->drawTransform() * surfaceOriginToReplicaOriginTransform;
renderSurface->setReplicaDrawTransform(replicaOriginTransform);
// Compute the replica's "screenSpaceTransform" that maps from the replica's origin space to the screen's origin space.
- WebTransformationMatrix replicaScreenSpaceTransform = layer->renderSurface()->screenSpaceTransform() * surfaceOriginToReplicaOriginTransform;
+ gfx::Transform replicaScreenSpaceTransform = layer->renderSurface()->screenSpaceTransform() * surfaceOriginToReplicaOriginTransform;
renderSurface->setReplicaScreenSpaceTransform(replicaScreenSpaceTransform);
}
@@ -819,9 +818,9 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerList)
{
gfx::Rect totalDrawableContentRect;
- WebTransformationMatrix identityMatrix;
- WebTransformationMatrix deviceScaleTransform;
- deviceScaleTransform.scale(deviceScaleFactor);
+ gfx::Transform identityMatrix;
+ gfx::Transform deviceScaleTransform;
+ deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor);
std::vector<scoped_refptr<Layer> > dummyLayerList;
// The root layer's renderSurface should receive the deviceViewport as the initial clipRect.
@@ -846,9 +845,9 @@ void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const gfx::S
void LayerTreeHostCommon::calculateDrawTransforms(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, LayerSorter* layerSorter, int maxTextureSize, std::vector<LayerImpl*>& renderSurfaceLayerList)
{
gfx::Rect totalDrawableContentRect;
- WebTransformationMatrix identityMatrix;
- WebTransformationMatrix deviceScaleTransform;
- deviceScaleTransform.scale(deviceScaleFactor);
+ gfx::Transform identityMatrix;
+ gfx::Transform deviceScaleTransform;
+ deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor);
std::vector<LayerImpl*> dummyLayerList;
// The root layer's renderSurface should receive the deviceViewport as the initial clipRect.
@@ -870,15 +869,15 @@ void LayerTreeHostCommon::calculateDrawTransforms(LayerImpl* rootLayer, const gf
DCHECK(rootLayer->renderSurface());
}
-static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const WebTransformationMatrix& localSpaceToScreenSpaceTransform, gfx::RectF localSpaceRect)
+static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const gfx::Transform& localSpaceToScreenSpaceTransform, gfx::RectF localSpaceRect)
{
// If the transform is not invertible, then assume that this point doesn't hit this rect.
- if (!localSpaceToScreenSpaceTransform.isInvertible())
+ if (!localSpaceToScreenSpaceTransform.IsInvertible())
return false;
// Transform the hit test point from screen space to the local space of the given rect.
bool clipped = false;
- gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(localSpaceToScreenSpaceTransform.inverse(), screenSpacePoint, clipped);
+ gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(MathUtil::inverse(localSpaceToScreenSpaceTransform), screenSpacePoint, clipped);
// If projectPoint could not project to a valid value, then we assume that this point doesn't hit this rect.
if (clipped)
@@ -887,15 +886,15 @@ static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const WebTransfor
return localSpaceRect.Contains(hitTestPointInLocalSpace);
}
-static bool pointHitsRegion(gfx::PointF screenSpacePoint, const WebTransformationMatrix& screenSpaceTransform, const Region& layerSpaceRegion, float layerContentScaleX, float layerContentScaleY)
+static bool pointHitsRegion(gfx::PointF screenSpacePoint, const gfx::Transform& screenSpaceTransform, const Region& layerSpaceRegion, float layerContentScaleX, float layerContentScaleY)
{
// If the transform is not invertible, then assume that this point doesn't hit this region.
- if (!screenSpaceTransform.isInvertible())
+ if (!screenSpaceTransform.IsInvertible())
return false;
// Transform the hit test point from screen space to the local space of the given region.
bool clipped = false;
- gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(screenSpaceTransform.inverse(), screenSpacePoint, clipped);
+ gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(MathUtil::inverse(screenSpaceTransform), screenSpacePoint, clipped);
gfx::PointF hitTestPointInLayerSpace = gfx::ScalePoint(hitTestPointInContentSpace, 1 / layerContentScaleX, 1 / layerContentScaleY);
// If projectPoint could not project to a valid value, then we assume that this point doesn't hit this region.
diff --git a/cc/layer_tree_host_common.h b/cc/layer_tree_host_common.h
index 9b0a684..8975577 100644
--- a/cc/layer_tree_host_common.h
+++ b/cc/layer_tree_host_common.h
@@ -9,8 +9,8 @@
#include "cc/cc_export.h"
#include "cc/scoped_ptr_vector.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/transform.h"
#include "ui/gfx/vector2d.h"
-#include <public/WebTransformationMatrix.h>
namespace cc {
@@ -20,7 +20,7 @@ class Layer;
class CC_EXPORT LayerTreeHostCommon {
public:
- static gfx::Rect calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const WebKit::WebTransformationMatrix&);
+ static gfx::Rect calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const gfx::Transform&);
static void calculateDrawTransforms(Layer* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerList);
static void calculateDrawTransforms(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, LayerSorter*, int maxTextureSize, std::vector<LayerImpl*>& renderSurfaceLayerList);
diff --git a/cc/layer_tree_host_common_unittest.cc b/cc/layer_tree_host_common_unittest.cc
index 456ea52..0623a36 100644
--- a/cc/layer_tree_host_common_unittest.cc
+++ b/cc/layer_tree_host_common_unittest.cc
@@ -19,16 +19,15 @@
#include "ui/gfx/size_conversions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using namespace WebKitTests;
-using WebKit::WebTransformationMatrix;
namespace cc {
namespace {
template<typename LayerType>
-void setLayerPropertiesForTestingInternal(LayerType* layer, const WebTransformationMatrix& transform, const WebTransformationMatrix& sublayerTransform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D)
+void setLayerPropertiesForTestingInternal(LayerType* layer, const gfx::Transform& transform, const gfx::Transform& sublayerTransform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D)
{
layer->setTransform(transform);
layer->setSublayerTransform(sublayerTransform);
@@ -38,13 +37,13 @@ void setLayerPropertiesForTestingInternal(LayerType* layer, const WebTransformat
layer->setPreserves3D(preserves3D);
}
-void setLayerPropertiesForTesting(Layer* layer, const WebTransformationMatrix& transform, const WebTransformationMatrix& sublayerTransform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D)
+void setLayerPropertiesForTesting(Layer* layer, const gfx::Transform& transform, const gfx::Transform& sublayerTransform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D)
{
setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransform, anchor, position, bounds, preserves3D);
layer->setAutomaticallyComputeRasterScale(true);
}
-void setLayerPropertiesForTesting(LayerImpl* layer, const WebTransformationMatrix& transform, const WebTransformationMatrix& sublayerTransform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D)
+void setLayerPropertiesForTesting(LayerImpl* layer, const gfx::Transform& transform, const gfx::Transform& sublayerTransform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D)
{
setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTransform, anchor, position, bounds, preserves3D);
layer->setContentBounds(bounds);
@@ -52,7 +51,7 @@ void setLayerPropertiesForTesting(LayerImpl* layer, const WebTransformationMatri
void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceScaleFactor = 1, float pageScaleFactor = 1)
{
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList;
int dummyMaxTextureSize = 512;
gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * deviceScaleFactor, rootLayer->bounds().height() * deviceScaleFactor);
@@ -66,7 +65,7 @@ void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev
{
// Note: this version skips layer sorting.
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
std::vector<LayerImpl*> dummyRenderSurfaceLayerList;
int dummyMaxTextureSize = 512;
gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * deviceScaleFactor, rootLayer->bounds().height() * deviceScaleFactor);
@@ -76,19 +75,6 @@ void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev
LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLayerList);
}
-WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix& mat)
-{
- WebTransformationMatrix ret = mat;
- ret.setM13(0);
- ret.setM23(0);
- ret.setM31(0);
- ret.setM32(0);
- ret.setM33(1);
- ret.setM34(0);
- ret.setM43(0);
- return ret;
-}
-
scoped_ptr<LayerImpl> createTreeForFixedPositionTests()
{
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@@ -96,7 +82,7 @@ scoped_ptr<LayerImpl> createTreeForFixedPositionTests()
scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3);
scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(4);
- WebTransformationMatrix IdentityMatrix;
+ gfx::Transform IdentityMatrix;
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
gfx::Size bounds(100, 100);
@@ -160,7 +146,7 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForNoOpLayer)
parent->addChild(child);
child->addChild(grandChild);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false);
setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false);
@@ -175,7 +161,7 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForNoOpLayer)
TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer)
{
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
scoped_refptr<Layer> layer = Layer::create();
scoped_refptr<Layer> root = Layer::create();
@@ -183,17 +169,17 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer)
root->addChild(layer);
// Case 1: setting the sublayer transform should not affect this layer's draw transform or screen-space transform.
- WebTransformationMatrix arbitraryTranslation;
- arbitraryTranslation.translate(10, 20);
+ gfx::Transform arbitraryTranslation;
+ arbitraryTranslation.Translate(10, 20);
setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslation, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedDrawTransform = identityMatrix;
+ gfx::Transform expectedDrawTransform = identityMatrix;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform());
// Case 2: Setting the bounds of the layer should not affect either the draw transform or the screenspace transform.
- WebTransformationMatrix translationToCenter;
- translationToCenter.translate(5, 6);
+ gfx::Transform translationToCenter;
+ translationToCenter.Translate(5, 6);
setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false);
executeCalculateDrawTransformsAndVisibility(root.get());
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform());
@@ -206,8 +192,8 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer)
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform());
// Case 4: A change in actual position affects both the draw transform and screen space transform.
- WebTransformationMatrix positionTransform;
- positionTransform.translate(0, 1.2);
+ gfx::Transform positionTransform;
+ positionTransform.Translate(0, 1.2);
setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false);
executeCalculateDrawTransformsAndVisibility(root.get());
EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->drawTransform());
@@ -215,17 +201,17 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer)
// Case 5: In the correct sequence of transforms, the layer transform should pre-multiply the translationToCenter. This is easily tested by
// using a scale transform, because scale and translation are not commutative.
- WebTransformationMatrix layerTransform;
- layerTransform.scale3d(2, 2, 1);
+ gfx::Transform layerTransform;
+ layerTransform.Scale3d(2, 2, 1);
setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false);
executeCalculateDrawTransformsAndVisibility(root.get());
EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform());
// Case 6: The layer transform should occur with respect to the anchor point.
- WebTransformationMatrix translationToAnchor;
- translationToAnchor.translate(5, 0);
- WebTransformationMatrix expectedResult = translationToAnchor * layerTransform * translationToAnchor.inverse();
+ gfx::Transform translationToAnchor;
+ translationToAnchor.Translate(5, 0);
+ gfx::Transform expectedResult = translationToAnchor * layerTransform * MathUtil::inverse(translationToAnchor);
setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gfx::PointF(0.5, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false);
executeCalculateDrawTransformsAndVisibility(root.get());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform());
@@ -234,7 +220,7 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer)
// Case 7: Verify that position pre-multiplies the layer transform.
// The current implementation of calculateDrawTransforms does this implicitly, but it is
// still worth testing to detect accidental regressions.
- expectedResult = positionTransform * translationToAnchor * layerTransform * translationToAnchor.inverse();
+ expectedResult = positionTransform * translationToAnchor * layerTransform * MathUtil::inverse(translationToAnchor);
setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gfx::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false);
executeCalculateDrawTransformsAndVisibility(root.get());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform());
@@ -243,7 +229,7 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer)
TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
{
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
scoped_refptr<Layer> root = Layer::create();
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<Layer> child = Layer::create();
@@ -266,8 +252,8 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTransform());
// Case 2: parent's position affects child and grandChild.
- WebTransformationMatrix parentPositionTransform;
- parentPositionTransform.translate(0, 1.2);
+ gfx::Transform parentPositionTransform;
+ parentPositionTransform.Translate(0, 1.2);
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false);
setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false);
@@ -278,11 +264,11 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenSpaceTransform());
// Case 3: parent's local transform affects child and grandchild
- WebTransformationMatrix parentLayerTransform;
- parentLayerTransform.scale3d(2, 2, 1);
- WebTransformationMatrix parentTranslationToAnchor;
- parentTranslationToAnchor.translate(2.5, 3);
- WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse();
+ gfx::Transform parentLayerTransform;
+ parentLayerTransform.Scale3d(2, 2, 1);
+ gfx::Transform parentTranslationToAnchor;
+ parentTranslationToAnchor.Translate(2.5, 3);
+ gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * MathUtil::inverse(parentTranslationToAnchor);
setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false);
setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false);
@@ -296,14 +282,14 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
// scaling is used here again so that the correct sequence of transforms is properly tested.
// Note that preserves3D is false, but the sublayer matrix should retain its 3D properties when given to child.
// But then, the child also does not preserve3D. When it gives its hierarchy to the grandChild, it should be flattened to 2D.
- WebTransformationMatrix parentSublayerMatrix;
- parentSublayerMatrix.scale3d(10, 10, 3.3);
- WebTransformationMatrix parentTranslationToCenter;
- parentTranslationToCenter.translate(5, 6);
+ gfx::Transform parentSublayerMatrix;
+ parentSublayerMatrix.Scale3d(10, 10, 3.3);
+ gfx::Transform parentTranslationToCenter;
+ parentTranslationToCenter.Translate(5, 6);
// Sublayer matrix is applied to the center of the parent layer.
- parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
- * parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse();
- WebTransformationMatrix flattenedCompositeTransform = remove3DComponentOfMatrix(parentCompositeTransform);
+ parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * MathUtil::inverse(parentTranslationToAnchor)
+ * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inverse(parentTranslationToCenter);
+ gfx::Transform flattenedCompositeTransform = MathUtil::to2dTransform(parentCompositeTransform);
setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false);
setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false);
@@ -336,26 +322,26 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface)
child->addChild(grandChild);
// One-time setup of root layer
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false);
// Child is set up so that a new render surface should be created.
child->setOpacity(0.5);
- WebTransformationMatrix parentLayerTransform;
- parentLayerTransform.scale3d(1, 0.9, 1);
- WebTransformationMatrix parentTranslationToAnchor;
- parentTranslationToAnchor.translate(25, 30);
- WebTransformationMatrix parentSublayerMatrix;
- parentSublayerMatrix.scale3d(0.9, 1, 3.3);
- WebTransformationMatrix parentTranslationToCenter;
- parentTranslationToCenter.translate(50, 60);
- WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
- * parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse();
+ gfx::Transform parentLayerTransform;
+ parentLayerTransform.Scale3d(1, 0.9, 1);
+ gfx::Transform parentTranslationToAnchor;
+ parentTranslationToAnchor.Translate(25, 30);
+ gfx::Transform parentSublayerMatrix;
+ parentSublayerMatrix.Scale3d(0.9, 1, 3.3);
+ gfx::Transform parentTranslationToCenter;
+ parentTranslationToCenter.Translate(50, 60);
+ gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * MathUtil::inverse(parentTranslationToAnchor)
+ * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inverse(parentTranslationToCenter);
gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleComponents(parentCompositeTransform);
- WebTransformationMatrix surfaceSublayerTransform;
- surfaceSublayerTransform.scaleNonUniform(parentCompositeScale.x(), parentCompositeScale.y());
- WebTransformationMatrix surfaceSublayerCompositeTransform = parentCompositeTransform * surfaceSublayerTransform.inverse();
+ gfx::Transform surfaceSublayerTransform;
+ surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScale.y());
+ gfx::Transform surfaceSublayerCompositeTransform = parentCompositeTransform * MathUtil::inverse(surfaceSublayerTransform);
// Child's render surface should not exist yet.
ASSERT_FALSE(child->renderSurface());
@@ -395,30 +381,30 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForReplica)
child->setReplicaLayer(childReplica.get());
// One-time setup of root layer
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false);
// Child is set up so that a new render surface should be created.
child->setOpacity(0.5);
- WebTransformationMatrix parentLayerTransform;
- parentLayerTransform.scale3d(2, 2, 1);
- WebTransformationMatrix parentTranslationToAnchor;
- parentTranslationToAnchor.translate(2.5, 3);
- WebTransformationMatrix parentSublayerMatrix;
- parentSublayerMatrix.scale3d(10, 10, 3.3);
- WebTransformationMatrix parentTranslationToCenter;
- parentTranslationToCenter.translate(5, 6);
- WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
- * parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse();
- WebTransformationMatrix childTranslationToCenter;
- childTranslationToCenter.translate(8, 9);
- WebTransformationMatrix replicaLayerTransform;
- replicaLayerTransform.scale3d(3, 3, 1);
+ gfx::Transform parentLayerTransform;
+ parentLayerTransform.Scale3d(2, 2, 1);
+ gfx::Transform parentTranslationToAnchor;
+ parentTranslationToAnchor.Translate(2.5, 3);
+ gfx::Transform parentSublayerMatrix;
+ parentSublayerMatrix.Scale3d(10, 10, 3.3);
+ gfx::Transform parentTranslationToCenter;
+ parentTranslationToCenter.Translate(5, 6);
+ gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * MathUtil::inverse(parentTranslationToAnchor)
+ * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inverse(parentTranslationToCenter);
+ gfx::Transform childTranslationToCenter;
+ childTranslationToCenter.Translate(8, 9);
+ gfx::Transform replicaLayerTransform;
+ replicaLayerTransform.Scale3d(3, 3, 1);
gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleComponents(parentCompositeTransform);
- WebTransformationMatrix surfaceSublayerTransform;
- surfaceSublayerTransform.scaleNonUniform(parentCompositeScale.x(), parentCompositeScale.y());
- WebTransformationMatrix replicaCompositeTransform = parentCompositeTransform * replicaLayerTransform * surfaceSublayerTransform.inverse();
+ gfx::Transform surfaceSublayerTransform;
+ surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScale.y());
+ gfx::Transform replicaCompositeTransform = parentCompositeTransform * replicaLayerTransform * MathUtil::inverse(surfaceSublayerTransform);
// Child's render surface should not exist yet.
ASSERT_FALSE(child->renderSurface());
@@ -475,7 +461,7 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy)
renderSurface2->setOpacity(0.33f);
// One-time setup of root layer
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false);
// All layers in the tree are initialized with an anchor at .25 and a size of (10,10).
@@ -485,38 +471,38 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy)
//
// x component tests that layerTransform and sublayerTransform are done in the right order (translation and scale are noncommutative).
// y component has a translation by 1 for every ancestor, which indicates the "depth" of the layer in the hierarchy.
- WebTransformationMatrix translationToAnchor;
- translationToAnchor.translate(2.5, 0);
- WebTransformationMatrix translationToCenter;
- translationToCenter.translate(5, 5);
- WebTransformationMatrix layerTransform;
- layerTransform.translate(1, 1);
- WebTransformationMatrix sublayerTransform;
- sublayerTransform.scale3d(10, 1, 1);
- WebTransformationMatrix replicaLayerTransform;
- replicaLayerTransform.scale3d(-2, 5, 1);
-
- WebTransformationMatrix A = translationToAnchor * layerTransform * translationToAnchor.inverse();
- WebTransformationMatrix B = translationToCenter * sublayerTransform * translationToCenter.inverse();
- WebTransformationMatrix R = A * translationToAnchor * replicaLayerTransform * translationToAnchor.inverse();
+ gfx::Transform translationToAnchor;
+ translationToAnchor.Translate(2.5, 0);
+ gfx::Transform translationToCenter;
+ translationToCenter.Translate(5, 5);
+ gfx::Transform layerTransform;
+ layerTransform.Translate(1, 1);
+ gfx::Transform sublayerTransform;
+ sublayerTransform.Scale3d(10, 1, 1);
+ gfx::Transform replicaLayerTransform;
+ replicaLayerTransform.Scale3d(-2, 5, 1);
+
+ gfx::Transform A = translationToAnchor * layerTransform * MathUtil::inverse(translationToAnchor);
+ gfx::Transform B = translationToCenter * sublayerTransform * MathUtil::inverse(translationToCenter);
+ gfx::Transform R = A * translationToAnchor * replicaLayerTransform * MathUtil::inverse(translationToAnchor);
gfx::Vector2dF surface1ParentTransformScale = MathUtil::computeTransform2dScaleComponents(A * B);
- WebTransformationMatrix surface1SublayerTransform;
- surface1SublayerTransform.scaleNonUniform(surface1ParentTransformScale.x(), surface1ParentTransformScale.y());
+ gfx::Transform surface1SublayerTransform;
+ surface1SublayerTransform.Scale(surface1ParentTransformScale.x(), surface1ParentTransformScale.y());
// SS1 = transform given to the subtree of renderSurface1
- WebTransformationMatrix SS1 = surface1SublayerTransform;
+ gfx::Transform SS1 = surface1SublayerTransform;
// S1 = transform to move from renderSurface1 pixels to the layer space of the owning layer
- WebTransformationMatrix S1 = surface1SublayerTransform.inverse();
+ gfx::Transform S1 = MathUtil::inverse(surface1SublayerTransform);
gfx::Vector2dF surface2ParentTransformScale = MathUtil::computeTransform2dScaleComponents(SS1 * A * B);
- WebTransformationMatrix surface2SublayerTransform;
- surface2SublayerTransform.scaleNonUniform(surface2ParentTransformScale.x(), surface2ParentTransformScale.y());
+ gfx::Transform surface2SublayerTransform;
+ surface2SublayerTransform.Scale(surface2ParentTransformScale.x(), surface2ParentTransformScale.y());
// SS2 = transform given to the subtree of renderSurface2
- WebTransformationMatrix SS2 = surface2SublayerTransform;
+ gfx::Transform SS2 = surface2SublayerTransform;
// S2 = transform to move from renderSurface2 pixels to the layer space of the owning layer
- WebTransformationMatrix S2 = surface2SublayerTransform.inverse();
+ gfx::Transform S2 = MathUtil::inverse(surface2SublayerTransform);
setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false);
setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false);
@@ -606,17 +592,17 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy)
// Sanity check. If these fail there is probably a bug in the test itself.
// It is expected that we correctly set up transforms so that the y-component of the screen-space transform
// encodes the "depth" of the layer in the tree.
- EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42());
+ EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42());
+ EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42());
+ EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().matrix().getDouble(1, 3));
}
TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer)
@@ -630,10 +616,10 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer)
scoped_refptr<Layer> child = Layer::create();
scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(new LayerWithForcedDrawsContent());
- WebTransformationMatrix rotationAboutYAxis;
- rotationAboutYAxis.rotate3d(0, 30, 0);
+ gfx::Transform rotationAboutYAxis;
+ MathUtil::rotateEulerAngles(&rotationAboutYAxis, 0, 30, 0);
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
@@ -647,10 +633,10 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer)
ASSERT_FALSE(child->preserves3D());
ASSERT_FALSE(grandChild->preserves3D());
- WebTransformationMatrix expectedChildDrawTransform = rotationAboutYAxis;
- WebTransformationMatrix expectedChildScreenSpaceTransform = rotationAboutYAxis;
- WebTransformationMatrix expectedGrandChildDrawTransform = rotationAboutYAxis; // draws onto child's renderSurface
- WebTransformationMatrix expectedGrandChildScreenSpaceTransform = rotationAboutYAxis.to2dTransform() * rotationAboutYAxis;
+ gfx::Transform expectedChildDrawTransform = rotationAboutYAxis;
+ gfx::Transform expectedChildScreenSpaceTransform = rotationAboutYAxis;
+ gfx::Transform expectedGrandChildDrawTransform = rotationAboutYAxis; // draws onto child's renderSurface
+ gfx::Transform expectedGrandChildScreenSpaceTransform = MathUtil::to2dTransform(rotationAboutYAxis) * rotationAboutYAxis;
executeCalculateDrawTransformsAndVisibility(root.get());
@@ -677,7 +663,7 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer)
scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(new LayerWithForcedDrawsContent());
// The child height is zero, but has non-zero width that should be accounted for while computing drawTransforms.
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 0), false);
setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
@@ -700,7 +686,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped
scoped_refptr<Layer> renderSurface1 = Layer::create();
scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new LayerWithForcedDrawsContent());
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false);
@@ -728,7 +714,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild)
scoped_refptr<Layer> renderSurface1 = Layer::create();
scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new LayerWithForcedDrawsContent());
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
@@ -757,7 +743,7 @@ TEST(LayerTreeHostCommonTest, verifyForceRenderSurface)
scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new LayerWithForcedDrawsContent());
renderSurface1->setForceRenderSurface(true);
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false);
@@ -801,8 +787,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedChildTransform;
- WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform;
+ gfx::Transform expectedChildTransform;
+ gfx::Transform expectedGrandChildTransform = expectedChildTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -812,8 +798,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected.
- expectedChildTransform.makeIdentity();
- expectedChildTransform.translate(-10, -10);
+ expectedChildTransform.MakeIdentity();
+ expectedChildTransform.Translate(-10, -10);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -826,7 +812,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
// In this case, the fixed position element inherits the container's transform,
// but the scrollDelta that has to be undone should not be affected by that transform.
//
- // Transforms are in general non-commutative; using something like a non-uniform scale
+ // gfx::Transforms are in general non-commutative; using something like a non-uniform scale
// helps to verify that translations and non-uniform scales are applied in the correct
// order.
scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
@@ -834,8 +820,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
LayerImpl* grandChild = child->children()[0];
// This scale will cause child and grandChild to be effectively 200 x 800 with respect to the renderTarget.
- WebTransformationMatrix nonUniformScale;
- nonUniformScale.scaleNonUniform(2, 8);
+ gfx::Transform nonUniformScale;
+ nonUniformScale.Scale(2, 8);
child->setTransform(nonUniformScale);
child->setIsContainerForFixedPositionLayers(true);
@@ -845,10 +831,10 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedChildTransform;
- expectedChildTransform.multiply(nonUniformScale);
+ gfx::Transform expectedChildTransform;
+ expectedChildTransform.PreconcatTransform(nonUniformScale);
- WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform;
+ gfx::Transform expectedGrandChildTransform = expectedChildTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -858,9 +844,9 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
executeCalculateDrawTransformsAndVisibility(root.get());
// The child should be affected by scrollDelta, but the fixed position grandChild should not be affected.
- expectedChildTransform.makeIdentity();
- expectedChildTransform.translate(-10, -20); // scrollDelta
- expectedChildTransform.multiply(nonUniformScale);
+ expectedChildTransform.MakeIdentity();
+ expectedChildTransform.Translate(-10, -20); // scrollDelta
+ expectedChildTransform.PreconcatTransform(nonUniformScale);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -883,11 +869,11 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedChildTransform;
- WebTransformationMatrix expectedGrandChildTransform;
- expectedGrandChildTransform.translate(8, 6);
+ gfx::Transform expectedChildTransform;
+ gfx::Transform expectedGrandChildTransform;
+ expectedGrandChildTransform.Translate(8, 6);
- WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChildTransform;
+ gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -898,10 +884,10 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
- expectedChildTransform.makeIdentity();
- expectedChildTransform.translate(-10, -10);
- expectedGrandChildTransform.makeIdentity();
- expectedGrandChildTransform.translate(-2, -4);
+ expectedChildTransform.MakeIdentity();
+ expectedChildTransform.Translate(-10, -10);
+ expectedGrandChildTransform.MakeIdentity();
+ expectedGrandChildTransform.Translate(-2, -4);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
@@ -917,8 +903,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
LayerImpl* grandChild = child->children()[0];
LayerImpl* greatGrandChild = grandChild->children()[0];
- WebTransformationMatrix rotationAboutZ;
- rotationAboutZ.rotate3d(0, 0, 90);
+ gfx::Transform rotationAboutZ;
+ MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90);
child->setIsContainerForFixedPositionLayers(true);
child->setTransform(rotationAboutZ);
@@ -930,15 +916,15 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedChildTransform;
- expectedChildTransform.multiply(rotationAboutZ);
+ gfx::Transform expectedChildTransform;
+ expectedChildTransform.PreconcatTransform(rotationAboutZ);
- WebTransformationMatrix expectedGrandChildTransform;
- expectedGrandChildTransform.multiply(rotationAboutZ); // child's local transform is inherited
- expectedGrandChildTransform.translate(8, 6); // translation because of position occurs before layer's local transform.
- expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
+ gfx::Transform expectedGrandChildTransform;
+ expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's local transform is inherited
+ expectedGrandChildTransform.Translate(8, 6); // translation because of position occurs before layer's local transform.
+ expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChild's local transform
- WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChildTransform;
+ gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -949,15 +935,15 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
- expectedChildTransform.makeIdentity();
- expectedChildTransform.translate(-10, -20); // scrollDelta
- expectedChildTransform.multiply(rotationAboutZ);
+ expectedChildTransform.MakeIdentity();
+ expectedChildTransform.Translate(-10, -20); // scrollDelta
+ expectedChildTransform.PreconcatTransform(rotationAboutZ);
- expectedGrandChildTransform.makeIdentity();
- expectedGrandChildTransform.translate(-10, -20); // child's scrollDelta is inherited
- expectedGrandChildTransform.multiply(rotationAboutZ); // child's local transform is inherited
- expectedGrandChildTransform.translate(8, 6); // translation because of position occurs before layer's local transform.
- expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
+ expectedGrandChildTransform.MakeIdentity();
+ expectedGrandChildTransform.Translate(-10, -20); // child's scrollDelta is inherited
+ expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's local transform is inherited
+ expectedGrandChildTransform.Translate(8, 6); // translation because of position occurs before layer's local transform.
+ expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChild's local transform
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -977,8 +963,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
LayerImpl* grandChild = child->children()[0];
LayerImpl* greatGrandChild = grandChild->children()[0];
- WebTransformationMatrix rotationAboutZ;
- rotationAboutZ.rotate3d(0, 0, 90);
+ gfx::Transform rotationAboutZ;
+ MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90);
child->setIsContainerForFixedPositionLayers(true);
child->setTransform(rotationAboutZ);
@@ -990,15 +976,15 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedChildTransform;
- expectedChildTransform.multiply(rotationAboutZ);
+ gfx::Transform expectedChildTransform;
+ expectedChildTransform.PreconcatTransform(rotationAboutZ);
- WebTransformationMatrix expectedGrandChildTransform;
- expectedGrandChildTransform.multiply(rotationAboutZ); // child's local transform is inherited
- expectedGrandChildTransform.translate(8, 6); // translation because of position occurs before layer's local transform.
- expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
+ gfx::Transform expectedGrandChildTransform;
+ expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's local transform is inherited
+ expectedGrandChildTransform.Translate(8, 6); // translation because of position occurs before layer's local transform.
+ expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChild's local transform
- WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChildTransform;
+ gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -1010,16 +996,16 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
- expectedChildTransform.makeIdentity();
- expectedChildTransform.translate(-10, 0); // scrollDelta
- expectedChildTransform.multiply(rotationAboutZ);
+ expectedChildTransform.MakeIdentity();
+ expectedChildTransform.Translate(-10, 0); // scrollDelta
+ expectedChildTransform.PreconcatTransform(rotationAboutZ);
- expectedGrandChildTransform.makeIdentity();
- expectedGrandChildTransform.translate(-10, 0); // child's scrollDelta is inherited
- expectedGrandChildTransform.multiply(rotationAboutZ); // child's local transform is inherited
- expectedGrandChildTransform.translate(-5, 0); // grandChild's scrollDelta
- expectedGrandChildTransform.translate(8, 6); // translation because of position occurs before layer's local transform.
- expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
+ expectedGrandChildTransform.MakeIdentity();
+ expectedGrandChildTransform.Translate(-10, 0); // child's scrollDelta is inherited
+ expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's local transform is inherited
+ expectedGrandChildTransform.Translate(-5, 0); // grandChild's scrollDelta
+ expectedGrandChildTransform.Translate(8, 6); // translation because of position occurs before layer's local transform.
+ expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChild's local transform
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -1043,20 +1029,20 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
greatGrandChild->setFixedToContainerLayer(true);
greatGrandChild->setDrawsContent(true);
- WebTransformationMatrix rotationAboutZ;
- rotationAboutZ.rotate3d(0, 0, 90);
+ gfx::Transform rotationAboutZ;
+ MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90);
grandChild->setTransform(rotationAboutZ);
// Case 1: scrollDelta of 0, 0
child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedChildTransform;
- WebTransformationMatrix expectedSurfaceDrawTransform;
- expectedSurfaceDrawTransform.translate(8, 6);
- expectedSurfaceDrawTransform.multiply(rotationAboutZ);
- WebTransformationMatrix expectedGrandChildTransform;
- WebTransformationMatrix expectedGreatGrandChildTransform;
+ gfx::Transform expectedChildTransform;
+ gfx::Transform expectedSurfaceDrawTransform;
+ expectedSurfaceDrawTransform.Translate(8, 6);
+ expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ);
+ gfx::Transform expectedGrandChildTransform;
+ gfx::Transform expectedGreatGrandChildTransform;
ASSERT_TRUE(grandChild->renderSurface());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->renderSurface()->drawTransform());
@@ -1074,21 +1060,21 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
// that surface. So, the net result is that, unlike previous tests where the fixed
// position layer's transform remains unchanged, here the fixed position layer's
// transform explicitly contains the translation that cancels out the scroll.
- expectedChildTransform.makeIdentity();
- expectedChildTransform.translate(-10, -30); // scrollDelta
+ expectedChildTransform.MakeIdentity();
+ expectedChildTransform.Translate(-10, -30); // scrollDelta
- expectedSurfaceDrawTransform.makeIdentity();
- expectedSurfaceDrawTransform.translate(-10, -30); // scrollDelta
- expectedSurfaceDrawTransform.translate(8, 6);
- expectedSurfaceDrawTransform.multiply(rotationAboutZ);
+ expectedSurfaceDrawTransform.MakeIdentity();
+ expectedSurfaceDrawTransform.Translate(-10, -30); // scrollDelta
+ expectedSurfaceDrawTransform.Translate(8, 6);
+ expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ);
// The rotation and its inverse are needed to place the scrollDelta compensation in
// the correct space. This test will fail if the rotation/inverse are backwards, too,
// so it requires perfect order of operations.
- expectedGreatGrandChildTransform.makeIdentity();
- expectedGreatGrandChildTransform.multiply(rotationAboutZ.inverse());
- expectedGreatGrandChildTransform.translate(10, 30); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface.
- expectedGreatGrandChildTransform.multiply(rotationAboutZ);
+ expectedGreatGrandChildTransform.MakeIdentity();
+ expectedGreatGrandChildTransform.PreconcatTransform(MathUtil::inverse(rotationAboutZ));
+ expectedGreatGrandChildTransform.Translate(10, 30); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface.
+ expectedGreatGrandChildTransform.PreconcatTransform(rotationAboutZ);
ASSERT_TRUE(grandChild->renderSurface());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
@@ -1110,7 +1096,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
// Add one more layer to the test tree for this scenario.
{
- WebTransformationMatrix identity;
+ gfx::Transform identity;
scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(5);
setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identity, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
greatGrandChild->addChild(fixedPositionChild.Pass());
@@ -1130,10 +1116,10 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
// verify that we have correct order-of-operations in the final scroll compensation.
// Note that rotating about the center of the layer ensures we do not accidentally
// clip away layers that we want to test.
- WebTransformationMatrix rotationAboutZ;
- rotationAboutZ.translate(50, 50);
- rotationAboutZ.rotate3d(0, 0, 90);
- rotationAboutZ.translate(-50, -50);
+ gfx::Transform rotationAboutZ;
+ rotationAboutZ.Translate(50, 50);
+ MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90);
+ rotationAboutZ.Translate(-50, -50);
grandChild->setTransform(rotationAboutZ);
greatGrandChild->setTransform(rotationAboutZ);
@@ -1141,21 +1127,21 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedChildTransform;
+ gfx::Transform expectedChildTransform;
- WebTransformationMatrix expectedGrandChildSurfaceDrawTransform;
- expectedGrandChildSurfaceDrawTransform.translate(8, 6);
- expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ);
+ gfx::Transform expectedGrandChildSurfaceDrawTransform;
+ expectedGrandChildSurfaceDrawTransform.Translate(8, 6);
+ expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ);
- WebTransformationMatrix expectedGrandChildTransform;
+ gfx::Transform expectedGrandChildTransform;
- WebTransformationMatrix expectedGreatGrandChildSurfaceDrawTransform;
- expectedGreatGrandChildSurfaceDrawTransform.translate(40, 60);
- expectedGreatGrandChildSurfaceDrawTransform.multiply(rotationAboutZ);
+ gfx::Transform expectedGreatGrandChildSurfaceDrawTransform;
+ expectedGreatGrandChildSurfaceDrawTransform.Translate(40, 60);
+ expectedGreatGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ);
- WebTransformationMatrix expectedGreatGrandChildTransform;
+ gfx::Transform expectedGreatGrandChildTransform;
- WebTransformationMatrix expectedFixedPositionChildTransform;
+ gfx::Transform expectedFixedPositionChildTransform;
ASSERT_TRUE(grandChild->renderSurface());
ASSERT_TRUE(greatGrandChild->renderSurface());
@@ -1170,13 +1156,13 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
child->setScrollDelta(gfx::Vector2d(10, 30));
executeCalculateDrawTransformsAndVisibility(root.get());
- expectedChildTransform.makeIdentity();
- expectedChildTransform.translate(-10, -30); // scrollDelta
+ expectedChildTransform.MakeIdentity();
+ expectedChildTransform.Translate(-10, -30); // scrollDelta
- expectedGrandChildSurfaceDrawTransform.makeIdentity();
- expectedGrandChildSurfaceDrawTransform.translate(-10, -30); // scrollDelta
- expectedGrandChildSurfaceDrawTransform.translate(8, 6);
- expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ);
+ expectedGrandChildSurfaceDrawTransform.MakeIdentity();
+ expectedGrandChildSurfaceDrawTransform.Translate(-10, -30); // scrollDelta
+ expectedGrandChildSurfaceDrawTransform.Translate(8, 6);
+ expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ);
// grandChild, greatGrandChild, and greatGrandChild's surface are not expected to
// change, since they are all not fixed, and they are all drawn with respect to
@@ -1185,16 +1171,16 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
// But the great-great grandchild, "fixedPositionChild", should have a transform that explicitly cancels out the scrollDelta.
// The expected transform is:
// compoundDrawTransform.inverse() * translate(positive scrollDelta) * compoundOriginTransform
- WebTransformationMatrix compoundDrawTransform; // transform from greatGrandChildSurface's origin to the root surface.
- compoundDrawTransform.translate(8, 6); // origin translation of grandChild
- compoundDrawTransform.multiply(rotationAboutZ); // rotation of grandChild
- compoundDrawTransform.translate(40, 60); // origin translation of greatGrandChild
- compoundDrawTransform.multiply(rotationAboutZ); // rotation of greatGrandChild
+ gfx::Transform compoundDrawTransform; // transform from greatGrandChildSurface's origin to the root surface.
+ compoundDrawTransform.Translate(8, 6); // origin translation of grandChild
+ compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of grandChild
+ compoundDrawTransform.Translate(40, 60); // origin translation of greatGrandChild
+ compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of greatGrandChild
- expectedFixedPositionChildTransform.makeIdentity();
- expectedFixedPositionChildTransform.multiply(compoundDrawTransform.inverse());
- expectedFixedPositionChildTransform.translate(10, 30); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface.
- expectedFixedPositionChildTransform.multiply(compoundDrawTransform);
+ expectedFixedPositionChildTransform.MakeIdentity();
+ expectedFixedPositionChildTransform.PreconcatTransform(MathUtil::inverse(compoundDrawTransform));
+ expectedFixedPositionChildTransform.Translate(10, 30); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface.
+ expectedFixedPositionChildTransform.PreconcatTransform(compoundDrawTransform);
ASSERT_TRUE(grandChild->renderSurface());
ASSERT_TRUE(greatGrandChild->renderSurface());
@@ -1225,10 +1211,10 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedSurfaceDrawTransform;
- expectedSurfaceDrawTransform.translate(0, 0);
- WebTransformationMatrix expectedChildTransform;
- WebTransformationMatrix expectedGrandChildTransform;
+ gfx::Transform expectedSurfaceDrawTransform;
+ expectedSurfaceDrawTransform.Translate(0, 0);
+ gfx::Transform expectedChildTransform;
+ gfx::Transform expectedGrandChildTransform;
ASSERT_TRUE(child->renderSurface());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderSurface()->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
@@ -1241,10 +1227,10 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
// The surface is translated by scrollDelta, the child transform doesn't change
// because it scrolls along with the surface, but the fixed position grandChild
// needs to compensate for the scroll translation.
- expectedSurfaceDrawTransform.makeIdentity();
- expectedSurfaceDrawTransform.translate(-10, -10);
- expectedGrandChildTransform.makeIdentity();
- expectedGrandChildTransform.translate(10, 10);
+ expectedSurfaceDrawTransform.MakeIdentity();
+ expectedSurfaceDrawTransform.Translate(-10, -10);
+ expectedGrandChildTransform.MakeIdentity();
+ expectedGrandChildTransform.Translate(10, 10);
ASSERT_TRUE(child->renderSurface());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderSurface()->drawTransform());
@@ -1271,8 +1257,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix expectedChildTransform;
- WebTransformationMatrix expectedGrandChildTransform;
+ gfx::Transform expectedChildTransform;
+ gfx::Transform expectedGrandChildTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -1281,8 +1267,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected.
- expectedChildTransform.makeIdentity();
- expectedChildTransform.translate(-10, -10);
+ expectedChildTransform.MakeIdentity();
+ expectedChildTransform.Translate(-10, -10);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
}
@@ -1296,8 +1282,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
LayerImpl* child = root->children()[0];
LayerImpl* grandChild = child->children()[0];
- WebTransformationMatrix rotationByZ;
- rotationByZ.rotate3d(0, 0, 90);
+ gfx::Transform rotationByZ;
+ MathUtil::rotateEulerAngles(&rotationByZ, 0, 0, 90);
root->setTransform(rotationByZ);
grandChild->setFixedToContainerLayer(true);
@@ -1306,7 +1292,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
root->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get());
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform());
@@ -1319,10 +1305,10 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
// the child's target surface (i.e. the root renderSurface). The grandChild is not
// affected by the scrollDelta, so its drawTransform needs to explicitly
// inverse-compensate for the scroll that's embedded in the target surface.
- WebTransformationMatrix expectedGrandChildTransform;
- expectedGrandChildTransform.multiply(rotationByZ.inverse());
- expectedGrandChildTransform.translate(10, 20); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface.
- expectedGrandChildTransform.multiply(rotationByZ);
+ gfx::Transform expectedGrandChildTransform;
+ expectedGrandChildTransform.PreconcatTransform(MathUtil::inverse(rotationByZ));
+ expectedGrandChildTransform.Translate(10, 20); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface.
+ expectedGrandChildTransform.PreconcatTransform(rotationByZ);
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -1344,7 +1330,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces)
// clipRect, and they should never get scheduled on the list of renderSurfaces.
//
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<Layer> child = Layer::create();
scoped_refptr<Layer> grandChild = Layer::create();
@@ -1399,7 +1385,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent)
// this clipping should be avoided and we should keep the grandChild
// in the renderSurfaceLayerList.
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<Layer> child = Layer::create();
scoped_refptr<Layer> grandChild = Layer::create();
@@ -1457,7 +1443,7 @@ TEST(LayerTreeHostCommonTest, verifyIsClippedIsSetCorrectly)
// - but if the layer itself masks to bounds, it is considered clipped
// and propagates the clip to the subtree.
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
scoped_refptr<Layer> root = Layer::create();
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<Layer> child1 = Layer::create();
@@ -1552,7 +1538,7 @@ TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers)
// grandChild4 - outside parent's clipRect; the drawableContentRect should be empty.
//
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<Layer> child = Layer::create();
scoped_refptr<Layer> grandChild1 = Layer::create();
@@ -1602,7 +1588,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces)
// have a clipRect of their own layer bounds, however, if masksToBounds was true.
//
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<Layer> child = Layer::create();
scoped_refptr<Layer> grandChild1 = Layer::create();
@@ -1693,10 +1679,10 @@ TEST(LayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy)
// Also put an animated opacity on a layer without descendants.
addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController(), 10, 1, 0, false);
- WebTransformationMatrix layerTransform;
- layerTransform.translate(1, 1);
- WebTransformationMatrix sublayerTransform;
- sublayerTransform.scale3d(10, 1, 1);
+ gfx::Transform layerTransform;
+ layerTransform.Translate(1, 1);
+ gfx::Transform sublayerTransform;
+ sublayerTransform.Scale3d(10, 1, 1);
// Put a transform animation on the render surface.
addAnimatedTransformToController(*renderSurface2->layerAnimationController(), 10, 30, 0);
@@ -1791,17 +1777,17 @@ TEST(LayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy)
// Sanity check. If these fail there is probably a bug in the test itself.
// It is expected that we correctly set up transforms so that the y-component of the screen-space transform
// encodes the "depth" of the layer in the tree.
- EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42());
+ EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42());
+ EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42());
- EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42());
+ EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().matrix().getDouble(1, 3));
}
TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform)
@@ -1809,7 +1795,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform)
// Test the calculateVisibleRect() function works correctly for identity transforms.
gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
- WebTransformationMatrix layerToSurfaceTransform;
+ gfx::Transform layerToSurfaceTransform;
// Case 1: Layer is contained within the surface.
gfx::Rect layerContentRect = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30));
@@ -1835,24 +1821,24 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectForTranslations)
gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30));
- WebTransformationMatrix layerToSurfaceTransform;
+ gfx::Transform layerToSurfaceTransform;
// Case 1: Layer is contained within the surface.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.translate(10, 10);
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.Translate(10, 10);
gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30));
gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_RECT_EQ(expected, actual);
// Case 2: Layer is outside the surface rect.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.translate(120, 120);
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.Translate(120, 120);
actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_TRUE(actual.IsEmpty());
// Case 3: Layer is partially overlapping the surface rect.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.translate(80, 80);
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.Translate(80, 80);
expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20));
actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_RECT_EQ(expected, actual);
@@ -1865,20 +1851,20 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations)
gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30));
- WebTransformationMatrix layerToSurfaceTransform;
+ gfx::Transform layerToSurfaceTransform;
// Case 1: Layer is contained within the surface.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.translate(50, 50);
- layerToSurfaceTransform.rotate(45);
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.Translate(50, 50);
+ layerToSurfaceTransform.Rotate(45);
gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30));
gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_RECT_EQ(expected, actual);
// Case 2: Layer is outside the surface rect.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.translate(-50, 0);
- layerToSurfaceTransform.rotate(45);
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.Translate(-50, 0);
+ layerToSurfaceTransform.Rotate(45);
actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_TRUE(actual.IsEmpty());
@@ -1887,8 +1873,8 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations)
// this case, the visible rect should still be the entire layer (remember the
// visible rect is computed in layer space); both the top-left and
// bottom-right corners of the layer are still visible.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.rotate(45);
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.Rotate(45);
expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30));
actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_RECT_EQ(expected, actual);
@@ -1898,9 +1884,9 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations)
// of the surface overlapping the layer. In layer space, the render surface
// overlaps the right side of the layer. The visible rect should be the
// layer's right half.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.translate(0, -sqrt(2.0) * 15);
- layerToSurfaceTransform.rotate(45);
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.Translate(0, -sqrt(2.0) * 15);
+ layerToSurfaceTransform.Rotate(45);
expected = gfx::Rect(gfx::Point(15, 0), gfx::Size(15, 30)); // right half of layer bounds.
actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_RECT_EQ(expected, actual);
@@ -1912,11 +1898,11 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform)
gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
- WebTransformationMatrix layerToSurfaceTransform;
+ gfx::Transform layerToSurfaceTransform;
// Case 1: Orthographic projection of a layer rotated about y-axis by 45 degrees, should be fully contained in the renderSurface.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.rotate3d(0, 45, 0);
+ layerToSurfaceTransform.MakeIdentity();
+ MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0);
gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_RECT_EQ(expected, actual);
@@ -1925,9 +1911,9 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform)
// shifted to the side so only the right-half the layer would be visible on
// the surface.
double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-rotated layer width; divided by sqrt(2) is the rotated width.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.translate(-halfWidthOfRotatedLayer, 0);
- layerToSurfaceTransform.rotate3d(0, 45, 0); // rotates about the left edge of the layer
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.Translate(-halfWidthOfRotatedLayer, 0);
+ MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); // rotates about the left edge of the layer
expected = gfx::Rect(gfx::Point(50, 0), gfx::Size(50, 100)); // right half of the layer.
actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_RECT_EQ(expected, actual);
@@ -1940,20 +1926,20 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform)
gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200));
- WebTransformationMatrix layerToSurfaceTransform;
+ gfx::Transform layerToSurfaceTransform;
// Case 1: Even though the layer is twice as large as the surface, due to perspective
// foreshortening, the layer will fit fully in the surface when its translated
// more than the perspective amount.
- layerToSurfaceTransform.makeIdentity();
+ layerToSurfaceTransform.MakeIdentity();
// The following sequence of transforms applies the perspective about the center of the surface.
- layerToSurfaceTransform.translate(50, 50);
- layerToSurfaceTransform.applyPerspective(9);
- layerToSurfaceTransform.translate(-50, -50);
+ layerToSurfaceTransform.Translate(50, 50);
+ layerToSurfaceTransform.ApplyPerspectiveDepth(9);
+ layerToSurfaceTransform.Translate(-50, -50);
// This translate places the layer in front of the surface's projection plane.
- layerToSurfaceTransform.translate3d(0, 0, -27);
+ layerToSurfaceTransform.Translate3d(0, 0, -27);
gfx::Rect expected = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200));
gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
@@ -1967,7 +1953,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform)
// Then, by similar triangles, if we want to move a layer by translating -50 units in projected surface units (so that only half of it is
// visible), then we would need to translate by (-36 / 9) * -50 == -200 in the layer's units.
//
- layerToSurfaceTransform.translate3d(-200, 0, 0);
+ layerToSurfaceTransform.Translate3d(-200, 0, 0);
expected = gfx::Rect(gfx::Point(50, -50), gfx::Size(100, 200)); // The right half of the layer's bounding rect.
actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
EXPECT_RECT_EQ(expected, actual);
@@ -1982,14 +1968,14 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBehi
gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
- WebTransformationMatrix layerToSurfaceTransform;
+ gfx::Transform layerToSurfaceTransform;
// This sequence of transforms effectively rotates the layer about the y-axis at the
// center of the layer.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.translate(50, 0);
- layerToSurfaceTransform.rotate3d(0, 45, 0);
- layerToSurfaceTransform.translate(-50, 0);
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.Translate(50, 0);
+ MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0);
+ layerToSurfaceTransform.Translate(-50, 0);
gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100));
gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
@@ -2006,16 +1992,16 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW)
gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100, 100));
gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -1), gfx::Size(20, 2));
- WebTransformationMatrix layerToSurfaceTransform;
+ gfx::Transform layerToSurfaceTransform;
// The layer is positioned so that the right half of the layer should be in front of
// the camera, while the other half is behind the surface's projection plane. The
// following sequence of transforms applies the perspective and rotation about the
// center of the layer.
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.applyPerspective(1);
- layerToSurfaceTransform.translate3d(-2, 0, 1);
- layerToSurfaceTransform.rotate3d(0, 45, 0);
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.ApplyPerspectiveDepth(1);
+ layerToSurfaceTransform.Translate3d(-2, 0, 1);
+ MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0);
// Sanity check that this transform does indeed cause w < 0 when applying the
// transform, otherwise this code is not testing the intended scenario.
@@ -2040,18 +2026,18 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection)
// This sequence of transforms causes one corner of the layer to protrude across the w = 0 plane, and should be clipped.
gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100, 100));
gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20));
- WebTransformationMatrix layerToSurfaceTransform;
- layerToSurfaceTransform.makeIdentity();
- layerToSurfaceTransform.applyPerspective(1);
- layerToSurfaceTransform.translate3d(0, 0, -5);
- layerToSurfaceTransform.rotate3d(0, 45, 0);
- layerToSurfaceTransform.rotate3d(80, 0, 0);
+ gfx::Transform layerToSurfaceTransform;
+ layerToSurfaceTransform.MakeIdentity();
+ layerToSurfaceTransform.ApplyPerspectiveDepth(1);
+ layerToSurfaceTransform.Translate3d(0, 0, -5);
+ MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0);
+ MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 80, 0, 0);
// Sanity check that un-projection does indeed cause w < 0, otherwise this code is not
// testing the intended scenario.
bool clipped = false;
gfx::RectF clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, layerContentRect);
- MathUtil::projectQuad(layerToSurfaceTransform.inverse(), gfx::QuadF(clippedRect), clipped);
+ MathUtil::projectQuad(MathUtil::inverse(layerToSurfaceTransform), gfx::QuadF(clippedRect), clipped);
ASSERT_TRUE(clipped);
// Only the corner of the layer is not visible on the surface because of being
@@ -2072,7 +2058,7 @@ TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer
root->addChild(child2);
root->addChild(child3);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false);
setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false);
@@ -2109,7 +2095,7 @@ TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersClipp
child->addChild(grandChild2);
child->addChild(grandChild3);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false);
@@ -2151,7 +2137,7 @@ TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInUnc
renderSurface1->addChild(child2);
renderSurface1->addChild(child3);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false);
setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false);
@@ -2195,7 +2181,7 @@ TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInCli
renderSurface1->addChild(child2);
renderSurface1->addChild(child3);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false);
setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false);
@@ -2245,7 +2231,7 @@ TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSurfaceHier
renderSurface2->addChild(child2);
renderSurface2->addChild(child3);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false);
setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(7, 13), false);
@@ -2300,9 +2286,9 @@ TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransformO
root->addChild(renderSurface1);
renderSurface1->addChild(child1);
- WebTransformationMatrix identityMatrix;
- WebTransformationMatrix childRotation;
- childRotation.rotate(45);
+ gfx::Transform identityMatrix;
+ gfx::Transform childRotation;
+ childRotation.Rotate(45);
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false);
setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gfx::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false);
@@ -2340,9 +2326,9 @@ TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransformO
root->addChild(renderSurface1);
renderSurface1->addChild(child1);
- WebTransformationMatrix identityMatrix;
- WebTransformationMatrix childRotation;
- childRotation.rotate(45);
+ gfx::Transform identityMatrix;
+ gfx::Transform childRotation;
+ childRotation.Rotate(45);
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false);
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false);
setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gfx::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false);
@@ -2384,7 +2370,7 @@ TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsInHighDPI)
renderSurface2->addChild(child2);
renderSurface2->addChild(child3);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(3, 4), false);
setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(7, 13), false);
@@ -2439,7 +2425,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d)
// that 3d transforms still apply in this case, but they are "flattened" to each
// parent layer according to current W3C spec.
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_refptr(new LayerWithForcedDrawsContent());
scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_refptr(new LayerWithForcedDrawsContent());
@@ -2469,16 +2455,16 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d)
frontFacingChildOfBackFacingSurface->setDoubleSided(false);
backFacingChildOfBackFacingSurface->setDoubleSided(false);
- WebTransformationMatrix backfaceMatrix;
- backfaceMatrix.translate(50, 50);
- backfaceMatrix.rotate3d(0, 1, 0, 180);
- backfaceMatrix.translate(-50, -50);
+ gfx::Transform backfaceMatrix;
+ backfaceMatrix.Translate(50, 50);
+ MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180);
+ backfaceMatrix.Translate(-50, -50);
// Having a descendant and opacity will force these to have render surfaces.
frontFacingSurface->setOpacity(0.5);
backFacingSurface->setOpacity(0.5);
- // Nothing preserves 3d. According to current W3C CSS Transforms spec, these layers
+ // Nothing preserves 3d. According to current W3C CSS gfx::Transforms spec, these layers
// should blindly use their own local transforms to determine back-face culling.
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
@@ -2531,7 +2517,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d)
{
// Verify the behavior of back-face culling when preserves-3d transform style is used.
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_refptr(new LayerWithForcedDrawsContent());
scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_refptr(new LayerWithForcedDrawsContent());
@@ -2563,10 +2549,10 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d)
frontFacingChildOfBackFacingSurface->setDoubleSided(false);
backFacingChildOfBackFacingSurface->setDoubleSided(false);
- WebTransformationMatrix backfaceMatrix;
- backfaceMatrix.translate(50, 50);
- backfaceMatrix.rotate3d(0, 1, 0, 180);
- backfaceMatrix.translate(-50, -50);
+ gfx::Transform backfaceMatrix;
+ backfaceMatrix.Translate(50, 50);
+ MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180);
+ backfaceMatrix.Translate(-50, -50);
// Opacity will not force creation of renderSurfaces in this case because of the
// preserve-3d transform style. Instead, an example of when a surface would be
@@ -2575,7 +2561,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d)
backFacingSurface->setReplicaLayer(dummyReplicaLayer2.get());
// Each surface creates its own new 3d rendering context (as defined by W3C spec).
- // According to current W3C CSS Transforms spec, layers in a 3d rendering context
+ // According to current W3C CSS gfx::Transforms spec, layers in a 3d rendering context
// should use the transform with respect to that context. This 3d rendering context
// occurs when (a) parent's transform style is flat and (b) the layer's transform
// style is preserve-3d.
@@ -2628,7 +2614,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms)
// treated as "unknown" so we can not be sure that their back face is really showing.
//
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new LayerWithForcedDrawsContent());
scoped_refptr<LayerWithForcedDrawsContent> animatingSurface = make_scoped_refptr(new LayerWithForcedDrawsContent());
@@ -2649,10 +2635,10 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms)
childOfAnimatingSurface->setDoubleSided(false);
animatingChild->setDoubleSided(false);
- WebTransformationMatrix backfaceMatrix;
- backfaceMatrix.translate(50, 50);
- backfaceMatrix.rotate3d(0, 1, 0, 180);
- backfaceMatrix.translate(-50, -50);
+ gfx::Transform backfaceMatrix;
+ backfaceMatrix.Translate(50, 50);
+ MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180);
+ backfaceMatrix.Translate(-50, -50);
// Make our render surface.
animatingSurface->setForceRenderSurface(true);
@@ -2708,7 +2694,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS
// Verify the behavior of back-face culling for a renderSurface that is created
// when it flattens its subtree, and its parent has preserves-3d.
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
scoped_refptr<Layer> parent = Layer::create();
scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_refptr(new LayerWithForcedDrawsContent());
scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_refptr(new LayerWithForcedDrawsContent());
@@ -2724,10 +2710,10 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS
frontFacingSurface->setDoubleSided(false);
backFacingSurface->setDoubleSided(false);
- WebTransformationMatrix backfaceMatrix;
- backfaceMatrix.translate(50, 50);
- backfaceMatrix.rotate3d(0, 1, 0, 180);
- backfaceMatrix.translate(-50, -50);
+ gfx::Transform backfaceMatrix;
+ backfaceMatrix.Translate(50, 50);
+ MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180);
+ backfaceMatrix.Translate(-50, -50);
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent transform style is preserve3d.
setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat.
@@ -2778,7 +2764,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer)
{
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
gfx::Size bounds(100, 100);
@@ -2818,14 +2804,14 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
{
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
- WebTransformationMatrix uninvertibleTransform;
- uninvertibleTransform.setM11(0);
- uninvertibleTransform.setM22(0);
- uninvertibleTransform.setM33(0);
- uninvertibleTransform.setM44(0);
- ASSERT_FALSE(uninvertibleTransform.isInvertible());
+ gfx::Transform uninvertibleTransform;
+ uninvertibleTransform.matrix().setDouble(0, 0, 0);
+ uninvertibleTransform.matrix().setDouble(1, 1, 0);
+ uninvertibleTransform.matrix().setDouble(2, 2, 0);
+ uninvertibleTransform.matrix().setDouble(3, 3, 0);
+ ASSERT_FALSE(uninvertibleTransform.IsInvertible());
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
gfx::Size bounds(100, 100);
@@ -2839,7 +2825,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
ASSERT_EQ(1u, root->renderSurface()->layerList().size());
- ASSERT_FALSE(root->screenSpaceTransform().isInvertible());
+ ASSERT_FALSE(root->screenSpaceTransform().IsInvertible());
// Hit testing any point should not hit the layer. If the invertible matrix is
// accidentally ignored and treated like an identity, then the hit testing will
@@ -2877,7 +2863,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer)
{
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
gfx::PointF position(50, 50); // this layer is positioned, and hit testing should correctly know where the layer is located.
gfx::Size bounds(100, 100);
@@ -2918,11 +2904,11 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer)
{
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
- WebTransformationMatrix identityMatrix;
- WebTransformationMatrix rotation45DegreesAboutCenter;
- rotation45DegreesAboutCenter.translate(50, 50);
- rotation45DegreesAboutCenter.rotate3d(0, 0, 45);
- rotation45DegreesAboutCenter.translate(-50, -50);
+ gfx::Transform identityMatrix;
+ gfx::Transform rotation45DegreesAboutCenter;
+ rotation45DegreesAboutCenter.Translate(50, 50);
+ MathUtil::rotateEulerAngles(&rotation45DegreesAboutCenter, 0, 0, 45);
+ rotation45DegreesAboutCenter.Translate(-50, -50);
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
gfx::Size bounds(100, 100);
@@ -2967,15 +2953,15 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer)
{
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
// perspectiveProjectionAboutCenter * translationByZ is designed so that the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50).
- WebTransformationMatrix perspectiveProjectionAboutCenter;
- perspectiveProjectionAboutCenter.translate(50, 50);
- perspectiveProjectionAboutCenter.applyPerspective(1);
- perspectiveProjectionAboutCenter.translate(-50, -50);
- WebTransformationMatrix translationByZ;
- translationByZ.translate3d(0, 0, -1);
+ gfx::Transform perspectiveProjectionAboutCenter;
+ perspectiveProjectionAboutCenter.Translate(50, 50);
+ perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1);
+ perspectiveProjectionAboutCenter.Translate(-50, -50);
+ gfx::Transform translationByZ;
+ translationByZ.Translate3d(0, 0, -1);
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
@@ -3027,7 +3013,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents)
//
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anchor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
@@ -3086,7 +3072,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer)
{
// Test that hit-testing will only work for the visible portion of a layer, and not
// the entire layer bounds. Here we just test the simple axis-aligned case.
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@@ -3154,7 +3140,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer)
//
scoped_ptr<LayerImpl> root = LayerImpl::create(123);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
gfx::Size bounds(100, 100);
@@ -3171,8 +3157,8 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer)
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, anchor, position, bounds, false);
child->setMasksToBounds(true);
- WebTransformationMatrix rotation45DegreesAboutCorner;
- rotation45DegreesAboutCorner.rotate3d(0, 0, 45);
+ gfx::Transform rotation45DegreesAboutCorner;
+ MathUtil::rotateEulerAngles(&rotation45DegreesAboutCorner, 0, 0, 45);
position = gfx::PointF(0, 0); // remember, positioned with respect to its parent which is already at 10, 10
bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100.
@@ -3180,12 +3166,12 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer)
grandChild->setMasksToBounds(true);
// Rotates about the center of the layer
- WebTransformationMatrix rotatedLeafTransform;
- rotatedLeafTransform.translate(-10, -10); // cancel out the grandParent's position
- rotatedLeafTransform.rotate3d(0, 0, -45); // cancel out the corner 45-degree rotation of the parent.
- rotatedLeafTransform.translate(50, 50);
- rotatedLeafTransform.rotate3d(0, 0, 45);
- rotatedLeafTransform.translate(-50, -50);
+ gfx::Transform rotatedLeafTransform;
+ rotatedLeafTransform.Translate(-10, -10); // cancel out the grandParent's position
+ MathUtil::rotateEulerAngles(&rotatedLeafTransform, 0, 0, -45); // cancel out the corner 45-degree rotation of the parent.
+ rotatedLeafTransform.Translate(50, 50);
+ MathUtil::rotateEulerAngles(&rotatedLeafTransform, 0, 0, 45);
+ rotatedLeafTransform.Translate(-50, -50);
position = gfx::PointF(0, 0);
bounds = gfx::Size(100, 100);
setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, identityMatrix, anchor, position, bounds, false);
@@ -3250,7 +3236,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer)
{
// This test checks that hit testing code does not accidentally clip to layer
// bounds for a layer that actually does not clip.
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@@ -3311,7 +3297,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers)
{
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
gfx::Size bounds(100, 100);
@@ -3414,7 +3400,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists)
//
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
gfx::Size bounds(100, 100);
@@ -3536,7 +3522,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
{
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
@@ -3592,14 +3578,14 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
{
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
- WebTransformationMatrix uninvertibleTransform;
- uninvertibleTransform.setM11(0);
- uninvertibleTransform.setM22(0);
- uninvertibleTransform.setM33(0);
- uninvertibleTransform.setM44(0);
- ASSERT_FALSE(uninvertibleTransform.isInvertible());
+ gfx::Transform uninvertibleTransform;
+ uninvertibleTransform.matrix().setDouble(0, 0, 0);
+ uninvertibleTransform.matrix().setDouble(1, 1, 0);
+ uninvertibleTransform.matrix().setDouble(2, 2, 0);
+ uninvertibleTransform.matrix().setDouble(3, 3, 0);
+ ASSERT_FALSE(uninvertibleTransform.IsInvertible());
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
gfx::PointF anchor(0, 0);
gfx::PointF position(0, 0);
@@ -3615,7 +3601,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
ASSERT_EQ(1u, root->renderSurface()->layerList().size());
- ASSERT_FALSE(root->screenSpaceTransform().isInvertible());
+ ASSERT_FALSE(root->screenSpaceTransform().IsInvertible());
// Hit checking any point should not hit the touch handler region on the layer. If the invertible matrix is
// accidentally ignored and treated like an identity, then the hit testing will
@@ -3653,7 +3639,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
{
scoped_ptr<LayerImpl> root = LayerImpl::create(12345);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50));
gfx::PointF anchor(0, 0);
gfx::PointF position(50, 50); // this layer is positioned, and hit testing should correctly know where the layer is located.
@@ -3711,7 +3697,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
//
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anchor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
@@ -3783,7 +3769,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
// be able to hit the touch handler region by scaling the points accordingly.
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
// Set the bounds of the root layer big enough to fit the child when scaled.
setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anchor, gfx::PointF(0, 0), gfx::Size(100, 100), false);
@@ -3804,8 +3790,8 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
int dummyMaxTextureSize = 512;
float deviceScaleFactor = 3.0f;
float pageScaleFactor = 5.0f;
- WebTransformationMatrix pageScaleTransform;
- pageScaleTransform.scale(pageScaleFactor);
+ gfx::Transform pageScaleTransform;
+ pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor);
root->setImplTransform(pageScaleTransform); // Applying the pageScaleFactor through implTransform.
gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bounds(), deviceScaleFactor * pageScaleFactor));
LayerTreeHostCommon::calculateDrawTransforms(root.get(), scaledBoundsForRoot, deviceScaleFactor, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
@@ -3864,7 +3850,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
{
// Test that hit-checking will only work for the visible portion of a layer, and not
// the entire layer bounds. Here we just test the simple axis-aligned case.
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
gfx::PointF anchor(0, 0);
scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@@ -3949,7 +3935,7 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI)
{
// Verify draw and screen space transforms of layers not in a surface.
MockContentLayerClient delegate;
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true);
@@ -3983,7 +3969,7 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI)
EXPECT_EQ(1u, renderSurfaceLayerList.size());
// Verify parent transforms
- WebTransformationMatrix expectedParentTransform;
+ gfx::Transform expectedParentTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpaceTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransform());
@@ -3999,8 +3985,8 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI)
EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect);
// Verify child and childEmpty transforms. They should match.
- WebTransformationMatrix expectedChildTransform;
- expectedChildTransform.translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
+ gfx::Transform expectedChildTransform;
+ expectedChildTransform.Translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->drawTransform());
@@ -4023,10 +4009,10 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI)
EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyScreenSpaceRect);
// Verify childNoScale transforms
- WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform();
+ gfx::Transform expectedChildNoScaleTransform = child->drawTransform();
// All transforms operate on content rects. The child's content rect
// incorporates device scale, but the childNoScale does not; add it here.
- expectedChildNoScaleTransform.scale(deviceScaleFactor);
+ expectedChildNoScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale->screenSpaceTransform());
}
@@ -4035,7 +4021,7 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
{
// Verify draw and screen space transforms of layers not in a surface.
MockContentLayerClient delegate;
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(133, 133), true);
@@ -4064,7 +4050,7 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
EXPECT_EQ(1u, renderSurfaceLayerList.size());
// Verify parent transforms
- WebTransformationMatrix expectedParentTransform;
+ gfx::Transform expectedParentTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpaceTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransform());
@@ -4082,7 +4068,7 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect);
// Verify child transforms
- WebTransformationMatrix expectedChildTransform;
+ gfx::Transform expectedChildTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTransform());
@@ -4100,10 +4086,10 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect);
// Verify childNoScale transforms
- WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform();
+ gfx::Transform expectedChildNoScaleTransform = child->drawTransform();
// All transforms operate on content rects. The child's content rect
// incorporates device scale, but the childNoScale does not; add it here.
- expectedChildNoScaleTransform.scale(deviceScaleFactor);
+ expectedChildNoScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale->screenSpaceTransform());
}
@@ -4111,15 +4097,15 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
TEST(LayerTreeHostCommonTest, verifyContentsScale)
{
MockContentLayerClient delegate;
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
- WebTransformationMatrix parentScaleMatrix;
+ gfx::Transform parentScaleMatrix;
const double initialParentScale = 1.75;
- parentScaleMatrix.scale(initialParentScale);
+ parentScaleMatrix.Scale(initialParentScale, initialParentScale);
- WebTransformationMatrix childScaleMatrix;
+ gfx::Transform childScaleMatrix;
const double initialChildScale = 1.25;
- childScaleMatrix.scale(initialChildScale);
+ childScaleMatrix.Scale(initialChildScale, initialChildScale);
float fixedRasterScale = 2.5;
@@ -4156,8 +4142,8 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale)
double pageScaleFactor = 1.5;
// FIXME: Remove this when pageScaleFactor is applied in the compositor.
- WebTransformationMatrix pageScaleMatrix;
- pageScaleMatrix.scale(pageScaleFactor);
+ gfx::Transform pageScaleMatrix;
+ pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor);
parent->setSublayerTransform(pageScaleMatrix);
LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
@@ -4170,16 +4156,16 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale)
// The parent is scaled up and shouldn't need to scale during draw. The child that can scale its contents should
// also not need to scale during draw. This shouldn't change if the child has empty bounds. The other children should.
- EXPECT_FLOAT_EQ(1, parent->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, parent->drawTransform().m22());
- EXPECT_FLOAT_EQ(1, childScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, childScale->drawTransform().m22());
- EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().m22());
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, childNoScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, childNoScale->drawTransform().m22());
- EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, childNoAutoScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, childNoAutoScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(1, 1));
+ EXPECT_FLOAT_EQ(1, childScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, childScale->drawTransform().matrix().getDouble(1, 1));
+ EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().matrix().getDouble(1, 1));
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, childNoScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, childNoScale->drawTransform().matrix().getDouble(1, 1));
+ EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, childNoAutoScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, childNoAutoScale->drawTransform().matrix().getDouble(1, 1));
// If the transform changes, we expect the contentsScale to remain unchanged.
childScale->setTransform(identityMatrix);
@@ -4199,7 +4185,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale)
// FIXME: Remove this when pageScaleFactor is applied in the compositor.
pageScaleMatrix = identityMatrix;
- pageScaleMatrix.scale(pageScaleFactor);
+ pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor);
parent->setSublayerTransform(pageScaleMatrix);
renderSurfaceLayerList.clear();
@@ -4215,15 +4201,15 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale)
TEST(LayerTreeHostCommonTest, verifySmallContentsScale)
{
MockContentLayerClient delegate;
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
- WebTransformationMatrix parentScaleMatrix;
+ gfx::Transform parentScaleMatrix;
const double initialParentScale = 1.75;
- parentScaleMatrix.scale(initialParentScale);
+ parentScaleMatrix.Scale(initialParentScale, initialParentScale);
- WebTransformationMatrix childScaleMatrix;
+ gfx::Transform childScaleMatrix;
const double initialChildScale = 0.25;
- childScaleMatrix.scale(initialChildScale);
+ childScaleMatrix.Scale(initialChildScale, initialChildScale);
scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true);
@@ -4244,8 +4230,8 @@ TEST(LayerTreeHostCommonTest, verifySmallContentsScale)
double pageScaleFactor = 0.01;
// FIXME: Remove this when pageScaleFactor is applied in the compositor.
- WebTransformationMatrix pageScaleMatrix;
- pageScaleMatrix.scale(pageScaleFactor);
+ gfx::Transform pageScaleMatrix;
+ pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor);
parent->setSublayerTransform(pageScaleMatrix);
LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
@@ -4255,9 +4241,9 @@ TEST(LayerTreeHostCommonTest, verifySmallContentsScale)
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale);
// When chilld's total scale becomes >= 1, we should save and use that scale factor.
- childScaleMatrix.makeIdentity();
+ childScaleMatrix.MakeIdentity();
const double finalChildScale = 0.75;
- childScaleMatrix.scale(finalChildScale);
+ childScaleMatrix.Scale(finalChildScale, finalChildScale);
childScale->setTransform(childScaleMatrix);
renderSurfaceLayerList.clear();
@@ -4270,15 +4256,15 @@ TEST(LayerTreeHostCommonTest, verifySmallContentsScale)
TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces)
{
MockContentLayerClient delegate;
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
- WebTransformationMatrix parentScaleMatrix;
+ gfx::Transform parentScaleMatrix;
const double initialParentScale = 2;
- parentScaleMatrix.scale(initialParentScale);
+ parentScaleMatrix.Scale(initialParentScale, initialParentScale);
- WebTransformationMatrix childScaleMatrix;
+ gfx::Transform childScaleMatrix;
const double initialChildScale = 3;
- childScaleMatrix.scale(initialChildScale);
+ childScaleMatrix.Scale(initialChildScale, initialChildScale);
float fixedRasterScale = 4;
@@ -4341,8 +4327,8 @@ TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces)
double pageScaleFactor = 7;
// FIXME: Remove this when pageScaleFactor is applied in the compositor.
- WebTransformationMatrix pageScaleMatrix;
- pageScaleMatrix.scale(pageScaleFactor);
+ gfx::Transform pageScaleMatrix;
+ pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor);
parent->setSublayerTransform(pageScaleMatrix);
LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
@@ -4360,70 +4346,70 @@ TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces)
EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoAutoScaleChildNoScale);
// The parent is scaled up and shouldn't need to scale during draw.
- EXPECT_FLOAT_EQ(1, parent->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, parent->drawTransform().m22());
+ EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(1, 1));
// RenderSurfaces should always be 1:1 with their target.
- EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m22());
+ EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().matrix().getDouble(1, 1));
// The surfaceScale can apply contents scale so the layer shouldn't need to scale during draw.
- EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().matrix().getDouble(1, 1));
// The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw.
- EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().matrix().getDouble(1, 1));
// The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw.
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().matrix().getDouble(1, 1));
// RenderSurfaces should always be 1:1 with their target.
- EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().m22());
+ EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().matrix().getDouble(1, 1));
// The surfaceNoScale layer can not apply contents scale, so it needs to be scaled during draw.
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, surfaceNoScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, surfaceNoScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, surfaceNoScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, surfaceNoScale->drawTransform().matrix().getDouble(1, 1));
// The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw.
- EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().matrix().getDouble(1, 1));
// The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw.
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform().matrix().getDouble(1, 1));
// RenderSurfaces should always be 1:1 with their target.
- EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().m22());
+ EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().matrix().getDouble(1, 1));
// The surfaceNoAutoScale layer has a fixed contents scale, so it needs to be scaled during draw.
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), surfaceNoAutoScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), surfaceNoAutoScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), surfaceNoAutoScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), surfaceNoAutoScale->drawTransform().matrix().getDouble(1, 1));
// The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw.
- EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().matrix().getDouble(1, 1));
// The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw.
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransform().m11());
- EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransform().m22());
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransform().matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransform().matrix().getDouble(1, 1));
}
TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer)
{
MockContentLayerClient delegate;
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
- WebTransformationMatrix parentScaleMatrix;
+ gfx::Transform parentScaleMatrix;
const double initialParentScale = 1.75;
- parentScaleMatrix.scale(initialParentScale);
+ parentScaleMatrix.Scale(initialParentScale, initialParentScale);
- WebTransformationMatrix childScaleMatrix;
+ gfx::Transform childScaleMatrix;
const double initialChildScale = 1.25;
- childScaleMatrix.scale(initialChildScale);
+ childScaleMatrix.Scale(initialChildScale, initialChildScale);
scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true);
@@ -4459,7 +4445,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer)
TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
{
MockContentLayerClient delegate;
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(30, 30), true);
@@ -4467,8 +4453,8 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true);
- WebTransformationMatrix replicaTransform;
- replicaTransform.scaleNonUniform(1, -1);
+ gfx::Transform replicaTransform;
+ replicaTransform.Scale(1, -1);
scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true);
@@ -4496,45 +4482,45 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
// render surface (it needs one because it has a replica layer).
EXPECT_EQ(2u, renderSurfaceLayerList.size());
- WebTransformationMatrix expectedParentTransform;
+ gfx::Transform expectedParentTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpaceTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransform());
- WebTransformationMatrix expectedDrawTransform;
+ gfx::Transform expectedDrawTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform());
- WebTransformationMatrix expectedScreenSpaceTransform;
- expectedScreenSpaceTransform.translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
+ gfx::Transform expectedScreenSpaceTransform;
+ expectedScreenSpaceTransform.Translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenSpaceTransform());
- WebTransformationMatrix expectedDuplicateChildDrawTransform = child->drawTransform();
+ gfx::Transform expectedDuplicateChildDrawTransform = child->drawTransform();
EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), duplicateChildNonOwner->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), duplicateChildNonOwner->screenSpaceTransform());
EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawableContentRect());
EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds());
- WebTransformationMatrix expectedRenderSurfaceDrawTransform;
- expectedRenderSurfaceDrawTransform.translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
+ gfx::Transform expectedRenderSurfaceDrawTransform;
+ expectedRenderSurfaceDrawTransform.Translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->renderSurface()->drawTransform());
- WebTransformationMatrix expectedSurfaceDrawTransform;
- expectedSurfaceDrawTransform.translate(deviceScaleFactor * 2, deviceScaleFactor * 2);
+ gfx::Transform expectedSurfaceDrawTransform;
+ expectedSurfaceDrawTransform.Translate(deviceScaleFactor * 2, deviceScaleFactor * 2);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderSurface()->drawTransform());
- WebTransformationMatrix expectedSurfaceScreenSpaceTransform;
- expectedSurfaceScreenSpaceTransform.translate(deviceScaleFactor * 2, deviceScaleFactor * 2);
+ gfx::Transform expectedSurfaceScreenSpaceTransform;
+ expectedSurfaceScreenSpaceTransform.Translate(deviceScaleFactor * 2, deviceScaleFactor * 2);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceScreenSpaceTransform, child->renderSurface()->screenSpaceTransform());
- WebTransformationMatrix expectedReplicaDrawTransform;
- expectedReplicaDrawTransform.setM22(-1);
- expectedReplicaDrawTransform.setM41(6);
- expectedReplicaDrawTransform.setM42(6);
+ gfx::Transform expectedReplicaDrawTransform;
+ expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1);
+ expectedReplicaDrawTransform.matrix().setDouble(0, 3, 6);
+ expectedReplicaDrawTransform.matrix().setDouble(1, 3, 6);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderSurface()->replicaDrawTransform());
- WebTransformationMatrix expectedReplicaScreenSpaceTransform;
- expectedReplicaScreenSpaceTransform.setM22(-1);
- expectedReplicaScreenSpaceTransform.setM41(6);
- expectedReplicaScreenSpaceTransform.setM42(6);
+ gfx::Transform expectedReplicaScreenSpaceTransform;
+ expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1);
+ expectedReplicaScreenSpaceTransform.matrix().setDouble(0, 3, 6);
+ expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 3, 6);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->renderSurface()->replicaScreenSpaceTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->renderSurface()->replicaScreenSpaceTransform());
}
@@ -4542,7 +4528,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition)
{
MockContentLayerClient delegate;
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(33, 31), true);
@@ -4550,8 +4536,8 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal
scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true);
- WebTransformationMatrix replicaTransform;
- replicaTransform.scaleNonUniform(1, -1);
+ gfx::Transform replicaTransform;
+ replicaTransform.Scale(1, -1);
scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate);
setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true);
@@ -4579,7 +4565,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal
// render surface (it needs one because it has a replica layer).
EXPECT_EQ(2u, renderSurfaceLayerList.size());
- WebTransformationMatrix identityTransform;
+ gfx::Transform identityTransform;
EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform());
@@ -4594,12 +4580,12 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal
EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->drawTransform());
EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->screenSpaceTransform());
- WebTransformationMatrix expectedReplicaDrawTransform;
- expectedReplicaDrawTransform.setM22(-1);
+ gfx::Transform expectedReplicaDrawTransform;
+ expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderSurface()->replicaDrawTransform());
- WebTransformationMatrix expectedReplicaScreenSpaceTransform;
- expectedReplicaScreenSpaceTransform.setM22(-1);
+ gfx::Transform expectedReplicaScreenSpaceTransform;
+ expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1);
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->renderSurface()->replicaScreenSpaceTransform());
}
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 0f96a43..96b4a02 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -36,8 +36,6 @@
#include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h"
-using WebKit::WebTransformationMatrix;
-
namespace {
void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible)
@@ -135,19 +133,19 @@ gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
return overflow;
}
-WebTransformationMatrix PinchZoomViewport::implTransform(bool pageScalePinchZoomEnabled) const
+gfx::Transform PinchZoomViewport::implTransform(bool pageScalePinchZoomEnabled) const
{
- WebTransformationMatrix transform;
- transform.scale(m_pageScaleDelta);
+ gfx::Transform transform;
+ transform.Scale(m_pageScaleDelta, m_pageScaleDelta);
// If the pinch state is applied in the impl, then push it to the
// impl transform, otherwise the scale is handled by WebCore.
if (pageScalePinchZoomEnabled) {
- transform.scale(m_pageScaleFactor);
+ transform.Scale(m_pageScaleFactor, m_pageScaleFactor);
// The offset needs to be scaled by deviceScaleFactor as this transform
// needs to work with physical pixels.
gfx::Vector2dF zoomedDeviceViewportOffset = gfx::ScaleVector2d(m_zoomedViewportOffset, m_deviceScaleFactor);
- transform.translate(-zoomedDeviceViewportOffset.x(), -zoomedDeviceViewportOffset.y());
+ transform.Translate(-zoomedDeviceViewportOffset.x(), -zoomedDeviceViewportOffset.y());
}
return transform;
@@ -448,7 +446,7 @@ static void appendQuadsToFillScreen(RenderPass* targetRenderPass, LayerImpl* roo
// doesn't have any bounds and so can't generate this itself.
// FIXME: Make the gutter quads generated by the solid color layer (make it smarter about generating quads to fill unoccluded areas).
- DCHECK(rootLayer->screenSpaceTransform().isInvertible());
+ DCHECK(rootLayer->screenSpaceTransform().IsInvertible());
gfx::Rect rootTargetRect = rootLayer->renderSurface()->contentRect();
float opacity = 1;
@@ -461,7 +459,7 @@ static void appendQuadsToFillScreen(RenderPass* targetRenderPass, LayerImpl* roo
opacity);
AppendQuadsData appendQuadsData;
- WebTransformationMatrix transformToLayerSpace = rootLayer->screenSpaceTransform().inverse();
+ gfx::Transform transformToLayerSpace = MathUtil::inverse(rootLayer->screenSpaceTransform());
for (Region::Iterator fillRects(fillRegion); fillRects.has_rect(); fillRects.next()) {
// The root layer transform is composed of translations and scales only,
// no perspective, so mapping is sufficient.
@@ -1198,8 +1196,8 @@ static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
{
// Layers with non-invertible screen space transforms should not have passed the scroll hit
// test in the first place.
- DCHECK(layerImpl.screenSpaceTransform().isInvertible());
- WebTransformationMatrix inverseScreenSpaceTransform = layerImpl.screenSpaceTransform().inverse();
+ DCHECK(layerImpl.screenSpaceTransform().IsInvertible());
+ gfx::Transform inverseScreenSpaceTransform = MathUtil::inverse(layerImpl.screenSpaceTransform());
gfx::PointF screenSpacePoint = gfx::ScalePoint(viewportPoint, scaleFromViewportToScreenSpace);
@@ -1462,7 +1460,7 @@ scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::processScrollDeltas()
return scrollInfo.Pass();
}
-WebTransformationMatrix LayerTreeHostImpl::implTransform() const
+gfx::Transform LayerTreeHostImpl::implTransform() const
{
return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnabled);
}
diff --git a/cc/layer_tree_host_impl.h b/cc/layer_tree_host_impl.h
index 4b41759..81ce4c2 100644
--- a/cc/layer_tree_host_impl.h
+++ b/cc/layer_tree_host_impl.h
@@ -100,7 +100,7 @@ public:
// origin of the zoomedDeviceViewport.
//
// implTransform = S[pageScale] * Tr[-zoomedDeviceViewportOffset]
- WebKit::WebTransformationMatrix implTransform(bool pageScalePinchZoomEnabled) const;
+ gfx::Transform implTransform(bool pageScalePinchZoomEnabled) const;
private:
float m_pageScaleFactor;
@@ -228,7 +228,7 @@ public:
void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor);
scoped_ptr<ScrollAndScaleSet> processScrollDeltas();
- WebKit::WebTransformationMatrix implTransform() const;
+ gfx::Transform implTransform() const;
void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index 859c9b7..aa556f6 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -552,7 +552,7 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
DCHECK(scrollLayer);
const float minPageScale = 1, maxPageScale = 4;
- const WebTransformationMatrix identityScaleTransform;
+ const gfx::Transform identityScaleTransform;
// The impl-based pinch zoom should not adjust the max scroll position.
{
@@ -606,7 +606,7 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5;
const float maxPageScale = 4;
- const WebTransformationMatrix identityScaleTransform;
+ const gfx::Transform identityScaleTransform;
// Basic pinch zoom in gesture
{
@@ -718,7 +718,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2;
const base::TimeTicks endTime = startTime + duration;
- const WebTransformationMatrix identityScaleTransform;
+ const gfx::Transform identityScaleTransform;
// Non-anchor zoom-in
{
@@ -1180,8 +1180,8 @@ TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild)
scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
- WebTransformationMatrix matrix;
- matrix.rotate3d(180, 0, 0);
+ gfx::Transform matrix;
+ MathUtil::rotateEulerAngles(&matrix, 180, 0, 0);
child->setTransform(matrix);
child->setDoubleSided(false);
@@ -1244,7 +1244,26 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
- EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix());
+ // TODO: If possible, use gfx::Transform() or Skia equality functions. At
+ // the moment we avoid that because skia does exact bit-wise equality
+ // checking that does not consider -0 == +0.
+ // http://code.google.com/p/chromium/issues/detail?id=162747
+ EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0, 0));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0, 1));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0, 2));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0, 3));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1, 0));
+ EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1, 1));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1, 2));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1, 3));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2, 0));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2, 1));
+ EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2, 2));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2, 3));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3, 0));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3, 1));
+ EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3, 2));
+ EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3, 3));
}
TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
@@ -1278,8 +1297,8 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta should match the new scale on the impl side.
- WebTransformationMatrix expectedScale;
- expectedScale.scale(pageScale);
+ gfx::Transform expectedScale;
+ expectedScale.Scale(pageScale, pageScale);
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
}
@@ -1287,11 +1306,11 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
{
gfx::Size surfaceSize(10, 10);
float defaultPageScale = 1;
- WebTransformationMatrix defaultPageScaleMatrix;
+ gfx::Transform defaultPageScaleMatrix;
float newPageScale = 2;
- WebTransformationMatrix newPageScaleMatrix;
- newPageScaleMatrix.scale(newPageScale);
+ gfx::Transform newPageScaleMatrix;
+ newPageScaleMatrix.Scale(newPageScale, newPageScale);
// Create a normal scrollable root layer and another scrollable child layer.
setupScrollAndContentsLayers(surfaceSize);
@@ -1320,12 +1339,12 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
m_hostImpl->drawLayers(frame);
m_hostImpl->didDrawAllLayers(frame);
- EXPECT_EQ(root->drawTransform().m11(), newPageScale);
- EXPECT_EQ(root->drawTransform().m22(), newPageScale);
- EXPECT_EQ(child->drawTransform().m11(), newPageScale);
- EXPECT_EQ(child->drawTransform().m22(), newPageScale);
- EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale);
- EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale);
+ EXPECT_EQ(root->drawTransform().matrix().getDouble(0, 0), newPageScale);
+ EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale);
+ EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale);
+ EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale);
+ EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale);
+ EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale);
}
TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
@@ -1367,8 +1386,8 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
- WebTransformationMatrix identityTransform;
- EXPECT_EQ(child->implTransform(), WebTransformationMatrix());
+ gfx::Transform identityTransform;
+ EXPECT_EQ(child->implTransform(), gfx::Transform());
}
TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
@@ -1456,8 +1475,8 @@ TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
setupScrollAndContentsLayers(gfx::Size(100, 100));
// Rotate the root layer 90 degrees counter-clockwise about its center.
- WebTransformationMatrix rotateTransform;
- rotateTransform.rotate(-90);
+ gfx::Transform rotateTransform;
+ rotateTransform.Rotate(-90);
m_hostImpl->rootLayer()->setTransform(rotateTransform);
gfx::Size surfaceSize(50, 50);
@@ -1494,10 +1513,10 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
// Create a child layer that is rotated to a non-axis-aligned angle.
scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl->rootLayer()->contentBounds());
- WebTransformationMatrix rotateTransform;
- rotateTransform.translate(-50, -50);
- rotateTransform.rotate(childLayerAngle);
- rotateTransform.translate(50, 50);
+ gfx::Transform rotateTransform;
+ rotateTransform.Translate(-50, -50);
+ rotateTransform.Rotate(childLayerAngle);
+ rotateTransform.Translate(50, 50);
child->setTransform(rotateTransform);
// Only allow vertical scrolling.
@@ -1553,8 +1572,8 @@ TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
// Scale the layer to twice its normal size.
int scale = 2;
- WebTransformationMatrix scaleTransform;
- scaleTransform.scale(scale);
+ gfx::Transform scaleTransform;
+ scaleTransform.Scale(scale, scale);
m_hostImpl->rootLayer()->setTransform(scaleTransform);
gfx::Size surfaceSize(50, 50);
@@ -2747,9 +2766,9 @@ static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid
ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
- pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), WebTransformationMatrix());
+ pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), gfx::Transform());
scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create();
- sharedState->SetAll(WebTransformationMatrix(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), false, 1);
+ sharedState->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), false, 1);
scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), resourceId, false, gfx::RectF(0, 0, 1, 1), false);
@@ -3169,10 +3188,10 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
// Rotation will put part of the child ouside the bounds of the root layer.
// Nevertheless, the child layers should be drawn.
- WebTransformationMatrix transform = surfaceLayerPtr->transform();
- transform.translate(50, 50);
- transform.rotate(35);
- transform.translate(-50, -50);
+ gfx::Transform transform = surfaceLayerPtr->transform();
+ transform.Translate(50, 50);
+ transform.Rotate(35);
+ transform.Translate(-50, -50);
surfaceLayerPtr->setTransform(transform);
{
@@ -3203,9 +3222,9 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
}
transform = surfaceLayerPtr->transform();
- transform.translate(50, 50);
- transform.rotate(-35);
- transform.translate(-50, -50);
+ transform.Translate(50, 50);
+ transform.Rotate(-35);
+ transform.Translate(-50, -50);
surfaceLayerPtr->setTransform(transform);
// The surface is now aligned again, and the clipped parts are exposed.
@@ -3298,8 +3317,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
// "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion.
- WebTransformationMatrix transform = layerS2Ptr->transform();
- transform.translate(150, 150);
+ gfx::Transform transform = layerS2Ptr->transform();
+ transform.Translate(150, 150);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3322,7 +3341,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
// Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed.
transform = layerS2Ptr->transform();
- transform.translate(-15, -15);
+ transform.Translate(-15, -15);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3413,8 +3432,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
// "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion.
- WebTransformationMatrix transform = layerS2Ptr->transform();
- transform.translate(100, 100);
+ gfx::Transform transform = layerS2Ptr->transform();
+ transform.Translate(100, 100);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3437,7 +3456,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
// Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed.
transform = layerS2Ptr->transform();
- transform.translate(-15, -15);
+ transform.Translate(-15, -15);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3519,8 +3538,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
// "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion.
- WebTransformationMatrix transform = layerS2Ptr->transform();
- transform.translate(300, 0);
+ gfx::Transform transform = layerS2Ptr->transform();
+ transform.Translate(300, 0);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3573,10 +3592,10 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
layerS1Ptr->setForceRenderSurface(true);
- WebTransformationMatrix transform = layerS1Ptr->transform();
- transform.translate(200, 200);
- transform.rotate(45);
- transform.translate(-200, -200);
+ gfx::Transform transform = layerS1Ptr->transform();
+ transform.Translate(200, 200);
+ transform.Rotate(45);
+ transform.Translate(-200, -200);
layerS1Ptr->setTransform(transform);
addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11
@@ -3686,8 +3705,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
// "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion.
- WebTransformationMatrix transform = layerS2Ptr->transform();
- transform.translate(150, 150);
+ gfx::Transform transform = layerS2Ptr->transform();
+ transform.Translate(150, 150);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3710,7 +3729,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
// Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed.
transform = layerS2Ptr->transform();
- transform.translate(-15, -15);
+ transform.Translate(-15, -15);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3968,8 +3987,8 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching)
}
// Change location of the intermediate layer
- WebTransformationMatrix transform = intermediateLayerPtr->transform();
- transform.setM41(1.0001);
+ gfx::Transform transform = intermediateLayerPtr->transform();
+ transform.matrix().setDouble(0, 3, 1.0001);
intermediateLayerPtr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -4129,8 +4148,8 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
}
// Change location of the intermediate layer
- WebTransformationMatrix transform = intermediateLayerPtr->transform();
- transform.setM41(1.0001);
+ gfx::Transform transform = intermediateLayerPtr->transform();
+ transform.matrix().setDouble(0, 3, 1.0001);
intermediateLayerPtr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -4224,14 +4243,14 @@ static void configureRenderPassTestData(const char* testScript, RenderPassRemova
// One shared state for all quads - we don't need the correct details
testData.sharedQuadState = SharedQuadState::Create();
- testData.sharedQuadState->SetAll(WebTransformationMatrix(), gfx::Rect(), gfx::Rect(), gfx::Rect(), false, 1.0);
+ testData.sharedQuadState->SetAll(gfx::Transform(), gfx::Rect(), gfx::Rect(), gfx::Rect(), false, 1.0);
const char* currentChar = testScript;
// Pre-create root pass
RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1]);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
- pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), WebTransformationMatrix());
+ pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), gfx::Transform());
testData.renderPassCache.add(rootRenderPassId, pass.Pass());
while (*currentChar) {
int layerId = *currentChar;
@@ -4291,7 +4310,7 @@ static void configureRenderPassTestData(const char* testScript, RenderPassRemova
renderer->setHaveCachedResourcesForRenderPassId(newRenderPassId);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
- pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), WebTransformationMatrix());
+ pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), gfx::Transform());
testData.renderPassCache.add(newRenderPassId, pass.Pass());
}
@@ -4538,8 +4557,8 @@ void LayerTreeHostImplTest::pinchZoomPanViewportForcesCommitRedraw(const float d
m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform();
- WebTransformationMatrix expectedImplTransform;
- expectedImplTransform.scale(pageScale);
+ gfx::Transform expectedImplTransform;
+ expectedImplTransform.Scale(pageScale, pageScale);
// Verify the pinch zoom took place.
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
@@ -4610,8 +4629,8 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact
m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform();
- WebTransformationMatrix expectedImplTransform;
- expectedImplTransform.scale(pageScale);
+ gfx::Transform expectedImplTransform;
+ expectedImplTransform.Scale(pageScale, pageScale);
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
@@ -4628,7 +4647,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact
m_hostImpl->updateRootScrollLayerImplTransform();
gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslation.y());
+ expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
// No change expected.
@@ -4645,7 +4664,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact
m_hostImpl->updateRootScrollLayerImplTransform();
expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslation.y());
+ expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
// No change expected.
@@ -4690,8 +4709,8 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform();
- WebTransformationMatrix expectedImplTransform;
- expectedImplTransform.scale(pageScale);
+ gfx::Transform expectedImplTransform;
+ expectedImplTransform.Scale(pageScale, pageScale);
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
@@ -4727,7 +4746,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
gfx::Vector2d expectedPanDelta(scrollDelta);
gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslation.y());
+ expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
@@ -4762,7 +4781,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
expectedPanDelta = scrollDelta;
expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslation.y());
+ expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
@@ -4809,8 +4828,8 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform();
- WebTransformationMatrix expectedImplTransform;
- expectedImplTransform.scale(pageScale);
+ gfx::Transform expectedImplTransform;
+ expectedImplTransform.Scale(pageScale, pageScale);
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
@@ -4836,7 +4855,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoomViewport pan.
gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslation.y());
+ expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
@@ -4855,7 +4874,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
expectedPanDelta = gfx::Vector2d(0, 1);
expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslation.y());
+ expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
}
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index 5135441..479138a 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -1339,20 +1339,20 @@ public:
gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5));
EXPECT_EQ(childBoundsScaled, child->contentBounds());
- WebTransformationMatrix scaleTransform;
- scaleTransform.scale(impl->deviceScaleFactor());
+ gfx::Transform scaleTransform;
+ scaleTransform.Scale(impl->deviceScaleFactor(), impl->deviceScaleFactor());
// The root layer is scaled by 2x.
- WebTransformationMatrix rootScreenSpaceTransform = scaleTransform;
- WebTransformationMatrix rootDrawTransform = scaleTransform;
+ gfx::Transform rootScreenSpaceTransform = scaleTransform;
+ gfx::Transform rootDrawTransform = scaleTransform;
EXPECT_EQ(rootDrawTransform, root->drawTransform());
EXPECT_EQ(rootScreenSpaceTransform, root->screenSpaceTransform());
// The child is at position 2,2, which is transformed to 3,3 after the scale
- WebTransformationMatrix childScreenSpaceTransform;
- childScreenSpaceTransform.translate(3, 3);
- WebTransformationMatrix childDrawTransform = childScreenSpaceTransform;
+ gfx::Transform childScreenSpaceTransform;
+ childScreenSpaceTransform.Translate(3, 3);
+ gfx::Transform childDrawTransform = childScreenSpaceTransform;
EXPECT_EQ(childDrawTransform, child->drawTransform());
EXPECT_EQ(childScreenSpaceTransform, child->screenSpaceTransform());
@@ -1465,7 +1465,7 @@ TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread)
runTest(true);
}
-static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const WebTransformationMatrix& transform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
+static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const gfx::Transform& transform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
{
layer->removeAllChildren();
if (parent)
@@ -1493,7 +1493,7 @@ public:
m_layerTreeHost->setRootLayer(m_parent);
m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20));
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true);
setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false);
@@ -1637,7 +1637,7 @@ private:
Region m_occludedScreenSpace;
};
-static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, const WebTransformationMatrix& transform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
+static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, const gfx::Transform& transform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
{
setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bounds, opaque);
layer->clearOccludedScreenSpace();
@@ -1655,11 +1655,11 @@ public:
scoped_refptr<TestLayer> grandChild = TestLayer::create();
scoped_refptr<TestLayer> mask = TestLayer::create();
- WebTransformationMatrix identityMatrix;
- WebTransformationMatrix childTransform;
- childTransform.translate(250, 250);
- childTransform.rotate(90);
- childTransform.translate(-250, -250);
+ gfx::Transform identityMatrix;
+ gfx::Transform childTransform;
+ childTransform.Translate(250, 250);
+ childTransform.Rotate(90);
+ childTransform.Translate(-250, -250);
child->setMasksToBounds(true);
@@ -1828,11 +1828,11 @@ public:
scoped_refptr<TestLayer> grandChild = TestLayer::create();
scoped_refptr<TestLayer> mask = TestLayer::create();
- WebTransformationMatrix identityMatrix;
- WebTransformationMatrix childTransform;
- childTransform.translate(250, 250);
- childTransform.rotate(90);
- childTransform.translate(-250, -250);
+ gfx::Transform identityMatrix;
+ gfx::Transform childTransform;
+ childTransform.Translate(250, 250);
+ childTransform.Rotate(90);
+ childTransform.Translate(-250, -250);
child->setMasksToBounds(true);
@@ -1907,7 +1907,7 @@ public:
{
// We create enough RenderSurfaces that it will trigger Vector reallocation while computing occlusion.
Region occluded;
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
std::vector<scoped_refptr<TestLayer> > layers;
std::vector<scoped_refptr<TestLayer> > children;
int numSurfaces = 20;
@@ -2708,7 +2708,7 @@ public:
m_layerTreeHost->setRootLayer(m_layer);
m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20));
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true);
postSetNeedsCommitToMainThread();
@@ -2841,7 +2841,7 @@ public:
m_layerTreeHost->setRootLayer(m_layer);
m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20));
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true);
postSetNeedsCommitToMainThread();
@@ -2966,7 +2966,7 @@ public:
m_layerTreeHost->setRootLayer(m_parent);
m_layerTreeHost->setViewportSize(gfx::Size(m_numChildren, 1), gfx::Size(m_numChildren, 1));
- WebTransformationMatrix identityMatrix;
+ gfx::Transform identityMatrix;
setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(m_numChildren, 1), true);
for (int i = 0; i < m_numChildren; i++)
setLayerPropertiesForTesting(m_children[i].get(), m_parent.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(i, 0), gfx::Size(1, 1), false);
@@ -3122,15 +3122,15 @@ public:
virtual void beginTest() OVERRIDE
{
- WebTransformationMatrix m;
- m.translate(250, 360);
- m.scale(2);
+ gfx::Transform m;
+ m.Translate(250, 360);
+ m.Scale(2, 2);
gfx::Point point(400, 550);
gfx::Point transformedPoint;
// Unit transform, no change expected.
- m_layerTreeHost->setImplTransform(WebTransformationMatrix());
+ m_layerTreeHost->setImplTransform(gfx::Transform());
transformedPoint = gfx::ToRoundedPoint(m_layerTreeHost->adjustEventPointForPinchZoom(point));
EXPECT_EQ(point.x(), transformedPoint.x());
EXPECT_EQ(point.y(), transformedPoint.y());
diff --git a/cc/layer_unittest.cc b/cc/layer_unittest.cc
index 4ccd171..00baf6a 100644
--- a/cc/layer_unittest.cc
+++ b/cc/layer_unittest.cc
@@ -8,16 +8,16 @@
#include "cc/layer_impl.h"
#include "cc/layer_painter.h"
#include "cc/layer_tree_host.h"
+#include "cc/math_util.h"
#include "cc/single_thread_proxy.h"
#include "cc/thread.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/geometry_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using namespace WebKitTests;
-using WebKit::WebTransformationMatrix;
using ::testing::Mock;
using ::testing::_;
using ::testing::AtLeast;
@@ -505,8 +505,8 @@ TEST_F(LayerTest, checkPropertyChangeCausesCorrectBehavior)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUseLCDText(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setRenderTarget(0));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(WebTransformationMatrix()));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(WebTransformationMatrix()));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(gfx::Transform()));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(gfx::Transform()));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableContentRect(gfx::Rect(4, 5, 6, 7)));
EXPECT_FALSE(testLayer->needsDisplay());
@@ -521,13 +521,13 @@ TEST_F(LayerTest, checkPropertyChangeCausesCorrectBehavior)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsOpaque(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(gfx::PointF(4, 9)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get()));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0)));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(MathUtil::createGfxTransform(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOnMainThread(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNonFastScrollableRegion(gfx::Rect(1, 1, 2, 2)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEventHandlers(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollOffset(gfx::Vector2d(10, 10)));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0)));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(MathUtil::createGfxTransform(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer"));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDrawCheckerboardForMissingTiles(!testLayer->drawCheckerboardForMissingTiles()));
diff --git a/cc/math_util.cc b/cc/math_util.cc
index a9c0c82..9312d10 100644
--- a/cc/math_util.cc
+++ b/cc/math_util.cc
@@ -11,10 +11,8 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/rect_f.h"
+#include "ui/gfx/transform.h"
#include "ui/gfx/vector2d_f.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
namespace cc {
@@ -22,39 +20,39 @@ const double MathUtil::PI_DOUBLE = 3.14159265358979323846;
const float MathUtil::PI_FLOAT = 3.14159265358979323846f;
const double MathUtil::EPSILON = 1e-9;
-static HomogeneousCoordinate projectHomogeneousPoint(const WebTransformationMatrix& transform, const gfx::PointF& p)
+static HomogeneousCoordinate projectHomogeneousPoint(const gfx::Transform& transform, const gfx::PointF& p)
{
// In this case, the layer we are trying to project onto is perpendicular to ray
// (point p and z-axis direction) that we are trying to project. This happens when the
// layer is rotated so that it is infinitesimally thin, or when it is co-planar with
// the camera origin -- i.e. when the layer is invisible anyway.
- if (!transform.m33())
+ if (!transform.matrix().getDouble(2, 2))
return HomogeneousCoordinate(0, 0, 0, 1);
double x = p.x();
double y = p.y();
- double z = -(transform.m13() * x + transform.m23() * y + transform.m43()) / transform.m33();
+ double z = -(transform.matrix().getDouble(2, 0) * x + transform.matrix().getDouble(2, 1) * y + transform.matrix().getDouble(2, 3)) / transform.matrix().getDouble(2, 2);
// implicit definition of w = 1;
- double outX = x * transform.m11() + y * transform.m21() + z * transform.m31() + transform.m41();
- double outY = x * transform.m12() + y * transform.m22() + z * transform.m32() + transform.m42();
- double outZ = x * transform.m13() + y * transform.m23() + z * transform.m33() + transform.m43();
- double outW = x * transform.m14() + y * transform.m24() + z * transform.m34() + transform.m44();
+ double outX = x * transform.matrix().getDouble(0, 0) + y * transform.matrix().getDouble(0, 1) + z * transform.matrix().getDouble(0, 2) + transform.matrix().getDouble(0, 3);
+ double outY = x * transform.matrix().getDouble(1, 0) + y * transform.matrix().getDouble(1, 1) + z * transform.matrix().getDouble(1, 2) + transform.matrix().getDouble(1, 3);
+ double outZ = x * transform.matrix().getDouble(2, 0) + y * transform.matrix().getDouble(2, 1) + z * transform.matrix().getDouble(2, 2) + transform.matrix().getDouble(2, 3);
+ double outW = x * transform.matrix().getDouble(3, 0) + y * transform.matrix().getDouble(3, 1) + z * transform.matrix().getDouble(3, 2) + transform.matrix().getDouble(3, 3);
return HomogeneousCoordinate(outX, outY, outZ, outW);
}
-static HomogeneousCoordinate mapHomogeneousPoint(const WebTransformationMatrix& transform, const gfx::Point3F& p)
+static HomogeneousCoordinate mapHomogeneousPoint(const gfx::Transform& transform, const gfx::Point3F& p)
{
double x = p.x();
double y = p.y();
double z = p.z();
// implicit definition of w = 1;
- double outX = x * transform.m11() + y * transform.m21() + z * transform.m31() + transform.m41();
- double outY = x * transform.m12() + y * transform.m22() + z * transform.m32() + transform.m42();
- double outZ = x * transform.m13() + y * transform.m23() + z * transform.m33() + transform.m43();
- double outW = x * transform.m14() + y * transform.m24() + z * transform.m34() + transform.m44();
+ double outX = x * transform.matrix().getDouble(0, 0) + y * transform.matrix().getDouble(0, 1) + z * transform.matrix().getDouble(0, 2) + transform.matrix().getDouble(0, 3);
+ double outY = x * transform.matrix().getDouble(1, 0) + y * transform.matrix().getDouble(1, 1) + z * transform.matrix().getDouble(1, 2) + transform.matrix().getDouble(1, 3);
+ double outZ = x * transform.matrix().getDouble(2, 0) + y * transform.matrix().getDouble(2, 1) + z * transform.matrix().getDouble(2, 2) + transform.matrix().getDouble(2, 3);
+ double outW = x * transform.matrix().getDouble(3, 0) + y * transform.matrix().getDouble(3, 1) + z * transform.matrix().getDouble(3, 2) + transform.matrix().getDouble(3, 3);
return HomogeneousCoordinate(outX, outY, outZ, outW);
}
@@ -102,15 +100,15 @@ static inline void addVertexToClippedQuad(const gfx::PointF& newVertex, gfx::Poi
numVerticesInClippedQuad++;
}
-gfx::Rect MathUtil::mapClippedRect(const WebTransformationMatrix& transform, const gfx::Rect& srcRect)
+gfx::Rect MathUtil::mapClippedRect(const gfx::Transform& transform, const gfx::Rect& srcRect)
{
return gfx::ToEnclosingRect(mapClippedRect(transform, gfx::RectF(srcRect)));
}
-gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, const gfx::RectF& srcRect)
+gfx::RectF MathUtil::mapClippedRect(const gfx::Transform& transform, const gfx::RectF& srcRect)
{
- if (transform.isIdentityOrTranslation())
- return srcRect + gfx::Vector2dF(static_cast<float>(transform.m41()), static_cast<float>(transform.m42()));
+ if (MathUtil::isIdentityOrTranslation(transform))
+ return srcRect + gfx::Vector2dF(static_cast<float>(transform.matrix().getDouble(0, 3)), static_cast<float>(transform.matrix().getDouble(1, 3)));
// Apply the transform, but retain the result in homogeneous coordinates.
gfx::QuadF q = gfx::QuadF(srcRect);
@@ -122,10 +120,10 @@ gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, co
return computeEnclosingClippedRect(h1, h2, h3, h4);
}
-gfx::RectF MathUtil::projectClippedRect(const WebTransformationMatrix& transform, const gfx::RectF& srcRect)
+gfx::RectF MathUtil::projectClippedRect(const gfx::Transform& transform, const gfx::RectF& srcRect)
{
- if (transform.isIdentityOrTranslation())
- return srcRect + gfx::Vector2dF(static_cast<float>(transform.m41()), static_cast<float>(transform.m42()));
+ if (MathUtil::isIdentityOrTranslation(transform))
+ return srcRect + gfx::Vector2dF(static_cast<float>(transform.matrix().getDouble(0, 3)), static_cast<float>(transform.matrix().getDouble(1, 3)));
// Perform the projection, but retain the result in homogeneous coordinates.
gfx::QuadF q = gfx::QuadF(srcRect);
@@ -137,7 +135,7 @@ gfx::RectF MathUtil::projectClippedRect(const WebTransformationMatrix& transform
return computeEnclosingClippedRect(h1, h2, h3, h4);
}
-void MathUtil::mapClippedQuad(const WebTransformationMatrix& transform, const gfx::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad)
+void MathUtil::mapClippedQuad(const gfx::Transform& transform, const gfx::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad)
{
HomogeneousCoordinate h1 = mapHomogeneousPoint(transform, gfx::Point3F(srcQuad.p1()));
HomogeneousCoordinate h2 = mapHomogeneousPoint(transform, gfx::Point3F(srcQuad.p2()));
@@ -241,11 +239,11 @@ gfx::RectF MathUtil::computeEnclosingClippedRect(const HomogeneousCoordinate& h1
return gfx::RectF(gfx::PointF(xmin, ymin), gfx::SizeF(xmax - xmin, ymax - ymin));
}
-gfx::QuadF MathUtil::mapQuad(const WebTransformationMatrix& transform, const gfx::QuadF& q, bool& clipped)
+gfx::QuadF MathUtil::mapQuad(const gfx::Transform& transform, const gfx::QuadF& q, bool& clipped)
{
- if (transform.isIdentityOrTranslation()) {
+ if (MathUtil::isIdentityOrTranslation(transform)) {
gfx::QuadF mappedQuad(q);
- mappedQuad += gfx::Vector2dF(static_cast<float>(transform.m41()), static_cast<float>(transform.m42()));
+ mappedQuad += gfx::Vector2dF(static_cast<float>(transform.matrix().getDouble(0, 3)), static_cast<float>(transform.matrix().getDouble(1, 3)));
clipped = false;
return mappedQuad;
}
@@ -261,7 +259,7 @@ gfx::QuadF MathUtil::mapQuad(const WebTransformationMatrix& transform, const gfx
return gfx::QuadF(h1.cartesianPoint2d(), h2.cartesianPoint2d(), h3.cartesianPoint2d(), h4.cartesianPoint2d());
}
-gfx::PointF MathUtil::mapPoint(const WebTransformationMatrix& transform, const gfx::PointF& p, bool& clipped)
+gfx::PointF MathUtil::mapPoint(const gfx::Transform& transform, const gfx::PointF& p, bool& clipped)
{
HomogeneousCoordinate h = mapHomogeneousPoint(transform, gfx::Point3F(p));
@@ -284,7 +282,7 @@ gfx::PointF MathUtil::mapPoint(const WebTransformationMatrix& transform, const g
return h.cartesianPoint2d();
}
-gfx::Point3F MathUtil::mapPoint(const WebTransformationMatrix& transform, const gfx::Point3F& p, bool& clipped)
+gfx::Point3F MathUtil::mapPoint(const gfx::Transform& transform, const gfx::Point3F& p, bool& clipped)
{
HomogeneousCoordinate h = mapHomogeneousPoint(transform, p);
@@ -307,7 +305,7 @@ gfx::Point3F MathUtil::mapPoint(const WebTransformationMatrix& transform, const
return h.cartesianPoint3d();
}
-gfx::QuadF MathUtil::projectQuad(const WebTransformationMatrix& transform, const gfx::QuadF& q, bool& clipped)
+gfx::QuadF MathUtil::projectQuad(const gfx::Transform& transform, const gfx::QuadF& q, bool& clipped)
{
gfx::QuadF projectedQuad;
bool clippedPoint;
@@ -323,7 +321,7 @@ gfx::QuadF MathUtil::projectQuad(const WebTransformationMatrix& transform, const
return projectedQuad;
}
-gfx::PointF MathUtil::projectPoint(const WebTransformationMatrix& transform, const gfx::PointF& p, bool& clipped)
+gfx::PointF MathUtil::projectPoint(const gfx::Transform& transform, const gfx::PointF& p, bool& clipped)
{
HomogeneousCoordinate h = projectHomogeneousPoint(transform, p);
@@ -347,7 +345,7 @@ gfx::PointF MathUtil::projectPoint(const WebTransformationMatrix& transform, con
return h.cartesianPoint2d();
}
-void MathUtil::flattenTransformTo2d(WebTransformationMatrix& transform)
+void MathUtil::flattenTransformTo2d(gfx::Transform& transform)
{
// Set both the 3rd row and 3rd column to (0, 0, 1, 0).
//
@@ -359,13 +357,13 @@ void MathUtil::flattenTransformTo2d(WebTransformationMatrix& transform)
// - Because of linearity of transforms, this flattened transform also preserves the
// effect that any subsequent (post-multiplied) transforms would have on z values.
//
- transform.setM13(0);
- transform.setM23(0);
- transform.setM31(0);
- transform.setM32(0);
- transform.setM33(1);
- transform.setM34(0);
- transform.setM43(0);
+ transform.matrix().setDouble(2, 0, 0);
+ transform.matrix().setDouble(2, 1, 0);
+ transform.matrix().setDouble(0, 2, 0);
+ transform.matrix().setDouble(1, 2, 0);
+ transform.matrix().setDouble(2, 2, 1);
+ transform.matrix().setDouble(3, 2, 0);
+ transform.matrix().setDouble(2, 3, 0);
}
static inline float scaleOnAxis(double a, double b, double c)
@@ -373,12 +371,12 @@ static inline float scaleOnAxis(double a, double b, double c)
return std::sqrt(a * a + b * b + c * c);
}
-gfx::Vector2dF MathUtil::computeTransform2dScaleComponents(const WebTransformationMatrix& transform)
+gfx::Vector2dF MathUtil::computeTransform2dScaleComponents(const gfx::Transform& transform)
{
- if (transform.hasPerspective())
+ if (hasPerspective(transform))
return gfx::Vector2dF(1, 1);
- float xScale = scaleOnAxis(transform.m11(), transform.m12(), transform.m13());
- float yScale = scaleOnAxis(transform.m21(), transform.m22(), transform.m23());
+ float xScale = scaleOnAxis(transform.matrix().getDouble(0, 0), transform.matrix().getDouble(1, 0), transform.matrix().getDouble(2, 0));
+ float yScale = scaleOnAxis(transform.matrix().getDouble(0, 1), transform.matrix().getDouble(1, 1), transform.matrix().getDouble(2, 1));
return gfx::Vector2dF(xScale, yScale);
}
@@ -396,23 +394,22 @@ gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF des
return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * destination.y());
}
-bool MathUtil::isInvertible(const gfx::Transform& transform)
+bool MathUtil::isBackFaceVisible(const gfx::Transform& transform)
{
- const SkMatrix44& matrix = transform.matrix();
- double determinant = matrix.determinant();
- return abs(determinant) > EPSILON;
-}
+ // Compute whether a layer with a forward-facing normal of (0, 0, 1) would
+ // have its back face visible after applying the transform.
+ //
+ // This is done by transforming the normal and seeing if the resulting z
+ // value is positive or negative. However, note that transforming a normal
+ // actually requires using the inverse-transpose of the original transform.
-bool MathUtil::isBackFaceVisible(const gfx::Transform&)
-{
- // TODO (shawnsingh): to be implemented in a follow up patch very soon.
- NOTREACHED();
- return false;
-}
+ // TODO (shawnsingh) make this perform more efficiently - we do not
+ // actually need to instantiate/invert/transpose any matrices, exploiting the
+ // fact that we only need to transform (0, 0, 1, 0).
+ gfx::Transform inverseTransform = MathUtil::inverse(transform);
+ const SkMatrix44& mInv = inverseTransform.matrix();
-bool MathUtil::isIdentity(const gfx::Transform& transform)
-{
- return transform.matrix().isIdentity();
+ return mInv.getDouble(2, 2) < 0;
}
bool MathUtil::isIdentityOrTranslation(const gfx::Transform& transform)
@@ -438,11 +435,6 @@ bool MathUtil::hasPerspective(const gfx::Transform& transform)
return matrix.getDouble(3, 0) || matrix.getDouble(3, 1) || matrix.getDouble(3, 2) || (matrix.getDouble(3, 3) != 1);
}
-void MathUtil::makeIdentity(gfx::Transform* transform)
-{
- transform->matrix().setIdentity();
-}
-
void MathUtil::rotateEulerAngles(gfx::Transform* transform, double eulerX, double eulerY, double eulerZ)
{
// TODO (shawnsingh): make this implementation faster and more accurate by
diff --git a/cc/math_util.h b/cc/math_util.h
index 65fb436..99ee46c 100644
--- a/cc/math_util.h
+++ b/cc/math_util.h
@@ -11,14 +11,11 @@
#include "ui/gfx/point3_f.h"
#include "ui/gfx/transform.h"
-namespace WebKit {
-class WebTransformationMatrix;
-}
-
namespace gfx {
class QuadF;
class Rect;
class RectF;
+class Transform;
class Vector2dF;
}
@@ -78,7 +75,7 @@ public:
static float Deg2Rad(float deg) { return deg * PI_FLOAT / 180; }
static float Rad2Deg(float rad) { return rad * 180 / PI_FLOAT; }
- // Background: WebTransformationMatrix code in WebCore does not do the right thing in
+ // Background: Existing transform code does not do the right thing in
// mapRect / mapQuad / projectQuad when there is a perspective projection that causes
// one of the transformed vertices to go to w < 0. In those cases, it is necessary to
// perform clipping in homogeneous coordinates, after applying the transform, before
@@ -86,30 +83,30 @@ public:
//
// These functions return the axis-aligned rect that encloses the correctly clipped,
// transformed polygon.
- static gfx::Rect mapClippedRect(const WebKit::WebTransformationMatrix&, const gfx::Rect&);
- static gfx::RectF mapClippedRect(const WebKit::WebTransformationMatrix&, const gfx::RectF&);
- static gfx::RectF projectClippedRect(const WebKit::WebTransformationMatrix&, const gfx::RectF&);
+ static gfx::Rect mapClippedRect(const gfx::Transform&, const gfx::Rect&);
+ static gfx::RectF mapClippedRect(const gfx::Transform&, const gfx::RectF&);
+ static gfx::RectF projectClippedRect(const gfx::Transform&, const gfx::RectF&);
// Returns an array of vertices that represent the clipped polygon. After returning, indexes from
// 0 to numVerticesInClippedQuad are valid in the clippedQuad array. Note that
// numVerticesInClippedQuad may be zero, which means the entire quad was clipped, and
// none of the vertices in the array are valid.
- static void mapClippedQuad(const WebKit::WebTransformationMatrix&, const gfx::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad);
+ static void mapClippedQuad(const gfx::Transform&, const gfx::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad);
static gfx::RectF computeEnclosingRectOfVertices(gfx::PointF vertices[], int numVertices);
static gfx::RectF computeEnclosingClippedRect(const HomogeneousCoordinate& h1, const HomogeneousCoordinate& h2, const HomogeneousCoordinate& h3, const HomogeneousCoordinate& h4);
// NOTE: These functions do not do correct clipping against w = 0 plane, but they
// correctly detect the clipped condition via the boolean clipped.
- static gfx::QuadF mapQuad(const WebKit::WebTransformationMatrix&, const gfx::QuadF&, bool& clipped);
- static gfx::PointF mapPoint(const WebKit::WebTransformationMatrix&, const gfx::PointF&, bool& clipped);
- static gfx::Point3F mapPoint(const WebKit::WebTransformationMatrix&, const gfx::Point3F&, bool& clipped);
- static gfx::QuadF projectQuad(const WebKit::WebTransformationMatrix&, const gfx::QuadF&, bool& clipped);
- static gfx::PointF projectPoint(const WebKit::WebTransformationMatrix&, const gfx::PointF&, bool& clipped);
+ static gfx::QuadF mapQuad(const gfx::Transform&, const gfx::QuadF&, bool& clipped);
+ static gfx::PointF mapPoint(const gfx::Transform&, const gfx::PointF&, bool& clipped);
+ static gfx::Point3F mapPoint(const gfx::Transform&, const gfx::Point3F&, bool& clipped);
+ static gfx::QuadF projectQuad(const gfx::Transform&, const gfx::QuadF&, bool& clipped);
+ static gfx::PointF projectPoint(const gfx::Transform&, const gfx::PointF&, bool& clipped);
- static void flattenTransformTo2d(WebKit::WebTransformationMatrix&);
+ static void flattenTransformTo2d(gfx::Transform&);
- static gfx::Vector2dF computeTransform2dScaleComponents(const WebKit::WebTransformationMatrix&);
+ static gfx::Vector2dF computeTransform2dScaleComponents(const gfx::Transform&);
// Returns the smallest angle between the given two vectors in degrees. Neither vector is
// assumed to be normalized.
@@ -118,17 +115,14 @@ public:
// Projects the |source| vector onto |destination|. Neither vector is assumed to be normalized.
static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF destination);
- // Temporary API to ease migration from WebKit::WebTransformationMatrix
+ // Temporary API to ease migration from gfx::Transform
// to gfx::Transform.
//
// TODO(shawnsingh, vollick) we should phase out as much as possible of
// these temporary functions, putting functionality into gfx::Transform.
- static bool isInvertible(const gfx::Transform&);
static bool isBackFaceVisible(const gfx::Transform&);
- static bool isIdentity(const gfx::Transform&);
static bool isIdentityOrTranslation(const gfx::Transform&);
static bool hasPerspective(const gfx::Transform&);
- static void makeIdentity(gfx::Transform*);
static void rotateEulerAngles(gfx::Transform*, double eulerX, double eulerY, double eulerZ);
static void rotateAxisAngle(gfx::Transform*, double i, double j, double k, double degrees);
static gfx::Transform inverse(const gfx::Transform&);
diff --git a/cc/math_util_unittest.cc b/cc/math_util_unittest.cc
index 92c4405..c9daf9c 100644
--- a/cc/math_util_unittest.cc
+++ b/cc/math_util_unittest.cc
@@ -11,37 +11,35 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
namespace {
TEST(MathUtilTest, verifyBackfaceVisibilityBasicCases)
{
- WebTransformationMatrix transform;
+ gfx::Transform transform;
- transform.makeIdentity();
- EXPECT_FALSE(transform.isBackFaceVisible());
+ transform.MakeIdentity();
+ EXPECT_FALSE(MathUtil::isBackFaceVisible(transform));
- transform.makeIdentity();
- transform.rotate3d(0, 80, 0);
- EXPECT_FALSE(transform.isBackFaceVisible());
+ transform.MakeIdentity();
+ MathUtil::rotateEulerAngles(&transform, 0, 80, 0);
+ EXPECT_FALSE(MathUtil::isBackFaceVisible(transform));
- transform.makeIdentity();
- transform.rotate3d(0, 100, 0);
- EXPECT_TRUE(transform.isBackFaceVisible());
+ transform.MakeIdentity();
+ MathUtil::rotateEulerAngles(&transform, 0, 100, 0);
+ EXPECT_TRUE(MathUtil::isBackFaceVisible(transform));
// Edge case, 90 degree rotation should return false.
- transform.makeIdentity();
- transform.rotate3d(0, 90, 0);
- EXPECT_FALSE(transform.isBackFaceVisible());
+ transform.MakeIdentity();
+ MathUtil::rotateEulerAngles(&transform, 0, 90, 0);
+ EXPECT_FALSE(MathUtil::isBackFaceVisible(transform));
}
TEST(MathUtilTest, verifyBackfaceVisibilityForPerspective)
{
- WebTransformationMatrix layerSpaceToProjectionPlane;
+ gfx::Transform layerSpaceToProjectionPlane;
// This tests if isBackFaceVisible works properly under perspective transforms.
// Specifically, layers that may have their back face visible in orthographic
@@ -50,11 +48,11 @@ TEST(MathUtilTest, verifyBackfaceVisibilityForPerspective)
// Case 1: Layer is rotated by slightly more than 90 degrees, at the center of the
// prespective projection. In this case, the layer's back-side is visible to
// the camera.
- layerSpaceToProjectionPlane.makeIdentity();
- layerSpaceToProjectionPlane.applyPerspective(1);
- layerSpaceToProjectionPlane.translate3d(0, 0, 0);
- layerSpaceToProjectionPlane.rotate3d(0, 100, 0);
- EXPECT_TRUE(layerSpaceToProjectionPlane.isBackFaceVisible());
+ layerSpaceToProjectionPlane.MakeIdentity();
+ layerSpaceToProjectionPlane.ApplyPerspectiveDepth(1);
+ layerSpaceToProjectionPlane.Translate3d(0, 0, 0);
+ MathUtil::rotateEulerAngles(&layerSpaceToProjectionPlane, 0, 100, 0);
+ EXPECT_TRUE(MathUtil::isBackFaceVisible(layerSpaceToProjectionPlane));
// Case 2: Layer is rotated by slightly more than 90 degrees, but shifted off to the
// side of the camera. Because of the wide field-of-view, the layer's front
@@ -70,16 +68,16 @@ TEST(MathUtilTest, verifyBackfaceVisibilityForPerspective)
// back side of layer -->| \ /
// \./ <-- camera origin
//
- layerSpaceToProjectionPlane.makeIdentity();
- layerSpaceToProjectionPlane.applyPerspective(1);
- layerSpaceToProjectionPlane.translate3d(-10, 0, 0);
- layerSpaceToProjectionPlane.rotate3d(0, 100, 0);
- EXPECT_FALSE(layerSpaceToProjectionPlane.isBackFaceVisible());
+ layerSpaceToProjectionPlane.MakeIdentity();
+ layerSpaceToProjectionPlane.ApplyPerspectiveDepth(1);
+ layerSpaceToProjectionPlane.Translate3d(-10, 0, 0);
+ MathUtil::rotateEulerAngles(&layerSpaceToProjectionPlane, 0, 100, 0);
+ EXPECT_FALSE(MathUtil::isBackFaceVisible(layerSpaceToProjectionPlane));
// Case 3: Additionally rotating the layer by 180 degrees should of course show the
// opposite result of case 2.
- layerSpaceToProjectionPlane.rotate3d(0, 180, 0);
- EXPECT_TRUE(layerSpaceToProjectionPlane.isBackFaceVisible());
+ MathUtil::rotateEulerAngles(&layerSpaceToProjectionPlane, 0, 180, 0);
+ EXPECT_TRUE(MathUtil::isBackFaceVisible(layerSpaceToProjectionPlane));
}
TEST(MathUtilTest, verifyProjectionOfPerpendicularPlane)
@@ -87,9 +85,9 @@ TEST(MathUtilTest, verifyProjectionOfPerpendicularPlane)
// In this case, the m33() element of the transform becomes zero, which could cause a
// divide-by-zero when projecting points/quads.
- WebTransformationMatrix transform;
- transform.makeIdentity();
- transform.setM33(0);
+ gfx::Transform transform;
+ transform.MakeIdentity();
+ transform.matrix().setDouble(2, 2, 0);
gfx::RectF rect = gfx::RectF(0, 0, 1, 1);
gfx::RectF projectedRect = MathUtil::projectClippedRect(transform, rect);
@@ -293,7 +291,7 @@ TEST(MathUtilGfxTransformTest, verifyDefaultConstructorCreatesIdentityMatrix)
EXPECT_ROW2_EQ(0, 1, 0, 0, A);
EXPECT_ROW3_EQ(0, 0, 1, 0, A);
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
- EXPECT_TRUE(MathUtil::isIdentity(A));
+ EXPECT_TRUE(A.IsIdentity());
}
TEST(MathUtilGfxTransformTest, verifyCreateGfxTransformFor2dElements)
@@ -332,7 +330,7 @@ TEST(MathUtilGfxTransformTest, verifyMatrixInversion)
// Invert a translation
gfx::Transform translation;
translation.Translate3d(2, 3, 4);
- EXPECT_TRUE(MathUtil::isInvertible(translation));
+ EXPECT_TRUE(translation.IsInvertible());
gfx::Transform inverseTranslation = MathUtil::inverse(translation);
EXPECT_ROW1_EQ(1, 0, 0, -2, inverseTranslation);
@@ -349,7 +347,7 @@ TEST(MathUtilGfxTransformTest, verifyMatrixInversion)
// Invert a non-uniform scale
gfx::Transform scale;
scale.Scale3d(4, 10, 100);
- EXPECT_TRUE(MathUtil::isInvertible(scale));
+ EXPECT_TRUE(scale.IsInvertible());
gfx::Transform inverseScale = MathUtil::inverse(scale);
EXPECT_ROW1_EQ(0.25, 0, 0, 0, inverseScale);
@@ -364,12 +362,12 @@ TEST(MathUtilGfxTransformTest, verifyMatrixInversion)
notInvertible.matrix().setDouble(1, 1, 0);
notInvertible.matrix().setDouble(2, 2, 0);
notInvertible.matrix().setDouble(3, 3, 0);
- EXPECT_FALSE(MathUtil::isInvertible(notInvertible));
+ EXPECT_FALSE(notInvertible.IsInvertible());
gfx::Transform inverseOfNotInvertible;
initializeTestMatrix(&inverseOfNotInvertible); // initialize this to something non-identity, to make sure that assignment below actually took place.
inverseOfNotInvertible = MathUtil::inverse(notInvertible);
- EXPECT_TRUE(MathUtil::isIdentity(inverseOfNotInvertible));
+ EXPECT_TRUE(inverseOfNotInvertible.IsIdentity());
}
TEST(MathUtilGfxTransformTest, verifyTo2DTransform)
@@ -553,12 +551,12 @@ TEST(MathUtilGfxTransformTest, verifyMakeIdentiy)
{
gfx::Transform A;
initializeTestMatrix(&A);
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
EXPECT_ROW1_EQ(1, 0, 0, 0, A);
EXPECT_ROW2_EQ(0, 1, 0, 0, A);
EXPECT_ROW3_EQ(0, 0, 1, 0, A);
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
- EXPECT_TRUE(MathUtil::isIdentity(A));
+ EXPECT_TRUE(A.IsIdentity());
}
TEST(MathUtilGfxTransformTest, verifyTranslate)
@@ -571,7 +569,7 @@ TEST(MathUtilGfxTransformTest, verifyTranslate)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that Translate() post-multiplies the existing matrix.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Scale(5, 5);
A.Translate(2, 3);
EXPECT_ROW1_EQ(5, 0, 0, 10, A);
@@ -590,7 +588,7 @@ TEST(MathUtilGfxTransformTest, verifyTranslate3d)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that Translate3d() post-multiplies the existing matrix.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Scale3d(6, 7, 8);
A.Translate3d(2, 3, 4);
EXPECT_ROW1_EQ(6, 0, 0, 12, A);
@@ -609,7 +607,7 @@ TEST(MathUtilGfxTransformTest, verifyScale)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that Scale() post-multiplies the existing matrix.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Translate3d(2, 3, 4);
A.Scale(6, 7);
EXPECT_ROW1_EQ(6, 0, 0, 2, A);
@@ -628,7 +626,7 @@ TEST(MathUtilGfxTransformTest, verifyScale3d)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that scale3d() post-multiplies the existing matrix.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Translate3d(2, 3, 4);
A.Scale3d(6, 7, 8);
EXPECT_ROW1_EQ(6, 0, 0, 2, A);
@@ -647,7 +645,7 @@ TEST(MathUtilGfxTransformTest, verifyRotate)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that Rotate() post-multiplies the existing matrix.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Scale3d(6, 7, 8);
A.Rotate(90);
EXPECT_ROW1_NEAR(0, -6, 0, 0, A, ERROR_THRESHOLD);
@@ -661,7 +659,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateEulerAngles)
gfx::Transform A;
// Check rotation about z-axis
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
MathUtil::rotateEulerAngles(&A, 0, 0, 90);
EXPECT_ROW1_NEAR(0, -1, 0, 0, A, ERROR_THRESHOLD);
EXPECT_ROW2_NEAR(1, 0, 0, 0, A, ERROR_THRESHOLD);
@@ -669,7 +667,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateEulerAngles)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Check rotation about x-axis
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
MathUtil::rotateEulerAngles(&A, 90, 0, 0);
EXPECT_ROW1_EQ(1, 0, 0, 0, A);
EXPECT_ROW2_NEAR(0, 0, -1, 0, A, ERROR_THRESHOLD);
@@ -678,7 +676,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateEulerAngles)
// Check rotation about y-axis.
// Note carefully, the expected pattern is inverted compared to rotating about x axis or z axis.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
MathUtil::rotateEulerAngles(&A, 0, 90, 0);
EXPECT_ROW1_NEAR(0, 0, 1, 0, A, ERROR_THRESHOLD);
EXPECT_ROW2_EQ(0, 1, 0, 0, A);
@@ -686,7 +684,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateEulerAngles)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that rotate3d(rx, ry, rz) post-multiplies the existing matrix.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Scale3d(6, 7, 8);
MathUtil::rotateEulerAngles(&A, 0, 0, 90);
EXPECT_ROW1_NEAR(0, -6, 0, 0, A, ERROR_THRESHOLD);
@@ -711,7 +709,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateEulerAnglesOrderOfCompositeRotations)
// from the other orderings. That way, this test verifies the exact ordering.
gfx::Transform A;
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
MathUtil::rotateEulerAngles(&A, 10, 20, 30);
EXPECT_ROW1_NEAR(0.8137976813493738026394908,
@@ -734,7 +732,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateAxisAngleForAlignedAxes)
gfx::Transform A;
// Check rotation about z-axis
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
MathUtil::rotateAxisAngle(&A, 0, 0, 1, 90);
EXPECT_ROW1_NEAR(0, -1, 0, 0, A, ERROR_THRESHOLD);
EXPECT_ROW2_NEAR(1, 0, 0, 0, A, ERROR_THRESHOLD);
@@ -742,7 +740,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateAxisAngleForAlignedAxes)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Check rotation about x-axis
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
MathUtil::rotateAxisAngle(&A, 1, 0, 0, 90);
EXPECT_ROW1_EQ(1, 0, 0, 0, A);
EXPECT_ROW2_NEAR(0, 0, -1, 0, A, ERROR_THRESHOLD);
@@ -751,7 +749,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateAxisAngleForAlignedAxes)
// Check rotation about y-axis.
// Note carefully, the expected pattern is inverted compared to rotating about x axis or z axis.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
MathUtil::rotateAxisAngle(&A, 0, 1, 0, 90);
EXPECT_ROW1_NEAR(0, 0, 1, 0, A, ERROR_THRESHOLD);
EXPECT_ROW2_EQ(0, 1, 0, 0, A);
@@ -759,7 +757,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateAxisAngleForAlignedAxes)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that rotate3d(axis, angle) post-multiplies the existing matrix.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Scale3d(6, 7, 8);
MathUtil::rotateAxisAngle(&A, 0, 0, 1, 90);
EXPECT_ROW1_NEAR(0, -6, 0, 0, A, ERROR_THRESHOLD);
@@ -796,7 +794,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateAxisAngleForDegenerateAxis)
MathUtil::rotateAxisAngle(&A, 0, 0, 0, 45);
// Verify that A remains unchanged.
- EXPECT_TRUE(MathUtil::isIdentity(A));
+ EXPECT_TRUE(A.IsIdentity());
initializeTestMatrix(&A);
MathUtil::rotateAxisAngle(&A, 0, 0, 0, 35);
@@ -819,7 +817,7 @@ TEST(MathUtilGfxTransformTest, verifySkewX)
// Verify that skewX() post-multiplies the existing matrix.
// Row 1, column 2, would incorrectly have value "7" if the matrix is pre-multiplied instead of post-multiplied.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Scale3d(6, 7, 8);
A.SkewX(45);
EXPECT_ROW1_EQ(6, 6, 0, 0, A);
@@ -839,7 +837,7 @@ TEST(MathUtilGfxTransformTest, verifySkewY)
// Verify that skewY() post-multiplies the existing matrix.
// Row 2, column 1, would incorrectly have value "6" if the matrix is pre-multiplied instead of post-multiplied.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Scale3d(6, 7, 8);
A.SkewY(45);
EXPECT_ROW1_EQ(6, 0, 0, 0, A);
@@ -858,7 +856,7 @@ TEST(MathUtilGfxTransformTest, verifyPerspectiveDepth)
EXPECT_ROW4_EQ(0, 0, -1, 1, A);
// Verify that PerspectiveDepth() post-multiplies the existing matrix.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Translate3d(2, 3, 4);
A.ApplyPerspectiveDepth(1);
EXPECT_ROW1_EQ(1, 0, -2, 2, A);
@@ -873,27 +871,27 @@ TEST(MathUtilGfxTransformTest, verifyHasPerspective)
A.ApplyPerspectiveDepth(1);
EXPECT_TRUE(MathUtil::hasPerspective(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.ApplyPerspectiveDepth(0);
EXPECT_FALSE(MathUtil::hasPerspective(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 0, -1);
EXPECT_TRUE(MathUtil::hasPerspective(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 1, -1);
EXPECT_TRUE(MathUtil::hasPerspective(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 2, -0.3);
EXPECT_TRUE(MathUtil::hasPerspective(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 3, 0.5);
EXPECT_TRUE(MathUtil::hasPerspective(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 3, 0);
EXPECT_TRUE(MathUtil::hasPerspective(A));
}
@@ -903,55 +901,55 @@ TEST(MathUtilGfxTransformTest, verifyIsInvertible)
gfx::Transform A;
// Translations, rotations, scales, skews and arbitrary combinations of them are invertible.
- MathUtil::makeIdentity(&A);
- EXPECT_TRUE(MathUtil::isInvertible(A));
+ A.MakeIdentity();
+ EXPECT_TRUE(A.IsInvertible());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Translate3d(2, 3, 4);
- EXPECT_TRUE(MathUtil::isInvertible(A));
+ EXPECT_TRUE(A.IsInvertible());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.Scale3d(6, 7, 8);
- EXPECT_TRUE(MathUtil::isInvertible(A));
+ EXPECT_TRUE(A.IsInvertible());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
MathUtil::rotateEulerAngles(&A, 10, 20, 30);
- EXPECT_TRUE(MathUtil::isInvertible(A));
+ EXPECT_TRUE(A.IsInvertible());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.SkewX(45);
- EXPECT_TRUE(MathUtil::isInvertible(A));
+ EXPECT_TRUE(A.IsInvertible());
// A perspective matrix (projection plane at z=0) is invertible. The intuitive
// explanation is that perspective is eqivalent to a skew of the w-axis; skews are
// invertible.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.ApplyPerspectiveDepth(1);
- EXPECT_TRUE(MathUtil::isInvertible(A));
+ EXPECT_TRUE(A.IsInvertible());
// A "pure" perspective matrix derived by similar triangles, with m44() set to zero
// (i.e. camera positioned at the origin), is not invertible.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.ApplyPerspectiveDepth(1);
A.matrix().setDouble(3, 3, 0);
- EXPECT_FALSE(MathUtil::isInvertible(A));
+ EXPECT_FALSE(A.IsInvertible());
// Adding more to a non-invertible matrix will not make it invertible in the general case.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.ApplyPerspectiveDepth(1);
A.matrix().setDouble(3, 3, 0);
A.Scale3d(6, 7, 8);
MathUtil::rotateEulerAngles(&A, 10, 20, 30);
A.Translate3d(6, 7, 8);
- EXPECT_FALSE(MathUtil::isInvertible(A));
+ EXPECT_FALSE(A.IsInvertible());
// A degenerate matrix of all zeros is not invertible.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(0, 0, 0);
A.matrix().setDouble(1, 1, 0);
A.matrix().setDouble(2, 2, 0);
A.matrix().setDouble(3, 3, 0);
- EXPECT_FALSE(MathUtil::isInvertible(A));
+ EXPECT_FALSE(A.IsInvertible());
}
TEST(MathUtilGfxTransformTest, verifyIsIdentity)
@@ -959,75 +957,75 @@ TEST(MathUtilGfxTransformTest, verifyIsIdentity)
gfx::Transform A;
initializeTestMatrix(&A);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
- EXPECT_TRUE(MathUtil::isIdentity(A));
+ A.MakeIdentity();
+ EXPECT_TRUE(A.IsIdentity());
// Modifying any one individual element should cause the matrix to no longer be identity.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(0, 0, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(1, 0, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(2, 0, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 0, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(0, 1, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(1, 1, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(2, 1, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 1, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(0, 2, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(1, 2, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(2, 2, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 2, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(0, 3, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(1, 3, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(2, 3, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 3, 2);
- EXPECT_FALSE(MathUtil::isIdentity(A));
+ EXPECT_FALSE(A.IsIdentity());
}
TEST(MathUtilGfxTransformTest, verifyIsIdentityOrTranslation)
@@ -1037,76 +1035,76 @@ TEST(MathUtilGfxTransformTest, verifyIsIdentityOrTranslation)
initializeTestMatrix(&A);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A));
// Modifying any non-translation components should cause isIdentityOrTranslation() to
// return false. NOTE: (0, 3), (1, 3), and (2, 3) are the translation components, so
// modifying them should still return true for isIdentityOrTranslation().
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(0, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(1, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(2, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(0, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(1, 1, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(2, 1, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 1, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(0, 2, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(1, 2, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(2, 2, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 2, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
// Note carefully - expecting true here.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(0, 3, 2);
EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A));
// Note carefully - expecting true here.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(1, 3, 2);
EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A));
// Note carefully - expecting true here.
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(2, 3, 2);
EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A));
- MathUtil::makeIdentity(&A);
+ A.MakeIdentity();
A.matrix().setDouble(3, 3, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
}
diff --git a/cc/nine_patch_layer_impl_unittest.cc b/cc/nine_patch_layer_impl_unittest.cc
index 8645bba..db57ec2 100644
--- a/cc/nine_patch_layer_impl_unittest.cc
+++ b/cc/nine_patch_layer_impl_unittest.cc
@@ -16,7 +16,7 @@
#include "ui/gfx/safe_integer_conversions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
namespace cc {
namespace {
@@ -48,8 +48,8 @@ TEST(NinePatchLayerImplTest, verifyDrawQuads)
// This scale should not affect the generated quad geometry, but only
// the shared draw transform.
- WebKit::WebTransformationMatrix transform;
- transform.scale(10);
+ gfx::Transform transform;
+ transform.Scale(10, 10);
layer->setDrawTransform(transform);
AppendQuadsData data;
diff --git a/cc/occlusion_tracker.cc b/cc/occlusion_tracker.cc
index 513b330..4ea3d3c 100644
--- a/cc/occlusion_tracker.cc
+++ b/cc/occlusion_tracker.cc
@@ -14,7 +14,6 @@
#include "ui/gfx/rect_conversions.h"
using namespace std;
-using WebKit::WebTransformationMatrix;
namespace cc {
@@ -121,7 +120,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::finishedRenderTarget(co
}
template<typename RenderSurfaceType>
-static inline Region transformSurfaceOpaqueRegion(const RenderSurfaceType* surface, const Region& region, const WebTransformationMatrix& transform)
+static inline Region transformSurfaceOpaqueRegion(const RenderSurfaceType* surface, const Region& region, const gfx::Transform& transform)
{
// Verify that rects within the |surface| will remain rects in its target surface after applying |transform|. If this is true, then
// apply |transform| to each rect within |region| in order to transform the entire Region.
@@ -182,7 +181,7 @@ static inline void reduceOcclusion(const gfx::Rect& affectedArea, const gfx::Rec
}
template<typename LayerType>
-static void reduceOcclusionBelowSurface(LayerType* contributingLayer, const gfx::Rect& surfaceRect, const WebTransformationMatrix& surfaceTransform, LayerType* renderTarget, Region& occlusionInTarget, Region& occlusionInScreen)
+static void reduceOcclusionBelowSurface(LayerType* contributingLayer, const gfx::Rect& surfaceRect, const gfx::Transform& surfaceTransform, LayerType* renderTarget, Region& occlusionInTarget, Region& occlusionInScreen)
{
if (surfaceRect.IsEmpty())
return;
@@ -249,7 +248,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::leaveToRenderTarget(con
// FIXME: Remove usePaintTracking when paint tracking is on for paint culling.
template<typename LayerType>
-static inline void addOcclusionBehindLayer(Region& region, const LayerType* layer, const WebTransformationMatrix& transform, const Region& opaqueContents, const gfx::Rect& clipRectInTarget, const gfx::Size& minimumTrackingSize, std::vector<gfx::Rect>* occludingScreenSpaceRects, std::vector<gfx::Rect>* nonOccludingScreenSpaceRects)
+static inline void addOcclusionBehindLayer(Region& region, const LayerType* layer, const gfx::Transform& transform, const Region& opaqueContents, const gfx::Rect& clipRectInTarget, const gfx::Size& minimumTrackingSize, std::vector<gfx::Rect>* occludingScreenSpaceRects, std::vector<gfx::Rect>* nonOccludingScreenSpaceRects)
{
DCHECK(layer->visibleContentRect().Contains(opaqueContents.bounds()));
@@ -309,7 +308,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer
// remain rectilinear, then we don't add any occlusion in screen space.
if (layerTransformsToScreenKnown(layer)) {
- WebTransformationMatrix targetToScreenTransform = m_stack.back().target->renderSurface()->screenSpaceTransform();
+ gfx::Transform targetToScreenTransform = m_stack.back().target->renderSurface()->screenSpaceTransform();
bool clipped;
gfx::QuadF clipQuadInScreen = MathUtil::mapQuad(targetToScreenTransform, gfx::QuadF(clipRectInTarget), clipped);
// FIXME: Find a rect interior to the transformed clip quad.
@@ -320,7 +319,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer
}
}
-static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const WebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRectInTarget, const Region& occlusion)
+static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const gfx::Transform& contentSpaceTransform, const gfx::Rect& clipRectInTarget, const Region& occlusion)
{
gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform, gfx::RectF(contentRect));
// Take the gfx::ToEnclosingRect, as we want to include partial pixels in the test.
@@ -329,7 +328,7 @@ static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const W
}
template<typename LayerType, typename RenderSurfaceType>
-bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerType* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const
+bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerType* renderTarget, const gfx::Rect& contentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const
{
if (hasOcclusionFromOutsideTargetSurface)
*hasOcclusionFromOutsideTargetSurface = false;
@@ -368,21 +367,21 @@ static inline gfx::Rect rectSubtractRegion(const gfx::Rect& rect, const Region&
return rectRegion.bounds();
}
-static inline gfx::Rect computeUnoccludedContentRect(const gfx::Rect& contentRect, const WebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRectInTarget, const Region& occlusion)
+static inline gfx::Rect computeUnoccludedContentRect(const gfx::Rect& contentRect, const gfx::Transform& contentSpaceTransform, const gfx::Rect& clipRectInTarget, const Region& occlusion)
{
- if (!contentSpaceTransform.isInvertible())
+ if (!contentSpaceTransform.IsInvertible())
return contentRect;
// Take the ToEnclosingRect at each step, as we want to contain any unoccluded partial pixels in the resulting Rect.
gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform, gfx::RectF(contentRect));
gfx::Rect shrunkRect = rectSubtractRegion(gfx::IntersectRects(gfx::ToEnclosingRect(transformedRect), clipRectInTarget), occlusion);
- gfx::Rect unoccludedRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(contentSpaceTransform.inverse(), gfx::RectF(shrunkRect)));
+ gfx::Rect unoccludedRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(MathUtil::inverse(contentSpaceTransform), gfx::RectF(shrunkRect)));
// The rect back in content space is a bounding box and may extend outside of the original contentRect, so clamp it to the contentRectBounds.
return gfx::IntersectRects(unoccludedRect, contentRect);
}
template<typename LayerType, typename RenderSurfaceType>
-gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentRect(const LayerType* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const
+gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentRect(const LayerType* renderTarget, const gfx::Rect& contentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const
{
DCHECK(!m_stack.empty());
if (m_stack.empty())
@@ -439,8 +438,8 @@ gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContribu
// found just below the top of the stack (if it exists).
bool hasOcclusion = m_stack.size() > 1;
- const WebTransformationMatrix& transformToScreen = forReplica ? surface->replicaScreenSpaceTransform() : surface->screenSpaceTransform();
- const WebTransformationMatrix& transformToTarget = forReplica ? surface->replicaDrawTransform() : surface->drawTransform();
+ const gfx::Transform& transformToScreen = forReplica ? surface->replicaScreenSpaceTransform() : surface->screenSpaceTransform();
+ const gfx::Transform& transformToTarget = forReplica ? surface->replicaDrawTransform() : surface->drawTransform();
gfx::Rect unoccludedInScreen = contentRect;
if (surfaceTransformsToScreenKnown(surface)) {
diff --git a/cc/occlusion_tracker.h b/cc/occlusion_tracker.h
index 7698103..96df92e 100644
--- a/cc/occlusion_tracker.h
+++ b/cc/occlusion_tracker.h
@@ -35,9 +35,9 @@ public:
void leaveLayer(const LayerIteratorPosition<LayerType>&);
// Returns true if the given rect in content space for a layer is fully occluded in either screen space or the layer's target surface. |renderTarget| is the contributing layer's render target, and |drawTransform|, |transformsToTargetKnown| and |clippedRectInTarget| are relative to that.
- bool occluded(const LayerType* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
+ bool occluded(const LayerType* renderTarget, const gfx::Rect& contentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
// Gives an unoccluded sub-rect of |contentRect| in the content space of a layer. Used when considering occlusion for a layer that paints/draws something. |renderTarget| is the contributing layer's render target, and |drawTransform|, |transformsToTargetKnown| and |clippedRectInTarget| are relative to that.
- gfx::Rect unoccludedContentRect(const LayerType* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
+ gfx::Rect unoccludedContentRect(const LayerType* renderTarget, const gfx::Rect& contentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
// Gives an unoccluded sub-rect of |contentRect| in the content space of the renderTarget owned by the layer.
// Used when considering occlusion for a contributing surface that is rendering into another target.
diff --git a/cc/occlusion_tracker_unittest.cc b/cc/occlusion_tracker_unittest.cc
index fac2f02..c46e8fd 100644
--- a/cc/occlusion_tracker_unittest.cc
+++ b/cc/occlusion_tracker_unittest.cc
@@ -4,6 +4,9 @@
#include "cc/occlusion_tracker.h"
+#include <public/WebFilterOperation.h>
+#include <public/WebFilterOperations.h>
+
#include "cc/layer.h"
#include "cc/layer_animation_controller.h"
#include "cc/layer_impl.h"
@@ -16,9 +19,7 @@
#include "cc/test/occlusion_tracker_test_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebFilterOperation.h>
-#include <public/WebFilterOperations.h>
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using namespace WebKit;
using namespace WebKitTests;
@@ -197,7 +198,7 @@ protected:
LayerTreeHost::setNeedsFilterContext(false);
}
- typename Types::ContentLayerType* createRoot(const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
+ typename Types::ContentLayerType* createRoot(const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
typename Types::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get();
@@ -208,7 +209,7 @@ protected:
return layerPtr;
}
- typename Types::LayerType* createLayer(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
+ typename Types::LayerType* createLayer(typename Types::LayerType* parent, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
typename Types::LayerPtrType layer(Types::createLayer());
typename Types::LayerType* layerPtr = layer.get();
@@ -217,7 +218,7 @@ protected:
return layerPtr;
}
- typename Types::LayerType* createSurface(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
+ typename Types::LayerType* createSurface(typename Types::LayerType* parent, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
typename Types::LayerType* layer = createLayer(parent, transform, position, bounds);
WebFilterOperations filters;
@@ -226,7 +227,7 @@ protected:
return layer;
}
- typename Types::ContentLayerType* createDrawingLayer(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
+ typename Types::ContentLayerType* createDrawingLayer(typename Types::LayerType* parent, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
{
typename Types::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get();
@@ -246,7 +247,7 @@ protected:
return layerPtr;
}
- typename Types::LayerType* createReplicaLayer(typename Types::LayerType* owningLayer, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
+ typename Types::LayerType* createReplicaLayer(typename Types::LayerType* owningLayer, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
typename Types::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get();
@@ -264,7 +265,7 @@ protected:
return layerPtr;
}
- typename Types::ContentLayerType* createDrawingSurface(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
+ typename Types::ContentLayerType* createDrawingSurface(typename Types::LayerType* parent, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
{
typename Types::ContentLayerType* layer = createDrawingLayer(parent, transform, position, bounds, opaque);
WebFilterOperations filters;
@@ -349,24 +350,24 @@ protected:
m_layerIterator = m_layerIteratorBegin;
}
- const WebTransformationMatrix identityMatrix;
+ const gfx::Transform identityMatrix;
private:
- void setBaseProperties(typename Types::LayerType* layer, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
+ void setBaseProperties(typename Types::LayerType* layer, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
layer->setTransform(transform);
- layer->setSublayerTransform(WebTransformationMatrix());
+ layer->setSublayerTransform(gfx::Transform());
layer->setAnchorPoint(gfx::PointF(0, 0));
layer->setPosition(position);
layer->setBounds(bounds);
}
- void setProperties(Layer* layer, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
+ void setProperties(Layer* layer, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
setBaseProperties(layer, transform, position, bounds);
}
- void setProperties(LayerImpl* layer, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
+ void setProperties(LayerImpl* layer, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
setBaseProperties(layer, transform, position, bounds);
@@ -503,8 +504,8 @@ protected:
OcclusionTrackerTestQuadsMismatchLayer(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix layerTransform;
- layerTransform.translate(10, 10);
+ gfx::Transform layerTransform;
+ layerTransform.Translate(10, 10);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::Point(0, 0), gfx::Size(100, 100));
typename Types::ContentLayerType* layer1 = this->createDrawingLayer(parent, layerTransform, gfx::PointF(0, 0), gfx::Size(90, 90), true);
@@ -523,8 +524,8 @@ protected:
// layers, e.g. in terms of transforms or clip rect. This is typical for
// DelegatedRendererLayer.
- WebTransformationMatrix quadTransform;
- quadTransform.translate(30, 30);
+ gfx::Transform quadTransform;
+ quadTransform.Translate(30, 30);
gfx::Rect clipRectInTarget(0, 0, 100, 100);
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, gfx::Rect(0, 0, 10, 10), quadTransform, false, clipRectInTarget).IsEmpty());
@@ -543,10 +544,10 @@ protected:
OcclusionTrackerTestRotatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix layerTransform;
- layerTransform.translate(250, 250);
- layerTransform.rotate(90);
- layerTransform.translate(-250, -250);
+ gfx::Transform layerTransform;
+ layerTransform.Translate(250, 250);
+ layerTransform.Rotate(90);
+ layerTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, layerTransform, gfx::PointF(30, 30), gfx::Size(500, 500), true);
@@ -595,8 +596,8 @@ protected:
OcclusionTrackerTestTranslatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix layerTransform;
- layerTransform.translate(20, 20);
+ gfx::Transform layerTransform;
+ layerTransform.Translate(20, 20);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, layerTransform, gfx::PointF(30, 30), gfx::Size(500, 500), true);
@@ -657,10 +658,10 @@ protected:
OcclusionTrackerTestChildInRotatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix childTransform;
- childTransform.translate(250, 250);
- childTransform.rotate(90);
- childTransform.translate(-250, -250);
+ gfx::Transform childTransform;
+ childTransform.Translate(250, 250);
+ childTransform.Rotate(90);
+ childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@@ -737,13 +738,13 @@ protected:
{
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(200, 200));
- WebTransformationMatrix layer1Matrix;
- layer1Matrix.scale(2);
+ gfx::Transform layer1Matrix;
+ layer1Matrix.Scale(2, 2);
typename Types::ContentLayerType* layer1 = this->createDrawingLayer(parent, layer1Matrix, gfx::PointF(0, 0), gfx::Size(100, 100), true);
layer1->setForceRenderSurface(true);
- WebTransformationMatrix layer2Matrix;
- layer2Matrix.translate(25, 25);
+ gfx::Transform layer2Matrix;
+ layer2Matrix.Translate(25, 25);
typename Types::ContentLayerType* layer2 = this->createDrawingLayer(layer1, layer2Matrix, gfx::PointF(0, 0), gfx::Size(50, 50), true);
typename Types::ContentLayerType* occluder = this->createDrawingLayer(parent, this->identityMatrix, gfx::PointF(100, 100), gfx::Size(500, 500), true);
this->calcDrawEtc(parent);
@@ -771,10 +772,10 @@ protected:
OcclusionTrackerTestVisitTargetTwoTimes(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix childTransform;
- childTransform.translate(250, 250);
- childTransform.rotate(90);
- childTransform.translate(-250, -250);
+ gfx::Transform childTransform;
+ childTransform.Translate(250, 250);
+ childTransform.Rotate(90);
+ childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@@ -876,13 +877,13 @@ protected:
OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix childTransform;
- childTransform.translate(250, 250);
- childTransform.rotate(95);
- childTransform.translate(-250, -250);
+ gfx::Transform childTransform;
+ childTransform.Translate(250, 250);
+ childTransform.Rotate(95);
+ childTransform.Translate(-250, -250);
- WebTransformationMatrix layerTransform;
- layerTransform.translate(10, 10);
+ gfx::Transform layerTransform;
+ layerTransform.Translate(10, 10);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
typename Types::LayerType* child = this->createLayer(parent, childTransform, gfx::PointF(30, 30), gfx::Size(500, 500));
@@ -939,10 +940,10 @@ protected:
OcclusionTrackerTestSurfaceWithTwoOpaqueChildren(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix childTransform;
- childTransform.translate(250, 250);
- childTransform.rotate(90);
- childTransform.translate(-250, -250);
+ gfx::Transform childTransform;
+ childTransform.Translate(250, 250);
+ childTransform.Rotate(90);
+ childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@@ -1025,10 +1026,10 @@ protected:
OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix childTransform;
- childTransform.translate(250, 250);
- childTransform.rotate(90);
- childTransform.translate(-250, -250);
+ gfx::Transform childTransform;
+ childTransform.Translate(250, 250);
+ childTransform.Rotate(90);
+ childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@@ -1130,15 +1131,15 @@ protected:
OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix child1Transform;
- child1Transform.translate(250, 250);
- child1Transform.rotate(-90);
- child1Transform.translate(-250, -250);
+ gfx::Transform child1Transform;
+ child1Transform.Translate(250, 250);
+ child1Transform.Rotate(-90);
+ child1Transform.Translate(-250, -250);
- WebTransformationMatrix child2Transform;
- child2Transform.translate(250, 250);
- child2Transform.rotate(90);
- child2Transform.translate(-250, -250);
+ gfx::Transform child2Transform;
+ child2Transform.Translate(250, 250);
+ child2Transform.Rotate(90);
+ child2Transform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@@ -1233,10 +1234,10 @@ protected:
OcclusionTrackerTestFilters(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix layerTransform;
- layerTransform.translate(250, 250);
- layerTransform.rotate(90);
- layerTransform.translate(-250, -250);
+ gfx::Transform layerTransform;
+ layerTransform.Translate(250, 250);
+ layerTransform.Rotate(90);
+ layerTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@@ -1867,8 +1868,8 @@ protected:
OcclusionTrackerTest3dTransform(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix transform;
- transform.rotate3d(0, 30, 0);
+ gfx::Transform transform;
+ MathUtil::rotateEulerAngles(&transform, 0, 30, 0);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
@@ -1898,10 +1899,10 @@ protected:
// behavior is that a 3d layer simply does not add any occlusion to the occlusion
// tracker.
- WebTransformationMatrix translationToFront;
- translationToFront.translate3d(0, 0, -10);
- WebTransformationMatrix translationToBack;
- translationToFront.translate3d(0, 0, -100);
+ gfx::Transform translationToFront;
+ translationToFront.Translate3d(0, 0, -10);
+ gfx::Transform translationToBack;
+ translationToFront.Translate3d(0, 0, -100);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
typename Types::ContentLayerType* child1 = this->createDrawingLayer(parent, translationToBack, gfx::PointF(0, 0), gfx::Size(100, 100), true);
@@ -1930,11 +1931,11 @@ protected:
OcclusionTrackerTestPerspectiveTransform(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix transform;
- transform.translate(150, 150);
- transform.applyPerspective(400);
- transform.rotate3d(1, 0, 0, -30);
- transform.translate(-150, -150);
+ gfx::Transform transform;
+ transform.Translate(150, 150);
+ transform.ApplyPerspectiveDepth(400);
+ MathUtil::rotateAxisAngle(&transform, 1, 0, 0, -30);
+ transform.Translate(-150, -150);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
@@ -1960,13 +1961,13 @@ protected:
void runMyTest()
{
// This test is based on the platform/chromium/compositing/3d-corners.html layout test.
- WebTransformationMatrix transform;
- transform.translate(250, 50);
- transform.applyPerspective(10);
- transform.translate(-250, -50);
- transform.translate(250, 50);
- transform.rotate3d(1, 0, 0, -167);
- transform.translate(-250, -50);
+ gfx::Transform transform;
+ transform.Translate(250, 50);
+ transform.ApplyPerspectiveDepth(10);
+ transform.Translate(-250, -50);
+ transform.Translate(250, 50);
+ MathUtil::rotateAxisAngle(&transform, 1, 0, 0, -167);
+ transform.Translate(-250, -50);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 100));
typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 500));
@@ -1993,11 +1994,11 @@ protected:
OcclusionTrackerTestLayerBehindCameraDoesNotOcclude(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix transform;
- transform.translate(50, 50);
- transform.applyPerspective(100);
- transform.translate3d(0, 0, 110);
- transform.translate(-50, -50);
+ gfx::Transform transform;
+ transform.Translate(50, 50);
+ transform.ApplyPerspectiveDepth(100);
+ transform.Translate3d(0, 0, 110);
+ transform.Translate(-50, -50);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, transform, gfx::PointF(0, 0), gfx::Size(100, 100), true);
@@ -2024,11 +2025,11 @@ protected:
OcclusionTrackerTestLargePixelsOccludeInsideClipRect(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix transform;
- transform.translate(50, 50);
- transform.applyPerspective(100);
- transform.translate3d(0, 0, 99);
- transform.translate(-50, -50);
+ gfx::Transform transform;
+ transform.Translate(50, 50);
+ transform.ApplyPerspectiveDepth(100);
+ transform.Translate3d(0, 0, 99);
+ transform.Translate(-50, -50);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@@ -2249,10 +2250,10 @@ protected:
OcclusionTrackerTestSurfaceOcclusionTranslatesToParent(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix surfaceTransform;
- surfaceTransform.translate(300, 300);
- surfaceTransform.scale(2);
- surfaceTransform.translate(-150, -150);
+ gfx::Transform surfaceTransform;
+ surfaceTransform.Translate(300, 300);
+ surfaceTransform.Scale(2, 2);
+ surfaceTransform.Translate(-150, -150);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 500));
typename Types::ContentLayerType* surface = this->createDrawingSurface(parent, surfaceTransform, gfx::PointF(0, 0), gfx::Size(300, 300), false);
@@ -2563,8 +2564,8 @@ protected:
OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix scaleByHalf;
- scaleByHalf.scale(0.5);
+ gfx::Transform scaleByHalf;
+ scaleByHalf.Scale(0.5, 0.5);
// Make a surface and its replica, each 50x50, that are completely surrounded by opaque layers which are above them in the z-order.
// The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface
@@ -2694,8 +2695,8 @@ protected:
OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix scaleByHalf;
- scaleByHalf.scale(0.5);
+ gfx::Transform scaleByHalf;
+ scaleByHalf.Scale(0.5, 0.5);
// Makes two surfaces that completely cover |parent|. The occlusion both above and below the filters will be reduced by each of them.
typename Types::ContentLayerType* root = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(75, 75));
@@ -2879,8 +2880,8 @@ protected:
OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix scaleByHalf;
- scaleByHalf.scale(0.5);
+ gfx::Transform scaleByHalf;
+ scaleByHalf.Scale(0.5, 0.5);
// Make a surface and its replica, each 50x50, with a smaller 30x30 layer centered below each.
// The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface
@@ -2927,8 +2928,8 @@ protected:
OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix scaleByHalf;
- scaleByHalf.scale(0.5);
+ gfx::Transform scaleByHalf;
+ scaleByHalf.Scale(0.5, 0.5);
// Make a surface and its replica, each 50x50, that are completely occluded by opaque layers which are above them in the z-order.
// The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface
@@ -2974,8 +2975,8 @@ protected:
OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
- WebTransformationMatrix scaleByHalf;
- scaleByHalf.scale(0.5);
+ gfx::Transform scaleByHalf;
+ scaleByHalf.Scale(0.5, 0.5);
// Make a surface and its replica, each 50x50, that are partially occluded by opaque layers which are above them in the z-order.
// The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface
diff --git a/cc/overdraw_metrics.cc b/cc/overdraw_metrics.cc
index 1f94357..8f4df24 100644
--- a/cc/overdraw_metrics.cc
+++ b/cc/overdraw_metrics.cc
@@ -11,9 +11,7 @@
#include "cc/math_util.h"
#include "ui/gfx/quad_f.h"
#include "ui/gfx/rect.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
@@ -49,7 +47,7 @@ static inline float polygonArea(const gfx::PointF points[8], int numPoints)
}
// Takes a given quad, maps it by the given transformation, and gives the area of the resulting polygon.
-static inline float areaOfMappedQuad(const WebTransformationMatrix& transform, const gfx::QuadF& quad)
+static inline float areaOfMappedQuad(const gfx::Transform& transform, const gfx::QuadF& quad)
{
gfx::PointF clippedQuad[8];
int numVerticesInClippedQuad = 0;
@@ -71,7 +69,7 @@ void OverdrawMetrics::didCullTilesForUpload(int count)
m_tilesCulledForUpload += count;
}
-void OverdrawMetrics::didUpload(const WebTransformationMatrix& transformToTarget, const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect)
+void OverdrawMetrics::didUpload(const gfx::Transform& transformToTarget, const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect)
{
if (!m_recordMetricsForFrame)
return;
@@ -99,7 +97,7 @@ void OverdrawMetrics::didUseRenderSurfaceTextureMemoryBytes(size_t renderSurface
m_renderSurfaceTextureUseBytes += renderSurfaceUseBytes;
}
-void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transformToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect)
+void OverdrawMetrics::didCullForDrawing(const gfx::Transform& transformToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect)
{
if (!m_recordMetricsForFrame)
return;
@@ -110,7 +108,7 @@ void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transform
m_pixelsCulledForDrawing += beforeCullArea - afterCullArea;
}
-void OverdrawMetrics::didDraw(const WebTransformationMatrix& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect)
+void OverdrawMetrics::didDraw(const gfx::Transform& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect)
{
if (!m_recordMetricsForFrame)
return;
diff --git a/cc/overdraw_metrics.h b/cc/overdraw_metrics.h
index 46916bf..81595e7 100644
--- a/cc/overdraw_metrics.h
+++ b/cc/overdraw_metrics.h
@@ -9,10 +9,7 @@
namespace gfx {
class Rect;
-}
-
-namespace WebKit {
-class WebTransformationMatrix;
+class Transform;
}
namespace cc {
@@ -31,7 +28,7 @@ public:
// Records that an invalid tile was culled and did not need to be painted/uploaded, and did not contribute to other tiles needing to be painted.
void didCullTilesForUpload(int count);
// Records pixels that were uploaded to texture memory.
- void didUpload(const WebKit::WebTransformationMatrix& transformToTarget, const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect);
+ void didUpload(const gfx::Transform& transformToTarget, const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect);
// Record contents texture(s) behind present using the given number of bytes.
void didUseContentsTextureMemoryBytes(size_t contentsTextureUseBytes);
// Record RenderSurfaceImpl texture(s) being present using the given number of bytes.
@@ -40,9 +37,9 @@ public:
// These methods are used for saving metrics during draw.
// Record pixels that were not drawn to screen.
- void didCullForDrawing(const WebKit::WebTransformationMatrix& transformToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect);
+ void didCullForDrawing(const gfx::Transform& transformToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect);
// Record pixels that were drawn to screen.
- void didDraw(const WebKit::WebTransformationMatrix& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect);
+ void didDraw(const gfx::Transform& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect);
void recordMetrics(const LayerTreeHost*) const;
void recordMetrics(const LayerTreeHostImpl*) const;
diff --git a/cc/quad_culler.cc b/cc/quad_culler.cc
index 41c1550..ca79ac1 100644
--- a/cc/quad_culler.cc
+++ b/cc/quad_culler.cc
@@ -12,7 +12,7 @@
#include "cc/overdraw_metrics.h"
#include "cc/render_pass.h"
#include "third_party/skia/include/core/SkColor.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using namespace std;
diff --git a/cc/quad_culler_unittest.cc b/cc/quad_culler_unittest.cc
index 82de2bb..110a1af 100644
--- a/cc/quad_culler_unittest.cc
+++ b/cc/quad_culler_unittest.cc
@@ -14,9 +14,7 @@
#include "cc/tiled_layer_impl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
namespace {
@@ -38,7 +36,7 @@ private:
typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType;
-static scoped_ptr<TiledLayerImpl> makeLayer(TiledLayerImpl* parent, const WebTransformationMatrix& drawTransform, const gfx::Rect& layerRect, float opacity, bool opaque, const gfx::Rect& layerOpaqueRect, std::vector<LayerImpl*>& surfaceLayerList)
+static scoped_ptr<TiledLayerImpl> makeLayer(TiledLayerImpl* parent, const gfx::Transform& drawTransform, const gfx::Rect& layerRect, float opacity, bool opaque, const gfx::Rect& layerOpaqueRect, std::vector<LayerImpl*>& surfaceLayerList)
{
scoped_ptr<TiledLayerImpl> layer = TiledLayerImpl::create(1);
scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(100, 100), LayerTilingData::NoBorderTexels);
@@ -89,7 +87,7 @@ static void appendQuads(QuadList& quadList, SharedQuadStateList& sharedStateList
QuadList quadList; \
SharedQuadStateList sharedStateList; \
std::vector<LayerImpl*> renderSurfaceLayerList; \
- WebTransformationMatrix childTransform; \
+ gfx::Transform childTransform; \
gfx::Size rootSize = gfx::Size(300, 300); \
gfx::Rect rootRect = gfx::Rect(rootSize); \
gfx::Size childSize = gfx::Size(200, 200); \
@@ -99,8 +97,8 @@ TEST(QuadCullerTest, verifyNoCulling)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
- scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, false, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Transform(), childRect, 1, false, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -116,8 +114,8 @@ TEST(QuadCullerTest, verifyCullChildLinesUpTopLeft)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
- scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Transform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -133,7 +131,7 @@ TEST(QuadCullerTest, verifyCullWhenChildOpacityNotOne)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 0.9f, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -150,7 +148,7 @@ TEST(QuadCullerTest, verifyCullWhenChildOpaqueFlagFalse)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -167,9 +165,9 @@ TEST(QuadCullerTest, verifyCullCenterTileOnly)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- childTransform.translate(50, 50);
+ childTransform.Translate(50, 50);
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -202,13 +200,13 @@ TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize1)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- childTransform.translate(100, 100);
+ childTransform.Translate(100, 100);
// Make the root layer's quad have extent (99.1, 99.1) -> (200.9, 200.9) to make
// sure it doesn't get culled due to transform rounding.
- WebTransformationMatrix rootTransform;
- rootTransform.translate(99.1, 99.1);
- rootTransform.scale(1.018);
+ gfx::Transform rootTransform;
+ rootTransform.Translate(99.1, 99.1);
+ rootTransform.Scale(1.018, 1.018);
rootRect = childRect = gfx::Rect(0, 0, 100, 100);
@@ -232,11 +230,11 @@ TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize2)
// Make the child's quad slightly smaller than, and centred over, the root layer tile.
// Verify the child does not cause the quad below to be culled due to rounding.
- childTransform.translate(100.1, 100.1);
- childTransform.scale(0.982);
+ childTransform.Translate(100.1, 100.1);
+ childTransform.Scale(0.982, 0.982);
- WebTransformationMatrix rootTransform;
- rootTransform.translate(100, 100);
+ gfx::Transform rootTransform;
+ rootTransform.Translate(100, 100);
rootRect = childRect = gfx::Rect(0, 0, 100, 100);
@@ -258,9 +256,9 @@ TEST(QuadCullerTest, verifyCullChildLinesUpBottomRight)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- childTransform.translate(100, 100);
+ childTransform.Translate(100, 100);
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -277,9 +275,9 @@ TEST(QuadCullerTest, verifyCullSubRegion)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- childTransform.translate(50, 50);
+ childTransform.Translate(50, 50);
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
gfx::Rect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2);
scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
@@ -297,9 +295,9 @@ TEST(QuadCullerTest, verifyCullSubRegion2)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- childTransform.translate(50, 10);
+ childTransform.Translate(50, 10);
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
gfx::Rect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() * 3 / 4);
scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
@@ -317,9 +315,9 @@ TEST(QuadCullerTest, verifyCullSubRegionCheckOvercull)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- childTransform.translate(50, 49);
+ childTransform.Translate(50, 49);
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
gfx::Rect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2);
scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
@@ -338,9 +336,9 @@ TEST(QuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude)
DECLARE_AND_INITIALIZE_TEST_QUADS
// Use a small rotation so as to not disturb the geometry significantly.
- childTransform.rotate(1);
+ childTransform.Rotate(1);
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -363,11 +361,11 @@ TEST(QuadCullerTest, verifyNonAxisAlignedQuadsSafelyCulled)
DECLARE_AND_INITIALIZE_TEST_QUADS
// Use a small rotation so as to not disturb the geometry significantly.
- WebTransformationMatrix parentTransform;
- parentTransform.rotate(1);
+ gfx::Transform parentTransform;
+ parentTransform.Rotate(1);
scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, parentTransform, rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
- scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Transform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -383,8 +381,8 @@ TEST(QuadCullerTest, verifyCullOutsideScissorOverTile)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
- scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Transform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(200, 100, 100, 100));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -400,8 +398,8 @@ TEST(QuadCullerTest, verifyCullOutsideScissorOverCulledTile)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
- scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Transform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(100, 100, 100, 100));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -417,8 +415,8 @@ TEST(QuadCullerTest, verifyCullOutsideScissorOverPartialTiles)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
- scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Transform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(50, 50, 200, 200));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -434,8 +432,8 @@ TEST(QuadCullerTest, verifyCullOutsideScissorOverNoTiles)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
- scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Transform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(500, 500, 100, 100));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@@ -451,8 +449,8 @@ TEST(QuadCullerTest, verifyWithoutMetrics)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
- scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
+ scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Transform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(50, 50, 200, 200), false);
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
diff --git a/cc/render_pass.cc b/cc/render_pass.cc
index 0a8dc48..2d49907 100644
--- a/cc/render_pass.cc
+++ b/cc/render_pass.cc
@@ -6,8 +6,6 @@
#include "third_party/skia/include/core/SkImageFilter.h"
-using WebKit::WebTransformationMatrix;
-
namespace cc {
scoped_ptr<RenderPass> RenderPass::Create() {
@@ -44,7 +42,7 @@ scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const {
void RenderPass::SetNew(Id id,
gfx::Rect output_rect,
gfx::RectF damage_rect,
- const WebKit::WebTransformationMatrix& transform_to_root_target) {
+ const gfx::Transform& transform_to_root_target) {
DCHECK_GT(id.layer_id, 0);
DCHECK_GE(id.index, 0);
@@ -60,7 +58,7 @@ void RenderPass::SetNew(Id id,
void RenderPass::SetAll(Id id,
gfx::Rect output_rect,
gfx::RectF damage_rect,
- const WebKit::WebTransformationMatrix& transform_to_root_target,
+ const gfx::Transform& transform_to_root_target,
bool has_transparent_background,
bool has_occlusion_from_outside_target_surface,
const WebKit::WebFilterOperations& filters,
diff --git a/cc/render_pass.h b/cc/render_pass.h
index e14b5e6..4624757 100644
--- a/cc/render_pass.h
+++ b/cc/render_pass.h
@@ -5,6 +5,9 @@
#ifndef CC_RENDER_PASS_H_
#define CC_RENDER_PASS_H_
+#include <public/WebFilterOperations.h>
+#include <vector>
+
#include "base/basictypes.h"
#include "cc/cc_export.h"
#include "cc/draw_quad.h"
@@ -14,9 +17,7 @@
#include "cc/shared_quad_state.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect_f.h"
-#include <public/WebFilterOperations.h>
-#include <public/WebTransformationMatrix.h>
-#include <vector>
+#include "ui/gfx/transform.h"
class SkImageFilter;
@@ -66,12 +67,12 @@ class CC_EXPORT RenderPass {
void SetNew(Id id,
gfx::Rect output_rect,
gfx::RectF damage_rect,
- const WebKit::WebTransformationMatrix& transform_to_root_target);
+ const gfx::Transform& transform_to_root_target);
void SetAll(Id id,
gfx::Rect output_rect,
gfx::RectF damage_rect,
- const WebKit::WebTransformationMatrix& transform_to_root_target,
+ const gfx::Transform& transform_to_root_target,
bool has_transparent_background,
bool has_occlusion_from_outside_target_surface,
const WebKit::WebFilterOperations& filters,
@@ -87,7 +88,7 @@ class CC_EXPORT RenderPass {
// Transforms from the origin of the |output_rect| to the origin of the root
// render pass' |output_rect|.
- WebKit::WebTransformationMatrix transform_to_root_target;
+ gfx::Transform transform_to_root_target;
// If false, the pixels in the render pass' texture are all opaque.
bool has_transparent_background;
diff --git a/cc/render_pass_unittest.cc b/cc/render_pass_unittest.cc
index f18f0f1..b84de4c 100644
--- a/cc/render_pass_unittest.cc
+++ b/cc/render_pass_unittest.cc
@@ -4,17 +4,18 @@
#include "cc/render_pass.h"
+#include <public/WebFilterOperations.h>
+
#include "cc/checkerboard_draw_quad.h"
+#include "cc/math_util.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/render_pass_test_common.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/effects/SkBlurImageFilter.h"
-#include <public/WebFilterOperations.h>
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using WebKit::WebFilterOperation;
using WebKit::WebFilterOperations;
-using WebKit::WebTransformationMatrix;
using WebKitTests::TestRenderPass;
namespace cc {
@@ -25,7 +26,7 @@ struct RenderPassSize {
RenderPass::Id m_id;
QuadList m_quadList;
SharedQuadStateList m_sharedQuadStateList;
- WebKit::WebTransformationMatrix m_transformToRootTarget;
+ gfx::Transform m_transformToRootTarget;
gfx::Rect m_outputRect;
gfx::RectF m_damageRect;
bool m_hasTransparentBackground;
@@ -39,7 +40,7 @@ TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads)
{
RenderPass::Id id(3, 2);
gfx::Rect outputRect(45, 22, 120, 13);
- WebTransformationMatrix transformToRoot(1, 0.5, 0.5, -0.5, -1, 0);
+ gfx::Transform transformToRoot = MathUtil::createGfxTransform(1, 0.5, 0.5, -0.5, -1, 0);
gfx::Rect damageRect(56, 123, 19, 43);
bool hasTransparentBackground = true;
bool hasOcclusionFromOutsideTargetSurface = true;
@@ -63,7 +64,7 @@ TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads)
// Stick a quad in the pass, this should not get copied.
scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create();
- sharedState->SetAll(WebTransformationMatrix(), gfx::Rect(), gfx::Rect(), gfx::Rect(), false, 1);
+ sharedState->SetAll(gfx::Transform(), gfx::Rect(), gfx::Rect(), gfx::Rect(), false, 1);
pass->AppendSharedQuadState(sharedState.Pass());
scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = CheckerboardDrawQuad::Create();
diff --git a/cc/render_surface.cc b/cc/render_surface.cc
index 0f083a3..6465dcf 100644
--- a/cc/render_surface.cc
+++ b/cc/render_surface.cc
@@ -6,9 +6,7 @@
#include "cc/layer.h"
#include "cc/math_util.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
diff --git a/cc/render_surface.h b/cc/render_surface.h
index 230f89d..c1c0b06 100644
--- a/cc/render_surface.h
+++ b/cc/render_surface.h
@@ -6,13 +6,14 @@
#ifndef CC_RENDER_SURFACE_H_
#define CC_RENDER_SURFACE_H_
+#include <vector>
+
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
+#include "cc/cc_export.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h"
-#include <public/WebTransformationMatrix.h>
-#include <vector>
-#include "cc/cc_export.h"
+#include "ui/gfx/transform.h"
namespace cc {
@@ -37,17 +38,17 @@ public:
// This goes from content space with the origin in the center of the rect being transformed to the target space with the origin in the top left of the
// rect being transformed. Position the rect so that the origin is in the center of it before applying this transform.
- const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; }
- void setDrawTransform(const WebKit::WebTransformationMatrix& drawTransform) { m_drawTransform = drawTransform; }
+ const gfx::Transform& drawTransform() const { return m_drawTransform; }
+ void setDrawTransform(const gfx::Transform& drawTransform) { m_drawTransform = drawTransform; }
- const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; }
- void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; }
+ const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
+ void setScreenSpaceTransform(const gfx::Transform& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; }
- const WebKit::WebTransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; }
- void setReplicaDrawTransform(const WebKit::WebTransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
+ const gfx::Transform& replicaDrawTransform() const { return m_replicaDrawTransform; }
+ void setReplicaDrawTransform(const gfx::Transform& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
- const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; }
- void setReplicaScreenSpaceTransform(const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; }
+ const gfx::Transform& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; }
+ void setReplicaScreenSpaceTransform(const gfx::Transform& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; }
bool targetSurfaceTransformsAreAnimating() const { return m_targetSurfaceTransformsAreAnimating; }
void setTargetSurfaceTransformsAreAnimating(bool animating) { m_targetSurfaceTransformsAreAnimating = animating; }
@@ -80,10 +81,10 @@ private:
float m_drawOpacity;
bool m_drawOpacityIsAnimating;
- WebKit::WebTransformationMatrix m_drawTransform;
- WebKit::WebTransformationMatrix m_screenSpaceTransform;
- WebKit::WebTransformationMatrix m_replicaDrawTransform;
- WebKit::WebTransformationMatrix m_replicaScreenSpaceTransform;
+ gfx::Transform m_drawTransform;
+ gfx::Transform m_screenSpaceTransform;
+ gfx::Transform m_replicaDrawTransform;
+ gfx::Transform m_replicaScreenSpaceTransform;
bool m_targetSurfaceTransformsAreAnimating;
bool m_screenSpaceTransformsAreAnimating;
diff --git a/cc/render_surface_impl.cc b/cc/render_surface_impl.cc
index 271d2e7..6be40d4 100644
--- a/cc/render_surface_impl.cc
+++ b/cc/render_surface_impl.cc
@@ -21,9 +21,7 @@
#include "cc/shared_quad_state.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "ui/gfx/rect_conversions.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
@@ -80,10 +78,10 @@ void RenderSurfaceImpl::dumpSurface(std::string* str, int indent) const
str->append(indentStr);
base::StringAppendF(str, "drawTransform: %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n",
- m_drawTransform.m11(), m_drawTransform.m12(), m_drawTransform.m13(), m_drawTransform.m14(),
- m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_drawTransform.m24(),
- m_drawTransform.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_drawTransform.m34(),
- m_drawTransform.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_drawTransform.m44());
+ m_drawTransform.matrix().getDouble(0, 0), m_drawTransform.matrix().getDouble(0, 1), m_drawTransform.matrix().getDouble(0, 2), m_drawTransform.matrix().getDouble(0, 3),
+ m_drawTransform.matrix().getDouble(1, 0), m_drawTransform.matrix().getDouble(1, 1), m_drawTransform.matrix().getDouble(1, 2), m_drawTransform.matrix().getDouble(1, 3),
+ m_drawTransform.matrix().getDouble(2, 0), m_drawTransform.matrix().getDouble(2, 1), m_drawTransform.matrix().getDouble(2, 2), m_drawTransform.matrix().getDouble(2, 3),
+ m_drawTransform.matrix().getDouble(3, 0), m_drawTransform.matrix().getDouble(3, 1), m_drawTransform.matrix().getDouble(3, 2), m_drawTransform.matrix().getDouble(3, 3));
str->append(indentStr);
base::StringAppendF(str, "damageRect is pos(%f, %f), size(%f, %f)\n",
@@ -199,7 +197,7 @@ void RenderSurfaceImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQ
DCHECK(!forReplica || m_owningLayer->hasReplica());
gfx::Rect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer);
- const WebTransformationMatrix& drawTransform = forReplica ? m_replicaDrawTransform : m_drawTransform;
+ const gfx::Transform& drawTransform = forReplica ? m_replicaDrawTransform : m_drawTransform;
SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(SharedQuadState::Create());
sharedQuadState->SetAll(drawTransform, m_contentRect, clippedRectInTarget, m_clipRect, m_isClipped, m_drawOpacity);
diff --git a/cc/render_surface_impl.h b/cc/render_surface_impl.h
index 340103a..9892c42 100644
--- a/cc/render_surface_impl.h
+++ b/cc/render_surface_impl.h
@@ -12,7 +12,7 @@
#include "cc/shared_quad_state.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
namespace cc {
@@ -46,17 +46,17 @@ public:
bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating; }
void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating) { m_drawOpacityIsAnimating = drawOpacityIsAnimating; }
- void setDrawTransform(const WebKit::WebTransformationMatrix& drawTransform) { m_drawTransform = drawTransform; }
- const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; }
+ void setDrawTransform(const gfx::Transform& drawTransform) { m_drawTransform = drawTransform; }
+ const gfx::Transform& drawTransform() const { return m_drawTransform; }
- void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; }
- const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; }
+ void setScreenSpaceTransform(const gfx::Transform& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; }
+ const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
- void setReplicaDrawTransform(const WebKit::WebTransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
- const WebKit::WebTransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; }
+ void setReplicaDrawTransform(const gfx::Transform& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
+ const gfx::Transform& replicaDrawTransform() const { return m_replicaDrawTransform; }
- void setReplicaScreenSpaceTransform(const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; }
- const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; }
+ void setReplicaScreenSpaceTransform(const gfx::Transform& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; }
+ const gfx::Transform& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; }
bool targetSurfaceTransformsAreAnimating() const { return m_targetSurfaceTransformsAreAnimating; }
void setTargetSurfaceTransformsAreAnimating(bool animating) { m_targetSurfaceTransformsAreAnimating = animating; }
@@ -100,10 +100,10 @@ private:
float m_drawOpacity;
bool m_drawOpacityIsAnimating;
- WebKit::WebTransformationMatrix m_drawTransform;
- WebKit::WebTransformationMatrix m_screenSpaceTransform;
- WebKit::WebTransformationMatrix m_replicaDrawTransform;
- WebKit::WebTransformationMatrix m_replicaScreenSpaceTransform;
+ gfx::Transform m_drawTransform;
+ gfx::Transform m_screenSpaceTransform;
+ gfx::Transform m_replicaDrawTransform;
+ gfx::Transform m_replicaScreenSpaceTransform;
bool m_targetSurfaceTransformsAreAnimating;
bool m_screenSpaceTransformsAreAnimating;
diff --git a/cc/render_surface_unittest.cc b/cc/render_surface_unittest.cc
index 837a3db..bae2b3c 100644
--- a/cc/render_surface_unittest.cc
+++ b/cc/render_surface_unittest.cc
@@ -14,9 +14,7 @@
#include "cc/test/mock_quad_culler.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
-
-using WebKit::WebTransformationMatrix;
+#include "ui/gfx/transform.h"
namespace cc {
namespace {
@@ -58,8 +56,8 @@ TEST(RenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(testRect));
scoped_ptr<LayerImpl> dummyMask = LayerImpl::create(1);
- WebTransformationMatrix dummyMatrix;
- dummyMatrix.translate(1.0, 2.0);
+ gfx::Transform dummyMatrix;
+ dummyMatrix.Translate(1.0, 2.0);
// The rest of the surface properties are either internal and should not cause change,
// or they are already accounted for by the owninglayer->layerPropertyChanged().
@@ -83,9 +81,9 @@ TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50));
gfx::Rect clipRect = gfx::Rect(gfx::Point(5, 5), gfx::Size(40, 40));
- WebTransformationMatrix origin;
+ gfx::Transform origin;
- origin.translate(30, 40);
+ origin.Translate(30, 40);
renderSurface->setDrawTransform(origin);
renderSurface->setContentRect(contentRect);
@@ -103,8 +101,8 @@ TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
ASSERT_EQ(1u, sharedStateList.size());
SharedQuadState* sharedQuadState = sharedStateList[0];
- EXPECT_EQ(30, sharedQuadState->content_to_target_transform.m41());
- EXPECT_EQ(40, sharedQuadState->content_to_target_transform.m42());
+ EXPECT_EQ(30, sharedQuadState->content_to_target_transform.matrix().getDouble(0, 3));
+ EXPECT_EQ(40, sharedQuadState->content_to_target_transform.matrix().getDouble(1, 3));
EXPECT_RECT_EQ(contentRect, gfx::Rect(sharedQuadState->visible_content_rect));
EXPECT_EQ(1, sharedQuadState->opacity);
}
@@ -132,8 +130,8 @@ TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass)
rootLayer->addChild(owningLayer.Pass());
gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50));
- WebTransformationMatrix origin;
- origin.translate(30, 40);
+ gfx::Transform origin;
+ origin.Translate(30, 40);
renderSurface->setScreenSpaceTransform(origin);
renderSurface->setContentRect(contentRect);
diff --git a/cc/shared_quad_state.cc b/cc/shared_quad_state.cc
index 24e9fdf..001f594 100644
--- a/cc/shared_quad_state.cc
+++ b/cc/shared_quad_state.cc
@@ -19,7 +19,7 @@ scoped_ptr<SharedQuadState> SharedQuadState::Copy() const {
}
void SharedQuadState::SetAll(
- const WebKit::WebTransformationMatrix& content_to_target_transform,
+ const gfx::Transform& content_to_target_transform,
const gfx::Rect& visible_content_rect,
const gfx::Rect& clipped_rect_in_target,
const gfx::Rect& clip_rect,
diff --git a/cc/shared_quad_state.h b/cc/shared_quad_state.h
index 300270b..055f12e 100644
--- a/cc/shared_quad_state.h
+++ b/cc/shared_quad_state.h
@@ -6,9 +6,9 @@
#define CC_SHARED_QUAD_STATE_H_
#include "base/memory/scoped_ptr.h"
-#include "ui/gfx/rect.h"
-#include <public/WebTransformationMatrix.h>
#include "cc/cc_export.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/transform.h"
namespace cc {
@@ -19,7 +19,7 @@ class CC_EXPORT SharedQuadState {
scoped_ptr<SharedQuadState> Copy() const;
- void SetAll(const WebKit::WebTransformationMatrix& content_to_target_transform,
+ void SetAll(const gfx::Transform& content_to_target_transform,
const gfx::Rect& visible_content_rect,
const gfx::Rect& clipped_rect_in_target,
const gfx::Rect& clip_rect,
@@ -27,7 +27,7 @@ class CC_EXPORT SharedQuadState {
float opacity);
// Transforms from quad's original content space to its target content space.
- WebKit::WebTransformationMatrix content_to_target_transform;
+ gfx::Transform content_to_target_transform;
// This rect lives in the content space for the quad's originating layer.
gfx::Rect visible_content_rect;
gfx::Rect clipped_rect_in_target;
diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc
index 58c5425..7f6e0c9 100644
--- a/cc/software_renderer.cc
+++ b/cc/software_renderer.cc
@@ -4,8 +4,13 @@
#include "cc/software_renderer.h"
+#include <public/WebCompositorSoftwareOutputDevice.h>
+#include <public/WebImage.h>
+#include <public/WebSize.h>
+
#include "base/debug/trace_event.h"
#include "cc/debug_border_draw_quad.h"
+#include "cc/math_util.h"
#include "cc/render_pass_draw_quad.h"
#include "cc/solid_color_draw_quad.h"
#include "cc/texture_draw_quad.h"
@@ -17,31 +22,27 @@
#include "third_party/skia/include/effects/SkLayerRasterizer.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/skia_util.h"
-#include <public/WebCompositorSoftwareOutputDevice.h>
-#include <public/WebImage.h>
-#include <public/WebSize.h>
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using WebKit::WebCompositorSoftwareOutputDevice;
using WebKit::WebSize;
-using WebKit::WebTransformationMatrix;
namespace cc {
namespace {
-void toSkMatrix(SkMatrix* flattened, const WebTransformationMatrix& m)
+void toSkMatrix(SkMatrix* flattened, const gfx::Transform& m)
{
// Convert from 4x4 to 3x3 by dropping the third row and column.
- flattened->set(0, SkDoubleToScalar(m.m11()));
- flattened->set(1, SkDoubleToScalar(m.m21()));
- flattened->set(2, SkDoubleToScalar(m.m41()));
- flattened->set(3, SkDoubleToScalar(m.m12()));
- flattened->set(4, SkDoubleToScalar(m.m22()));
- flattened->set(5, SkDoubleToScalar(m.m42()));
- flattened->set(6, SkDoubleToScalar(m.m14()));
- flattened->set(7, SkDoubleToScalar(m.m24()));
- flattened->set(8, SkDoubleToScalar(m.m44()));
+ flattened->set(0, SkDoubleToScalar(m.matrix().getDouble(0, 0)));
+ flattened->set(1, SkDoubleToScalar(m.matrix().getDouble(0, 1)));
+ flattened->set(2, SkDoubleToScalar(m.matrix().getDouble(0, 3)));
+ flattened->set(3, SkDoubleToScalar(m.matrix().getDouble(1, 0)));
+ flattened->set(4, SkDoubleToScalar(m.matrix().getDouble(1, 1)));
+ flattened->set(5, SkDoubleToScalar(m.matrix().getDouble(1, 3)));
+ flattened->set(6, SkDoubleToScalar(m.matrix().getDouble(3, 0)));
+ flattened->set(7, SkDoubleToScalar(m.matrix().getDouble(3, 1)));
+ flattened->set(8, SkDoubleToScalar(m.matrix().getDouble(3, 3)));
}
bool isScaleAndTranslate(const SkMatrix& matrix)
@@ -184,9 +185,9 @@ bool SoftwareRenderer::isSoftwareResource(ResourceProvider::ResourceId id) const
void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad)
{
TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad");
- WebTransformationMatrix quadRectMatrix;
+ gfx::Transform quadRectMatrix;
quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect);
- WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * frame.projectionMatrix * quadRectMatrix).to2dTransform();
+ gfx::Transform contentsDeviceTransform = MathUtil::to2dTransform(frame.windowMatrix * frame.projectionMatrix * quadRectMatrix);
SkMatrix skDeviceMatrix;
toSkMatrix(&skDeviceMatrix, contentsDeviceTransform);
m_skCurrentCanvas->setMatrix(skDeviceMatrix);
diff --git a/cc/software_renderer_unittest.cc b/cc/software_renderer_unittest.cc
index 121ba76..4b80d28 100644
--- a/cc/software_renderer_unittest.cc
+++ b/cc/software_renderer_unittest.cc
@@ -67,10 +67,10 @@ TEST_F(SoftwareRendererTest, solidColorQuad)
initializeRenderer();
scoped_ptr<SharedQuadState> sharedQuadState = SharedQuadState::Create();
- sharedQuadState->SetAll(WebTransformationMatrix(), outerRect, outerRect, outerRect, false, 1.0);
+ sharedQuadState->SetAll(gfx::Transform(), outerRect, outerRect, outerRect, false, 1.0);
RenderPass::Id rootRenderPassId = RenderPass::Id(1, 1);
scoped_ptr<TestRenderPass> rootRenderPass = TestRenderPass::Create();
- rootRenderPass->SetNew(rootRenderPassId, outerRect, gfx::Rect(), WebTransformationMatrix());
+ rootRenderPass->SetNew(rootRenderPassId, outerRect, gfx::Rect(), gfx::Transform());
scoped_ptr<SolidColorDrawQuad> outerQuad = SolidColorDrawQuad::Create();
outerQuad->SetNew(sharedQuadState.get(), outerRect, SK_ColorYELLOW);
scoped_ptr<SolidColorDrawQuad> innerQuad = SolidColorDrawQuad::Create();
@@ -128,10 +128,10 @@ TEST_F(SoftwareRendererTest, tileQuad)
gfx::Rect rect = gfx::Rect(gfx::Point(), deviceViewportSize());
scoped_ptr<SharedQuadState> sharedQuadState = SharedQuadState::Create();
- sharedQuadState->SetAll(WebTransformationMatrix(), outerRect, outerRect, outerRect, false, 1.0);
+ sharedQuadState->SetAll(gfx::Transform(), outerRect, outerRect, outerRect, false, 1.0);
RenderPass::Id rootRenderPassId = RenderPass::Id(1, 1);
scoped_ptr<TestRenderPass> rootRenderPass = TestRenderPass::Create();
- rootRenderPass->SetNew(rootRenderPassId, gfx::Rect(gfx::Point(), deviceViewportSize()), gfx::Rect(), WebTransformationMatrix());
+ rootRenderPass->SetNew(rootRenderPassId, gfx::Rect(gfx::Point(), deviceViewportSize()), gfx::Rect(), gfx::Transform());
scoped_ptr<TileDrawQuad> outerQuad = TileDrawQuad::Create();
outerQuad->SetNew(sharedQuadState.get(), outerRect, outerRect, resourceYellow, gfx::RectF(gfx::PointF(), outerSize), outerSize, false, false, false, false, false);
scoped_ptr<TileDrawQuad> innerQuad = TileDrawQuad::Create();
diff --git a/cc/solid_color_layer_impl.cc b/cc/solid_color_layer_impl.cc
index fb4429f..53a635e 100644
--- a/cc/solid_color_layer_impl.cc
+++ b/cc/solid_color_layer_impl.cc
@@ -7,8 +7,6 @@
#include "cc/quad_sink.h"
#include "cc/solid_color_draw_quad.h"
-using WebKit::WebTransformationMatrix;
-
namespace cc {
SolidColorLayerImpl::SolidColorLayerImpl(int id)
diff --git a/cc/solid_color_layer_impl.h b/cc/solid_color_layer_impl.h
index c762c84..30231cb 100644
--- a/cc/solid_color_layer_impl.h
+++ b/cc/solid_color_layer_impl.h
@@ -7,7 +7,6 @@
#include "cc/cc_export.h"
#include "cc/layer_impl.h"
-#include <public/WebTransformationMatrix.h>
namespace cc {
diff --git a/cc/stream_video_draw_quad.cc b/cc/stream_video_draw_quad.cc
index 0286a19..91cf3e2 100644
--- a/cc/stream_video_draw_quad.cc
+++ b/cc/stream_video_draw_quad.cc
@@ -18,7 +18,7 @@ void StreamVideoDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
gfx::Rect rect,
gfx::Rect opaque_rect,
unsigned texture_id,
- const WebKit::WebTransformationMatrix& matrix) {
+ const gfx::Transform& matrix) {
gfx::Rect visible_rect = rect;
bool needs_blending = false;
DrawQuad::SetAll(shared_quad_state, DrawQuad::STREAM_VIDEO_CONTENT, rect,
@@ -33,7 +33,7 @@ void StreamVideoDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
gfx::Rect visible_rect,
bool needs_blending,
unsigned texture_id,
- const WebKit::WebTransformationMatrix& matrix) {
+ const gfx::Transform& matrix) {
DrawQuad::SetAll(shared_quad_state, DrawQuad::STREAM_VIDEO_CONTENT, rect,
opaque_rect, visible_rect, needs_blending);
this->texture_id = texture_id;
diff --git a/cc/stream_video_draw_quad.h b/cc/stream_video_draw_quad.h
index 9e6154b..897f45d 100644
--- a/cc/stream_video_draw_quad.h
+++ b/cc/stream_video_draw_quad.h
@@ -8,7 +8,7 @@
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
#include "cc/draw_quad.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
namespace cc {
@@ -20,7 +20,7 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad {
gfx::Rect rect,
gfx::Rect opaque_rect,
unsigned texture_id,
- const WebKit::WebTransformationMatrix& matrix);
+ const gfx::Transform& matrix);
void SetAll(const SharedQuadState* shared_quad_state,
gfx::Rect rect,
@@ -28,10 +28,10 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad {
gfx::Rect visible_rect,
bool needs_blending,
unsigned texture_id,
- const WebKit::WebTransformationMatrix& matrix);
+ const gfx::Transform& matrix);
unsigned texture_id;
- WebKit::WebTransformationMatrix matrix;
+ gfx::Transform matrix;
static const StreamVideoDrawQuad* MaterialCast(const DrawQuad*);
private:
diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc
index 1ee736f..fd6ba2d 100644
--- a/cc/test/animation_test_common.cc
+++ b/cc/test/animation_test_common.cc
@@ -174,12 +174,12 @@ float FakeLayerAnimationControllerClient::opacity() const
return m_opacity;
}
-void FakeLayerAnimationControllerClient::setTransformFromAnimation(const WebKit::WebTransformationMatrix& transform)
+void FakeLayerAnimationControllerClient::setTransformFromAnimation(const gfx::Transform& transform)
{
m_transform = transform;
}
-const WebKit::WebTransformationMatrix& FakeLayerAnimationControllerClient::transform() const
+const gfx::Transform& FakeLayerAnimationControllerClient::transform() const
{
return m_transform;
}
diff --git a/cc/test/animation_test_common.h b/cc/test/animation_test_common.h
index 6839800..d293206 100644
--- a/cc/test/animation_test_common.h
+++ b/cc/test/animation_test_common.h
@@ -69,12 +69,12 @@ public:
virtual int id() const OVERRIDE;
virtual void setOpacityFromAnimation(float) OVERRIDE;
virtual float opacity() const OVERRIDE;
- virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix&) OVERRIDE;
- virtual const WebKit::WebTransformationMatrix& transform() const OVERRIDE;
+ virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE;
+ virtual const gfx::Transform& transform() const OVERRIDE;
private:
float m_opacity;
- WebKit::WebTransformationMatrix m_transform;
+ gfx::Transform m_transform;
};
int addOpacityTransitionToController(cc::LayerAnimationController&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);
diff --git a/cc/test/geometry_test_utils.cc b/cc/test/geometry_test_utils.cc
index 68afd4b..0d5df94 100644
--- a/cc/test/geometry_test_utils.cc
+++ b/cc/test/geometry_test_utils.cc
@@ -4,11 +4,17 @@
#include "cc/test/geometry_test_utils.h"
-#include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h>
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/transform.h"
+
namespace WebKitTests {
+// NOTE: even though transform data types use double precision, we only check
+// for equality within single-precision error bounds because many transforms
+// originate from single-precision data types such as quads/rects/etc.
+
void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expected,
const WebKit::WebTransformationMatrix& actual)
{
@@ -30,4 +36,25 @@ void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expecte
EXPECT_FLOAT_EQ((expected).m44(), (actual).m44());
}
+void ExpectTransformationMatrixEq(const gfx::Transform& expected,
+ const gfx::Transform& actual)
+{
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 0), (actual).matrix().getDouble(0, 0));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 0), (actual).matrix().getDouble(1, 0));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 0), (actual).matrix().getDouble(2, 0));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 0), (actual).matrix().getDouble(3, 0));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 1), (actual).matrix().getDouble(0, 1));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 1), (actual).matrix().getDouble(1, 1));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 1), (actual).matrix().getDouble(2, 1));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 1), (actual).matrix().getDouble(3, 1));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 2), (actual).matrix().getDouble(0, 2));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 2), (actual).matrix().getDouble(1, 2));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 2), (actual).matrix().getDouble(2, 2));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 2), (actual).matrix().getDouble(3, 2));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 3), (actual).matrix().getDouble(0, 3));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 3), (actual).matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 3), (actual).matrix().getDouble(2, 3));
+ EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 3), (actual).matrix().getDouble(3, 3));
+}
+
} // namespace WebKitTests
diff --git a/cc/test/geometry_test_utils.h b/cc/test/geometry_test_utils.h
index 52cb814..27be790 100644
--- a/cc/test/geometry_test_utils.h
+++ b/cc/test/geometry_test_utils.h
@@ -5,6 +5,10 @@
#ifndef CC_TEST_GEOMETRY_TEST_UTILS_H_
#define CC_TEST_GEOMETRY_TEST_UTILS_H_
+namespace gfx {
+class Transform;
+}
+
namespace WebKit {
class WebTransformationMatrix;
}
@@ -50,6 +54,9 @@ do { \
// in bulk, it causes a significant slow-down in compilation time. This problem
// exists with both gcc and clang, and bugs have been filed at
// http://llvm.org/bugs/show_bug.cgi?id=13651 and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54337
+void ExpectTransformationMatrixEq(const gfx::Transform& expected,
+ const gfx::Transform& actual);
+
void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expected,
const WebKit::WebTransformationMatrix& actual);
diff --git a/cc/test/render_pass_test_common.cc b/cc/test/render_pass_test_common.cc
index e3bb308..93f2f34 100644
--- a/cc/test/render_pass_test_common.cc
+++ b/cc/test/render_pass_test_common.cc
@@ -15,12 +15,11 @@
#include "cc/tile_draw_quad.h"
#include "cc/yuv_video_draw_quad.h"
#include "cc/resource_provider.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
namespace WebKitTests {
using cc::DrawQuad;
-using WebKit::WebTransformationMatrix;
void TestRenderPass::AppendOneOfEveryQuadType(cc::ResourceProvider* resourceProvider) {
gfx::Rect rect(0, 0, 100, 100);
@@ -28,7 +27,7 @@ void TestRenderPass::AppendOneOfEveryQuadType(cc::ResourceProvider* resourceProv
cc::ResourceProvider::ResourceId texture_resource =
resourceProvider->createResourceFromExternalTexture(1);
scoped_ptr<cc::SharedQuadState> shared_state = cc::SharedQuadState::Create();
- shared_state->SetAll(WebTransformationMatrix(),
+ shared_state->SetAll(gfx::Transform(),
rect,
rect,
rect,
@@ -87,7 +86,7 @@ void TestRenderPass::AppendOneOfEveryQuadType(cc::ResourceProvider* resourceProv
rect,
opaque_rect,
1,
- WebKit::WebTransformationMatrix());
+ gfx::Transform());
AppendQuad(stream_video_quad.PassAs<DrawQuad>());
scoped_ptr<cc::TextureDrawQuad> texture_quad =
diff --git a/cc/thread_proxy.h b/cc/thread_proxy.h
index e4fa901..296c180 100644
--- a/cc/thread_proxy.h
+++ b/cc/thread_proxy.h
@@ -86,7 +86,7 @@ private:
base::TimeTicks monotonicFrameBeginTime;
scoped_ptr<ScrollAndScaleSet> scrollInfo;
- WebKit::WebTransformationMatrix implTransform;
+ gfx::Transform implTransform;
PrioritizedResourceManager::BackingList evictedContentsTexturesBackings;
size_t memoryAllocationLimitBytes;
};
diff --git a/cc/tiled_layer.cc b/cc/tiled_layer.cc
index 9526a63..77a32e6 100644
--- a/cc/tiled_layer.cc
+++ b/cc/tiled_layer.cc
@@ -14,7 +14,6 @@
#include "ui/gfx/rect_conversions.h"
using namespace std;
-using WebKit::WebTransformationMatrix;
namespace cc {
@@ -484,7 +483,7 @@ void TiledLayer::updateTileTextures(const gfx::Rect& paintRect, int left, int to
tile->updaterResource()->update(queue, sourceRect, destOffset, tile->partialUpdate, stats);
if (occlusion)
- occlusion->overdrawMetrics().didUpload(WebTransformationMatrix(), sourceRect, tile->opaqueRect());
+ occlusion->overdrawMetrics().didUpload(gfx::Transform(), sourceRect, tile->opaqueRect());
}
}
diff --git a/cc/tiled_layer_impl.cc b/cc/tiled_layer_impl.cc
index ff4eaa3..f4636f2 100644
--- a/cc/tiled_layer_impl.cc
+++ b/cc/tiled_layer_impl.cc
@@ -20,7 +20,6 @@
#include "ui/gfx/quad_f.h"
using namespace std;
-using WebKit::WebTransformationMatrix;
namespace cc {
diff --git a/cc/tiled_layer_impl.h b/cc/tiled_layer_impl.h
index ac75f80..c8ff334 100644
--- a/cc/tiled_layer_impl.h
+++ b/cc/tiled_layer_impl.h
@@ -7,7 +7,6 @@
#include "cc/cc_export.h"
#include "cc/layer_impl.h"
-#include <public/WebTransformationMatrix.h>
namespace cc {
diff --git a/cc/tiled_layer_unittest.cc b/cc/tiled_layer_unittest.cc
index 9e88f09..52c4bea 100644
--- a/cc/tiled_layer_unittest.cc
+++ b/cc/tiled_layer_unittest.cc
@@ -18,10 +18,9 @@
#include "cc/test/tiled_layer_test_common.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/rect_conversions.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
using namespace WebKitTests;
-using WebKit::WebTransformationMatrix;
namespace cc {
namespace {
@@ -1141,8 +1140,8 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms)
// This makes sure the painting works when the occluded region (in screen space)
// is transformed differently than the layer.
layer->setBounds(gfx::Size(600, 600));
- WebTransformationMatrix screenTransform;
- screenTransform.scale(0.5);
+ gfx::Transform screenTransform;
+ screenTransform.Scale(0.5, 0.5);
layer->setScreenSpaceTransform(screenTransform);
layer->setDrawTransform(screenTransform);
@@ -1173,8 +1172,9 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
layer->setContentsScale(0.5);
EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY());
layer->setBounds(gfx::Size(600, 600));
- WebTransformationMatrix drawTransform;
- drawTransform.scale(1 / layer->contentsScaleX());
+ gfx::Transform drawTransform;
+ double invScaleFactor = 1 / layer->contentsScaleX();
+ drawTransform.Scale(invScaleFactor, invScaleFactor);
layer->setDrawTransform(drawTransform);
layer->setScreenSpaceTransform(drawTransform);
@@ -1215,8 +1215,8 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
layer->fakeLayerUpdater()->clearUpdateCount();
// This makes sure content scaling and transforms work together.
- WebTransformationMatrix screenTransform;
- screenTransform.scale(0.5);
+ gfx::Transform screenTransform;
+ screenTransform.Scale(0.5, 0.5);
layer->setScreenSpaceTransform(screenTransform);
layer->setDrawTransform(screenTransform);
diff --git a/cc/video_layer_impl.cc b/cc/video_layer_impl.cc
index a322541..918fac6 100644
--- a/cc/video_layer_impl.cc
+++ b/cc/video_layer_impl.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "cc/io_surface_draw_quad.h"
#include "cc/layer_tree_host_impl.h"
+#include "cc/math_util.h"
#include "cc/quad_sink.h"
#include "cc/resource_provider.h"
#include "cc/stream_video_draw_quad.h"
@@ -30,7 +31,7 @@ VideoLayerImpl::VideoLayerImpl(int id, WebKit::WebVideoFrameProvider* provider,
, m_externalTextureResource(0)
{
// This matrix is the default transformation for stream textures, and flips on the Y axis.
- m_streamTextureMatrix = WebKit::WebTransformationMatrix(
+ m_streamTextureMatrix = MathUtil::createGfxTransform(
1, 0, 0, 0,
0, -1, 0, 0,
0, 0, 1, 0,
@@ -252,8 +253,8 @@ void VideoLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuad
}
case GL_TEXTURE_EXTERNAL_OES: {
// StreamTexture hardware decoder.
- WebKit::WebTransformationMatrix transform(m_streamTextureMatrix);
- transform.scaleNonUniform(texWidthScale, texHeightScale);
+ gfx::Transform transform(m_streamTextureMatrix);
+ transform.Scale(texWidthScale, texHeightScale);
scoped_ptr<StreamVideoDrawQuad> streamVideoQuad = StreamVideoDrawQuad::Create();
streamVideoQuad->SetNew(sharedQuadState, quadRect, opaqueRect, m_frame->texture_id(), transform);
quadSink.append(streamVideoQuad.PassAs<DrawQuad>(), appendQuadsData);
@@ -401,7 +402,7 @@ void VideoLayerImpl::didReceiveFrame()
void VideoLayerImpl::didUpdateMatrix(const float matrix[16])
{
- m_streamTextureMatrix = WebKit::WebTransformationMatrix(
+ m_streamTextureMatrix = MathUtil::createGfxTransform(
matrix[0], matrix[1], matrix[2], matrix[3],
matrix[4], matrix[5], matrix[6], matrix[7],
matrix[8], matrix[9], matrix[10], matrix[11],
diff --git a/cc/video_layer_impl.h b/cc/video_layer_impl.h
index 6291ae1..6a4af37 100644
--- a/cc/video_layer_impl.h
+++ b/cc/video_layer_impl.h
@@ -5,6 +5,8 @@
#ifndef CC_VIDEO_LAYER_IMPL_H_
#define CC_VIDEO_LAYER_IMPL_H_
+#include <public/WebVideoFrameProvider.h>
+
#include "base/callback.h"
#include "base/synchronization/lock.h"
#include "cc/cc_export.h"
@@ -12,8 +14,7 @@
#include "media/base/video_frame.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "ui/gfx/size.h"
-#include <public/WebTransformationMatrix.h>
-#include <public/WebVideoFrameProvider.h>
+#include "ui/gfx/transform.h"
namespace WebKit {
class WebVideoFrame;
@@ -80,7 +81,7 @@ private:
base::Lock m_providerLock;
WebKit::WebVideoFrameProvider* m_provider;
- WebKit::WebTransformationMatrix m_streamTextureMatrix;
+ gfx::Transform m_streamTextureMatrix;
FrameUnwrapper m_unwrapper;
WebKit::WebVideoFrame *m_webFrame;
diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc
index 6c1c440..166e77a 100644
--- a/content/common/cc_messages.cc
+++ b/content/common/cc_messages.cc
@@ -7,7 +7,7 @@
#include "content/public/common/common_param_traits.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebData.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
+#include "ui/gfx/transform.h"
namespace IPC {
@@ -208,104 +208,108 @@ void ParamTraits<WebKit::WebFilterOperations>::Log(
l->append(")");
}
-void ParamTraits<WebKit::WebTransformationMatrix>::Write(
+void ParamTraits<gfx::Transform>::Write(
Message* m, const param_type& p) {
- WriteParam(m, p.m11());
- WriteParam(m, p.m12());
- WriteParam(m, p.m13());
- WriteParam(m, p.m14());
- WriteParam(m, p.m21());
- WriteParam(m, p.m22());
- WriteParam(m, p.m23());
- WriteParam(m, p.m24());
- WriteParam(m, p.m31());
- WriteParam(m, p.m32());
- WriteParam(m, p.m33());
- WriteParam(m, p.m34());
- WriteParam(m, p.m41());
- WriteParam(m, p.m42());
- WriteParam(m, p.m43());
- WriteParam(m, p.m44());
+ WriteParam(m, p.matrix().getDouble(0, 0));
+ WriteParam(m, p.matrix().getDouble(1, 0));
+ WriteParam(m, p.matrix().getDouble(2, 0));
+ WriteParam(m, p.matrix().getDouble(3, 0));
+ WriteParam(m, p.matrix().getDouble(0, 1));
+ WriteParam(m, p.matrix().getDouble(1, 1));
+ WriteParam(m, p.matrix().getDouble(2, 1));
+ WriteParam(m, p.matrix().getDouble(3, 1));
+ WriteParam(m, p.matrix().getDouble(0, 2));
+ WriteParam(m, p.matrix().getDouble(1, 2));
+ WriteParam(m, p.matrix().getDouble(2, 2));
+ WriteParam(m, p.matrix().getDouble(3, 2));
+ WriteParam(m, p.matrix().getDouble(0, 3));
+ WriteParam(m, p.matrix().getDouble(1, 3));
+ WriteParam(m, p.matrix().getDouble(2, 3));
+ WriteParam(m, p.matrix().getDouble(3, 3));
}
-bool ParamTraits<WebKit::WebTransformationMatrix>::Read(
+bool ParamTraits<gfx::Transform>::Read(
const Message* m, PickleIterator* iter, param_type* r) {
+ // Note: In this function, "m12" means 1st row, 2nd column of the matrix.
+ // This is consistent with Skia's row-column notation, but backwards from
+ // WebCore's column-row notation.
double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44;
+
bool success =
ReadParam(m, iter, &m11) &&
- ReadParam(m, iter, &m12) &&
- ReadParam(m, iter, &m13) &&
- ReadParam(m, iter, &m14) &&
ReadParam(m, iter, &m21) &&
- ReadParam(m, iter, &m22) &&
- ReadParam(m, iter, &m23) &&
- ReadParam(m, iter, &m24) &&
ReadParam(m, iter, &m31) &&
- ReadParam(m, iter, &m32) &&
- ReadParam(m, iter, &m33) &&
- ReadParam(m, iter, &m34) &&
ReadParam(m, iter, &m41) &&
+ ReadParam(m, iter, &m12) &&
+ ReadParam(m, iter, &m22) &&
+ ReadParam(m, iter, &m32) &&
ReadParam(m, iter, &m42) &&
+ ReadParam(m, iter, &m13) &&
+ ReadParam(m, iter, &m23) &&
+ ReadParam(m, iter, &m33) &&
ReadParam(m, iter, &m43) &&
+ ReadParam(m, iter, &m14) &&
+ ReadParam(m, iter, &m24) &&
+ ReadParam(m, iter, &m34) &&
ReadParam(m, iter, &m44);
if (success) {
- r->setM11(m11);
- r->setM12(m12);
- r->setM13(m13);
- r->setM14(m14);
- r->setM21(m21);
- r->setM22(m22);
- r->setM23(m23);
- r->setM24(m24);
- r->setM31(m31);
- r->setM32(m32);
- r->setM33(m33);
- r->setM34(m34);
- r->setM41(m41);
- r->setM42(m42);
- r->setM43(m43);
- r->setM44(m44);
+ r->matrix().setDouble(0, 0, m11);
+ r->matrix().setDouble(1, 0, m21);
+ r->matrix().setDouble(2, 0, m31);
+ r->matrix().setDouble(3, 0, m41);
+ r->matrix().setDouble(0, 1, m12);
+ r->matrix().setDouble(1, 1, m22);
+ r->matrix().setDouble(2, 1, m32);
+ r->matrix().setDouble(3, 1, m42);
+ r->matrix().setDouble(0, 2, m13);
+ r->matrix().setDouble(1, 2, m23);
+ r->matrix().setDouble(2, 2, m33);
+ r->matrix().setDouble(3, 2, m43);
+ r->matrix().setDouble(0, 3, m14);
+ r->matrix().setDouble(1, 3, m24);
+ r->matrix().setDouble(2, 3, m34);
+ r->matrix().setDouble(3, 3, m44);
}
return success;
}
-void ParamTraits<WebKit::WebTransformationMatrix>::Log(
+void ParamTraits<gfx::Transform>::Log(
const param_type& p, std::string* l) {
l->append("(");
- LogParam(p.m11(), l);
+ LogParam(p.matrix().getDouble(0, 0), l);
l->append(", ");
- LogParam(p.m12(), l);
+ LogParam(p.matrix().getDouble(1, 0), l);
l->append(", ");
- LogParam(p.m13(), l);
+ LogParam(p.matrix().getDouble(2, 0), l);
l->append(", ");
- LogParam(p.m14(), l);
+ LogParam(p.matrix().getDouble(3, 0), l);
l->append(", ");
- LogParam(p.m21(), l);
+ LogParam(p.matrix().getDouble(0, 1), l);
l->append(", ");
- LogParam(p.m22(), l);
+ LogParam(p.matrix().getDouble(1, 1), l);
l->append(", ");
- LogParam(p.m23(), l);
+ LogParam(p.matrix().getDouble(2, 1), l);
l->append(", ");
- LogParam(p.m24(), l);
+ LogParam(p.matrix().getDouble(3, 1), l);
l->append(", ");
- LogParam(p.m31(), l);
+ LogParam(p.matrix().getDouble(0, 2), l);
l->append(", ");
- LogParam(p.m32(), l);
+ LogParam(p.matrix().getDouble(1, 2), l);
l->append(", ");
- LogParam(p.m33(), l);
+ LogParam(p.matrix().getDouble(2, 2), l);
l->append(", ");
- LogParam(p.m34(), l);
+ LogParam(p.matrix().getDouble(3, 2), l);
l->append(", ");
- LogParam(p.m41(), l);
+ LogParam(p.matrix().getDouble(0, 3), l);
l->append(", ");
- LogParam(p.m42(), l);
+ LogParam(p.matrix().getDouble(1, 3), l);
l->append(", ");
- LogParam(p.m43(), l);
+ LogParam(p.matrix().getDouble(2, 3), l);
l->append(", ");
- LogParam(p.m44(), l);
+ LogParam(p.matrix().getDouble(3, 3), l);
l->append(") ");
}
@@ -406,7 +410,7 @@ bool ParamTraits<cc::RenderPass>::Read(
cc::RenderPass::Id id(-1, -1);
gfx::Rect output_rect;
gfx::RectF damage_rect;
- WebKit::WebTransformationMatrix transform_to_root_target;
+ gfx::Transform transform_to_root_target;
bool has_transparent_background;
bool has_occlusion_from_outside_target_surface;
WebKit::WebFilterOperations filters;
diff --git a/content/common/cc_messages.h b/content/common/cc_messages.h
index b896a2f..74f2479 100644
--- a/content/common/cc_messages.h
+++ b/content/common/cc_messages.h
@@ -24,10 +24,13 @@
#ifndef CONTENT_COMMON_CC_MESSAGES_H_
#define CONTENT_COMMON_CC_MESSAGES_H_
+namespace gfx {
+class Transform;
+}
+
namespace WebKit {
class WebData;
class WebFilterOperations;
-class WebTransformationMatrix;
}
namespace IPC {
@@ -57,8 +60,8 @@ struct ParamTraits<WebKit::WebFilterOperations> {
};
template <>
-struct ParamTraits<WebKit::WebTransformationMatrix> {
- typedef WebKit::WebTransformationMatrix param_type;
+struct ParamTraits<gfx::Transform> {
+ typedef gfx::Transform param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, PickleIterator* iter, param_type* r);
static void Log(const param_type& p, std::string* l);
diff --git a/content/common/cc_messages_unittest.cc b/content/common/cc_messages_unittest.cc
index 7225b68..d58c518 100644
--- a/content/common/cc_messages_unittest.cc
+++ b/content/common/cc_messages_unittest.cc
@@ -23,9 +23,9 @@ using cc::TileDrawQuad;
using cc::StreamVideoDrawQuad;
using cc::VideoLayerImpl;
using cc::YUVVideoDrawQuad;
+using gfx::Transform;
using WebKit::WebFilterOperation;
using WebKit::WebFilterOperations;
-using WebKit::WebTransformationMatrix;
class CCMessagesTest : public testing::Test {
protected:
@@ -173,10 +173,10 @@ class CCMessagesTest : public testing::Test {
TEST_F(CCMessagesTest, AllQuads) {
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
- WebTransformationMatrix arbitrary_matrix;
- arbitrary_matrix.scale(3);
- arbitrary_matrix.translate(-5, 20);
- arbitrary_matrix.rotate(15);
+ Transform arbitrary_matrix;
+ arbitrary_matrix.Scale(3, 3);
+ arbitrary_matrix.Translate(-5, 20);
+ arbitrary_matrix.Rotate(15);
gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
gfx::Rect arbitrary_rect2(40, 23, 11, 7);
gfx::Rect arbitrary_rect3(7, -53, 22, 19);
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index 00d0c5a..715b8e1 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -772,7 +772,7 @@ void Layer::RecomputeTransform() {
translate.Translate(bounds_.x(), bounds_.y());
transform.ConcatTransform(translate);
transform.ConcatTransform(scale_translate);
- cc_layer_->setTransform(WebKit::WebTransformationMatrix(transform));
+ cc_layer_->setTransform(transform);
}
void Layer::RecomputeDrawsContentAndUVRect() {
diff --git a/webkit/compositor_bindings/web_layer_impl.cc b/webkit/compositor_bindings/web_layer_impl.cc
index 557fabb..ee8b50f 100644
--- a/webkit/compositor_bindings/web_layer_impl.cc
+++ b/webkit/compositor_bindings/web_layer_impl.cc
@@ -23,42 +23,6 @@ using cc::Layer;
namespace WebKit {
-namespace {
-
-WebTransformationMatrix transformationMatrixFromSkMatrix44(const SkMatrix44& matrix)
-{
- double data[16];
- matrix.asColMajord(data);
- return WebTransformationMatrix(data[0], data[1], data[2], data[3],
- data[4], data[5], data[6], data[7],
- data[8], data[9], data[10], data[11],
- data[12], data[13], data[14], data[15]);
-}
-
-SkMatrix44 skMatrix44FromTransformationMatrix(const WebTransformationMatrix& matrix)
-{
- SkMatrix44 skMatrix;
- skMatrix.set(0, 0, SkDoubleToMScalar(matrix.m11()));
- skMatrix.set(1, 0, SkDoubleToMScalar(matrix.m12()));
- skMatrix.set(2, 0, SkDoubleToMScalar(matrix.m13()));
- skMatrix.set(3, 0, SkDoubleToMScalar(matrix.m14()));
- skMatrix.set(0, 1, SkDoubleToMScalar(matrix.m21()));
- skMatrix.set(1, 1, SkDoubleToMScalar(matrix.m22()));
- skMatrix.set(2, 1, SkDoubleToMScalar(matrix.m23()));
- skMatrix.set(3, 1, SkDoubleToMScalar(matrix.m24()));
- skMatrix.set(0, 2, SkDoubleToMScalar(matrix.m31()));
- skMatrix.set(1, 2, SkDoubleToMScalar(matrix.m32()));
- skMatrix.set(2, 2, SkDoubleToMScalar(matrix.m33()));
- skMatrix.set(3, 2, SkDoubleToMScalar(matrix.m34()));
- skMatrix.set(0, 3, SkDoubleToMScalar(matrix.m41()));
- skMatrix.set(1, 3, SkDoubleToMScalar(matrix.m42()));
- skMatrix.set(2, 3, SkDoubleToMScalar(matrix.m43()));
- skMatrix.set(3, 3, SkDoubleToMScalar(matrix.m44()));
- return skMatrix;
-}
-
-}
-
WebLayer* WebLayer::create()
{
return new WebLayerImpl();
@@ -203,32 +167,36 @@ WebFloatPoint WebLayerImpl::position() const
void WebLayerImpl::setSublayerTransform(const SkMatrix44& matrix)
{
- m_layer->setSublayerTransform(transformationMatrixFromSkMatrix44(matrix));
+ gfx::Transform subLayerTransform;
+ subLayerTransform.matrix() = matrix;
+ m_layer->setSublayerTransform(subLayerTransform);
}
void WebLayerImpl::setSublayerTransform(const WebTransformationMatrix& matrix)
{
- m_layer->setSublayerTransform(matrix);
+ m_layer->setSublayerTransform(matrix.toTransform());
}
SkMatrix44 WebLayerImpl::sublayerTransform() const
{
- return skMatrix44FromTransformationMatrix(m_layer->sublayerTransform());
+ return m_layer->sublayerTransform().matrix();
}
void WebLayerImpl::setTransform(const SkMatrix44& matrix)
{
- m_layer->setTransform(transformationMatrixFromSkMatrix44(matrix));
+ gfx::Transform transform;
+ transform.matrix() = matrix;
+ m_layer->setTransform(transform);
}
void WebLayerImpl::setTransform(const WebTransformationMatrix& matrix)
{
- m_layer->setTransform(matrix);
+ m_layer->setTransform(matrix.toTransform());
}
SkMatrix44 WebLayerImpl::transform() const
{
- return skMatrix44FromTransformationMatrix(m_layer->transform());
+ return m_layer->transform().matrix();
}
void WebLayerImpl::setDrawsContent(bool drawsContent)