0

Animation code is not yet migrated by this patch, due to WebTransformOperations.

BUG=159972

Review URL: https://codereview.chromium.org/11308153

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169609 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
shawnsingh@chromium.org
2012-11-27 08:29:00 +00:00
parent 5006a4185d
commit c8686a05e1
79 changed files with 1580 additions and 1633 deletions
cc
animation_curve.hdamage_tracker.ccdamage_tracker_unittest.ccdelegated_renderer_layer_impl_unittest.ccdirect_renderer.ccdirect_renderer.hdraw_quad.hdraw_quad_unittest.ccfloat_quad_unittest.ccgl_renderer.ccgl_renderer.hgl_renderer_unittest.ccheads_up_display_layer.cclayer.cclayer.hlayer_animation_controller.cclayer_animation_controller.hlayer_animation_controller_unittest.cclayer_impl.cclayer_impl.hlayer_impl_unittest.cclayer_iterator_unittest.cclayer_sorter.cclayer_sorter.hlayer_sorter_unittest.cclayer_tree_host.cclayer_tree_host.hlayer_tree_host_common.cclayer_tree_host_common.hlayer_tree_host_common_unittest.cclayer_tree_host_impl.cclayer_tree_host_impl.hlayer_tree_host_impl_unittest.cclayer_tree_host_unittest.cclayer_unittest.ccmath_util.ccmath_util.hmath_util_unittest.ccnine_patch_layer_impl_unittest.ccocclusion_tracker.ccocclusion_tracker.hocclusion_tracker_unittest.ccoverdraw_metrics.ccoverdraw_metrics.hquad_culler.ccquad_culler_unittest.ccrender_pass.ccrender_pass.hrender_pass_unittest.ccrender_surface.ccrender_surface.hrender_surface_impl.ccrender_surface_impl.hrender_surface_unittest.ccshared_quad_state.ccshared_quad_state.hsoftware_renderer.ccsoftware_renderer_unittest.ccsolid_color_layer_impl.ccsolid_color_layer_impl.hstream_video_draw_quad.ccstream_video_draw_quad.h
test
thread_proxy.htiled_layer.cctiled_layer_impl.cctiled_layer_impl.htiled_layer_unittest.ccvideo_layer_impl.ccvideo_layer_impl.h
content/common
ui/compositor
webkit/compositor_bindings

@ -5,9 +5,10 @@
#ifndef CC_ANIMATION_CURVE_H_ #ifndef CC_ANIMATION_CURVE_H_
#define CC_ANIMATION_CURVE_H_ #define CC_ANIMATION_CURVE_H_
#include <public/WebTransformationMatrix.h>
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include <public/WebTransformationMatrix.h>
namespace cc { namespace cc {

@ -10,8 +10,6 @@
#include "cc/render_surface_impl.h" #include "cc/render_surface_impl.h"
#include <public/WebFilterOperations.h> #include <public/WebFilterOperations.h>
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
scoped_ptr<DamageTracker> DamageTracker::create() 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 there was damage, transform it to target space, and possibly contribute its reflection if needed.
if (!damageRectInLocalSpace.IsEmpty()) { if (!damageRectInLocalSpace.IsEmpty()) {
const WebTransformationMatrix& drawTransform = renderSurface->drawTransform(); const gfx::Transform& drawTransform = renderSurface->drawTransform();
gfx::RectF damageRectInTargetSpace = MathUtil::mapClippedRect(drawTransform, damageRectInLocalSpace); gfx::RectF damageRectInTargetSpace = MathUtil::mapClippedRect(drawTransform, damageRectInLocalSpace);
targetDamageRect.Union(damageRectInTargetSpace); targetDamageRect.Union(damageRectInTargetSpace);
if (layer->replicaLayer()) { if (layer->replicaLayer()) {
const WebTransformationMatrix& replicaDrawTransform = renderSurface->replicaDrawTransform(); const gfx::Transform& replicaDrawTransform = renderSurface->replicaDrawTransform();
targetDamageRect.Union(MathUtil::mapClippedRect(replicaDrawTransform, damageRectInLocalSpace)); targetDamageRect.Union(MathUtil::mapClippedRect(replicaDrawTransform, damageRectInLocalSpace));
} }
} }
@ -323,7 +321,7 @@ void DamageTracker::extendDamageForRenderSurface(LayerImpl* layer, gfx::RectF& t
bool replicaIsNew = false; bool replicaIsNew = false;
removeRectFromCurrentFrame(replicaMaskLayer->id(), replicaIsNew); 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())); gfx::RectF replicaMaskLayerRect = MathUtil::mapClippedRect(replicaDrawTransform, gfx::RectF(gfx::PointF(), replicaMaskLayer->bounds()));
saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect); saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect);

@ -285,8 +285,8 @@ TEST_F(DamageTrackerTest, verifyDamageForTransformedLayer)
scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
LayerImpl* child = root->children()[0]; LayerImpl* child = root->children()[0];
WebTransformationMatrix rotation; gfx::Transform rotation;
rotation.rotate(45); rotation.Rotate(45);
clearDamageForAllSurfaces(root.get()); clearDamageForAllSurfaces(root.get());
child->setAnchorPoint(gfx::PointF(0.5, 0.5)); child->setAnchorPoint(gfx::PointF(0.5, 0.5));
@ -328,11 +328,11 @@ TEST_F(DamageTrackerTest, verifyDamageForPerspectiveClippedLayer)
scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
LayerImpl* child = root->children()[0]; LayerImpl* child = root->children()[0];
WebTransformationMatrix transform; gfx::Transform transform;
transform.translate3d(500, 500, 0); transform.Translate3d(500, 500, 0);
transform.applyPerspective(1); transform.ApplyPerspectiveDepth(1);
transform.rotate3d(0, 45, 0); MathUtil::rotateEulerAngles(&transform, 0, 45, 0);
transform.translate3d(-50, -50, 0); transform.Translate3d(-50, -50, 0);
// Set up the child // Set up the child
child->setPosition(gfx::PointF(0, 0)); child->setPosition(gfx::PointF(0, 0));
@ -833,8 +833,8 @@ TEST_F(DamageTrackerTest, verifyDamageForReplica)
scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(7); scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(7);
grandChild1Replica->setPosition(gfx::PointF()); grandChild1Replica->setPosition(gfx::PointF());
grandChild1Replica->setAnchorPoint(gfx::PointF()); grandChild1Replica->setAnchorPoint(gfx::PointF());
WebTransformationMatrix reflection; gfx::Transform reflection;
reflection.scale3d(-1, 1, 1); reflection.Scale3d(-1, 1, 1);
grandChild1Replica->setTransform(reflection); grandChild1Replica->setTransform(reflection);
grandChild1->setReplicaLayer(grandChild1Replica.Pass()); grandChild1->setReplicaLayer(grandChild1Replica.Pass());
} }
@ -986,8 +986,8 @@ TEST_F(DamageTrackerTest, verifyDamageForReplicaMask)
scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6);
grandChild1Replica->setPosition(gfx::PointF()); grandChild1Replica->setPosition(gfx::PointF());
grandChild1Replica->setAnchorPoint(gfx::PointF()); grandChild1Replica->setAnchorPoint(gfx::PointF());
WebTransformationMatrix reflection; gfx::Transform reflection;
reflection.scale3d(-1, 1, 1); reflection.Scale3d(-1, 1, 1);
grandChild1Replica->setTransform(reflection); grandChild1Replica->setTransform(reflection);
grandChild1->setReplicaLayer(grandChild1Replica.Pass()); grandChild1->setReplicaLayer(grandChild1Replica.Pass());
} }
@ -1048,8 +1048,8 @@ TEST_F(DamageTrackerTest, verifyDamageForReplicaMaskWithAnchor)
scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6);
grandChild1Replica->setPosition(gfx::PointF()); grandChild1Replica->setPosition(gfx::PointF());
grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the anchor being tested. grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the anchor being tested.
WebTransformationMatrix reflection; gfx::Transform reflection;
reflection.scale3d(-1, 1, 1); reflection.Scale3d(-1, 1, 1);
grandChild1Replica->setTransform(reflection); grandChild1Replica->setTransform(reflection);
grandChild1->setReplicaLayer(grandChild1Replica.Pass()); grandChild1->setReplicaLayer(grandChild1Replica.Pass());
} }

@ -19,11 +19,10 @@
#include "cc/test/mock_quad_culler.h" #include "cc/test/mock_quad_culler.h"
#include "cc/test/render_pass_test_common.h" #include "cc/test/render_pass_test_common.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::FakeWebCompositorOutputSurface; using WebKit::FakeWebCompositorOutputSurface;
using WebKit::FakeWebGraphicsContext3D; using WebKit::FakeWebGraphicsContext3D;
using WebKit::WebTransformationMatrix;
using namespace WebKitTests; using namespace WebKitTests;
@ -66,7 +65,7 @@ protected:
scoped_ptr<LayerTreeHostImpl> m_hostImpl; 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()); scoped_ptr<TestRenderPass> pass(TestRenderPass::Create());
pass->SetNew(id, outputRect, outputRect, rootTransform); 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); MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_list);
AppendQuadsData data(pass->id); AppendQuadsData data(pass->id);
SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQuadState::Create()); 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(); scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
quad->SetNew(sharedState, rect, color); quad->SetNew(sharedState, rect, color);
SolidColorDrawQuad* quadPtr = quad.get(); SolidColorDrawQuad* quadPtr = quad.get();
@ -94,7 +93,7 @@ static void addRenderPassQuad(TestRenderPass* toPass, TestRenderPass* contributi
AppendQuadsData data(toPass->id); AppendQuadsData data(toPass->id);
gfx::Rect outputRect = contributingPass->output_rect; gfx::Rect outputRect = contributingPass->output_rect;
SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQuadState::Create()); 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(); scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create();
quad->SetNew(sharedState, outputRect, contributingPass->id, false, 0, outputRect, 0, 0, 0, 0); quad->SetNew(sharedState, outputRect, contributingPass->id, false, 0, outputRect, 0, 0, 0, 0);
quadSink.append(quad.PassAs<DrawQuad>(), data); quadSink.append(quad.PassAs<DrawQuad>(), data);
@ -129,17 +128,17 @@ public:
delegatedRendererLayer->setBounds(gfx::Size(10, 10)); delegatedRendererLayer->setBounds(gfx::Size(10, 10));
delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); delegatedRendererLayer->setContentBounds(gfx::Size(10, 10));
delegatedRendererLayer->setDrawsContent(true); delegatedRendererLayer->setDrawsContent(true);
WebTransformationMatrix transform; gfx::Transform transform;
transform.translate(1, 1); transform.Translate(1, 1);
delegatedRendererLayer->setTransform(transform); delegatedRendererLayer->setTransform(transform);
ScopedPtrVector<RenderPass> delegatedRenderPasses; 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); 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); addQuad(pass2, gfx::Rect(0, 0, 7, 7), 22u);
addRenderPassQuad(pass2, pass1); 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); addRenderPassQuad(pass3, pass2);
delegatedRendererLayer->setRenderPasses(delegatedRenderPasses); 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. // 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. // So its root RenderPass' quads should all be transformed by that combined amount.
WebTransformationMatrix transform; gfx::Transform transform;
transform.translate(4, 4); transform.Translate(4, 4);
EXPECT_TRANSFORMATION_MATRIX_EQ(transform, frame.renderPasses[3]->quad_list[0]->quadTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(transform, frame.renderPasses[3]->quad_list[0]->quadTransform());
// Quads from non-root RenderPasses should not be shifted though. // Quads from non-root RenderPasses should not be shifted though.
ASSERT_EQ(2u, frame.renderPasses[2]->quad_list.size()); 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(gfx::Transform(), 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[1]->quadTransform());
ASSERT_EQ(1u, frame.renderPasses[1]->quad_list.size()); 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 { 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 // Because the DelegatedRendererLayer owns a RenderSurfaceImpl, its root RenderPass' quads do not need to be
// modified at all. // 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. // Quads from non-root RenderPasses should not be shifted though.
ASSERT_EQ(2u, frame.renderPasses[2]->quad_list.size()); 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(gfx::Transform(), 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[1]->quadTransform());
ASSERT_EQ(1u, frame.renderPasses[1]->quad_list.size()); 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 { class DelegatedRendererLayerImplTestSharedData : public DelegatedRendererLayerImplTest {
@ -398,17 +397,17 @@ public:
delegatedRendererLayer->setBounds(gfx::Size(20, 20)); delegatedRendererLayer->setBounds(gfx::Size(20, 20));
delegatedRendererLayer->setContentBounds(gfx::Size(20, 20)); delegatedRendererLayer->setContentBounds(gfx::Size(20, 20));
delegatedRendererLayer->setDrawsContent(true); delegatedRendererLayer->setDrawsContent(true);
WebTransformationMatrix transform; gfx::Transform transform;
transform.translate(10, 10); transform.Translate(10, 10);
delegatedRendererLayer->setTransform(transform); delegatedRendererLayer->setTransform(transform);
ScopedPtrVector<RenderPass> delegatedRenderPasses; ScopedPtrVector<RenderPass> delegatedRenderPasses;
gfx::Rect passRect(0, 0, 50, 50); 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); MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_list);
AppendQuadsData data(pass->id); AppendQuadsData data(pass->id);
SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQuadState::Create()); 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; scoped_ptr<SolidColorDrawQuad> colorQuad;
colorQuad = SolidColorDrawQuad::Create(); colorQuad = SolidColorDrawQuad::Create();
@ -467,8 +466,8 @@ TEST_F(DelegatedRendererLayerImplTestSharedData, SharedData)
// The state should be transformed only once. // The state should be transformed only once.
EXPECT_RECT_EQ(gfx::Rect(30, 30, 50, 50), sharedState->clipped_rect_in_target); EXPECT_RECT_EQ(gfx::Rect(30, 30, 50, 50), sharedState->clipped_rect_in_target);
WebTransformationMatrix expected; gfx::Transform expected;
expected.translate(30, 30); expected.Translate(30, 30);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected, sharedState->content_to_target_transform); EXPECT_TRANSFORMATION_MATRIX_EQ(expected, sharedState->content_to_target_transform);
} }

@ -9,42 +9,40 @@
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "cc/math_util.h" #include "cc/math_util.h"
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix; static gfx::Transform orthoProjectionMatrix(float left, float right, float bottom, float top)
static WebTransformationMatrix orthoProjectionMatrix(float left, float right, float bottom, float top)
{ {
// Use the standard formula to map the clipping frustum to the cube from // Use the standard formula to map the clipping frustum to the cube from
// [-1, -1, -1] to [1, 1, 1]. // [-1, -1, -1] to [1, 1, 1].
float deltaX = right - left; float deltaX = right - left;
float deltaY = top - bottom; float deltaY = top - bottom;
WebTransformationMatrix proj; gfx::Transform proj;
if (!deltaX || !deltaY) if (!deltaX || !deltaY)
return proj; return proj;
proj.setM11(2.0f / deltaX); proj.matrix().setDouble(0, 0, 2.0f / deltaX);
proj.setM41(-(right + left) / deltaX); proj.matrix().setDouble(0, 3, -(right + left) / deltaX);
proj.setM22(2.0f / deltaY); proj.matrix().setDouble(1, 1, 2.0f / deltaY);
proj.setM42(-(top + bottom) / 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 // Z component of vertices is always set to zero as we don't use the depth buffer
// while drawing. // while drawing.
proj.setM33(0); proj.matrix().setDouble(2, 2, 0);
return proj; 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. // Map to window position and scale up to pixel coordinates.
canvas.translate3d(x, y, 0); canvas.Translate3d(x, y, 0);
canvas.scale3d(width, height, 0); canvas.Scale3d(width, height, 0);
// Map from ([-1, -1] to [1, 1]) -> ([0, 0] to [1, 1]) // Map from ([-1, -1] to [1, 1]) -> ([0, 0] to [1, 1])
canvas.translate3d(0.5, 0.5, 0.5); canvas.Translate3d(0.5, 0.5, 0.5);
canvas.scale3d(0.5, 0.5, 0.5); canvas.Scale3d(0.5, 0.5, 0.5);
return canvas; return canvas;
} }
@ -71,11 +69,11 @@ gfx::RectF DirectRenderer::quadVertexRect()
} }
// static // 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 = quadTransform;
quadRectTransform->translate(0.5 * quadRect.width() + quadRect.x(), 0.5 * quadRect.height() + quadRect.y()); quadRectTransform->Translate(0.5 * quadRect.width() + quadRect.x(), 0.5 * quadRect.height() + quadRect.y());
quadRectTransform->scaleNonUniform(quadRect.width(), quadRect.height()); quadRectTransform->Scale(quadRect.width(), quadRect.height());
} }
// static // static
@ -176,7 +174,7 @@ gfx::RectF DirectRenderer::computeScissorRectForRenderPass(const DrawingFrame& f
if (frame.rootDamageRect == frame.rootRenderPass->output_rect) if (frame.rootDamageRect == frame.rootRenderPass->output_rect)
return renderPassScissor; 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); gfx::RectF damageRectInRenderPassSpace = MathUtil::projectClippedRect(inverseTransform, frame.rootDamageRect);
renderPassScissor.Intersect(damageRectInRenderPassSpace); renderPassScissor.Intersect(damageRectInRenderPassSpace);

@ -39,8 +39,8 @@ public:
gfx::RectF rootDamageRect; gfx::RectF rootDamageRect;
WebKit::WebTransformationMatrix projectionMatrix; gfx::Transform projectionMatrix;
WebKit::WebTransformationMatrix windowMatrix; gfx::Transform windowMatrix;
bool flippedY; bool flippedY;
}; };
@ -71,7 +71,7 @@ protected:
}; };
static gfx::RectF quadVertexRect(); 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 void initializeMatrices(DrawingFrame&, const gfx::Rect& drawRect, bool flipY);
static gfx::Rect moveScissorToWindowSpace(const DrawingFrame&, gfx::RectF scissorRect); static gfx::Rect moveScissorToWindowSpace(const DrawingFrame&, gfx::RectF scissorRect);
static gfx::RectF computeScissorRectForRenderPass(const DrawingFrame& frame); static gfx::RectF computeScissorRectForRenderPass(const DrawingFrame& frame);

@ -35,7 +35,7 @@ class CC_EXPORT DrawQuad {
const SharedQuadState* copied_shared_quad_state) const; const SharedQuadState* copied_shared_quad_state) const;
// TODO(danakj): Chromify or remove these SharedQuadState helpers. // 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 visibleContentRect() const { return shared_quad_state->visible_content_rect; }
gfx::Rect clippedRectInTarget() const { return shared_quad_state->clipped_rect_in_target; } gfx::Rect clippedRectInTarget() const { return shared_quad_state->clipped_rect_in_target; }
gfx::Rect clipRect() const { return shared_quad_state->clip_rect; } gfx::Rect clipRect() const { return shared_quad_state->clip_rect; }

@ -7,6 +7,7 @@
#include "cc/checkerboard_draw_quad.h" #include "cc/checkerboard_draw_quad.h"
#include "cc/debug_border_draw_quad.h" #include "cc/debug_border_draw_quad.h"
#include "cc/io_surface_draw_quad.h" #include "cc/io_surface_draw_quad.h"
#include "cc/math_util.h"
#include "cc/render_pass_draw_quad.h" #include "cc/render_pass_draw_quad.h"
#include "cc/solid_color_draw_quad.h" #include "cc/solid_color_draw_quad.h"
#include "cc/stream_video_draw_quad.h" #include "cc/stream_video_draw_quad.h"
@ -15,16 +16,14 @@
#include "cc/tile_draw_quad.h" #include "cc/tile_draw_quad.h"
#include "cc/yuv_video_draw_quad.h" #include "cc/yuv_video_draw_quad.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
namespace { namespace {
TEST(DrawQuadTest, copySharedQuadState) 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 visibleContentRect(10, 12, 14, 16);
gfx::Rect clippedRectInTarget(19, 21, 23, 25); gfx::Rect clippedRectInTarget(19, 21, 23, 25);
gfx::Rect clipRect = clippedRectInTarget; gfx::Rect clipRect = clippedRectInTarget;
@ -45,7 +44,7 @@ TEST(DrawQuadTest, copySharedQuadState)
scoped_ptr<SharedQuadState> createSharedQuadState() 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 visibleContentRect(10, 12, 14, 16);
gfx::Rect clippedRectInTarget(19, 21, 23, 25); gfx::Rect clippedRectInTarget(19, 21, 23, 25);
gfx::Rect clipRect = clippedRectInTarget; gfx::Rect clipRect = clippedRectInTarget;
@ -325,7 +324,7 @@ TEST(DrawQuadTest, copyStreamVideoDrawQuad)
{ {
gfx::Rect opaqueRect(3, 7, 10, 12); gfx::Rect opaqueRect(3, 7, 10, 12);
unsigned textureId = 64; 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_SHARED_STATE();
CREATE_QUAD_3_NEW(StreamVideoDrawQuad, opaqueRect, textureId, matrix); CREATE_QUAD_3_NEW(StreamVideoDrawQuad, opaqueRect, textureId, matrix);

@ -6,27 +6,25 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include "ui/gfx/quad_f.h" #include "ui/gfx/quad_f.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
namespace { 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) TEST(FloatQuadTest, IsRectilinearTest)
{ {
const int numRectilinear = 8; const int numRectilinear = 8;
WebTransformationMatrix rectilinearTrans[numRectilinear]; gfx::Transform rectilinearTrans[numRectilinear];
rectilinearTrans[1].rotate(90); rectilinearTrans[1].Rotate(90);
rectilinearTrans[2].rotate(180); rectilinearTrans[2].Rotate(180);
rectilinearTrans[3].rotate(270); rectilinearTrans[3].Rotate(270);
rectilinearTrans[4].skewX(0.00000000001); rectilinearTrans[4].SkewX(0.00000000001);
rectilinearTrans[5].skewY(0.00000000001); rectilinearTrans[5].SkewY(0.00000000001);
rectilinearTrans[6].scale(0.00001); rectilinearTrans[6].Scale(0.00001, 0.00001);
rectilinearTrans[6].rotate(180); rectilinearTrans[6].Rotate(180);
rectilinearTrans[7].scale(100000); rectilinearTrans[7].Scale(100000, 100000);
rectilinearTrans[7].rotate(180); rectilinearTrans[7].Rotate(180);
for (int i = 0; i < numRectilinear; ++i) { for (int i = 0; i < numRectilinear; ++i) {
bool clipped = false; bool clipped = false;
@ -36,17 +34,17 @@ TEST(FloatQuadTest, IsRectilinearTest)
} }
const int numNonRectilinear = 10; const int numNonRectilinear = 10;
WebTransformationMatrix nonRectilinearTrans[numNonRectilinear]; gfx::Transform nonRectilinearTrans[numNonRectilinear];
nonRectilinearTrans[0].rotate(359.999); nonRectilinearTrans[0].Rotate(359.999);
nonRectilinearTrans[1].rotate(0.0000001); nonRectilinearTrans[1].Rotate(0.0000001);
nonRectilinearTrans[2].rotate(89.999999); nonRectilinearTrans[2].Rotate(89.999999);
nonRectilinearTrans[3].rotate(90.0000001); nonRectilinearTrans[3].Rotate(90.0000001);
nonRectilinearTrans[4].rotate(179.999999); nonRectilinearTrans[4].Rotate(179.999999);
nonRectilinearTrans[5].rotate(180.0000001); nonRectilinearTrans[5].Rotate(180.0000001);
nonRectilinearTrans[6].rotate(269.999999); nonRectilinearTrans[6].Rotate(269.999999);
nonRectilinearTrans[7].rotate(270.0000001); nonRectilinearTrans[7].Rotate(270.0000001);
nonRectilinearTrans[8].skewX(0.00001); nonRectilinearTrans[8].SkewX(0.00001);
nonRectilinearTrans[9].skewY(0.00001); nonRectilinearTrans[9].SkewY(0.00001);
for (int i = 0; i < numNonRectilinear; ++i) { for (int i = 0; i < numNonRectilinear; ++i) {
bool clipped = false; bool clipped = false;

@ -43,7 +43,6 @@ using namespace std;
using WebKit::WebGraphicsContext3D; using WebKit::WebGraphicsContext3D;
using WebKit::WebGraphicsMemoryAllocation; using WebKit::WebGraphicsMemoryAllocation;
using WebKit::WebSharedGraphicsContext3D; using WebKit::WebSharedGraphicsContext3D;
using WebKit::WebTransformationMatrix;
namespace cc { 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. // Use the full quadRect for debug quads to not move the edges based on partial swaps.
const gfx::Rect& layerRect = quad->rect; const gfx::Rect& layerRect = quad->rect;
WebTransformationMatrix renderMatrix = quad->quadTransform(); gfx::Transform renderMatrix = quad->quadTransform();
renderMatrix.translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerRect.height() + layerRect.y()); renderMatrix.Translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerRect.height() + layerRect.y());
renderMatrix.scaleNonUniform(layerRect.width(), layerRect.height()); renderMatrix.Scale(layerRect.width(), layerRect.height());
GLRenderer::toGLMatrix(&glMatrix[0], frame.projectionMatrix * renderMatrix); GLRenderer::toGLMatrix(&glMatrix[0], frame.projectionMatrix * renderMatrix);
GLC(context(), context()->uniformMatrix4fv(program->vertexShader().matrixLocation(), 1, false, &glMatrix[0])); 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( scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
DrawingFrame& frame, const RenderPassDrawQuad* quad, DrawingFrame& frame, const RenderPassDrawQuad* quad,
const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& filters,
const WebTransformationMatrix& contentsDeviceTransform, const gfx::Transform& contentsDeviceTransform,
const WebTransformationMatrix& contentsDeviceTransformInverse) 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. // 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: // The algorithm works as follows:
@ -492,10 +491,10 @@ scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
if (usingBackgroundTexture) { if (usingBackgroundTexture) {
// Copy the readback pixels from device to the background texture for the surface. // Copy the readback pixels from device to the background texture for the surface.
WebTransformationMatrix deviceToFramebufferTransform; gfx::Transform deviceToFramebufferTransform;
deviceToFramebufferTransform.translate(quad->rect.width() / 2.0, quad->rect.height() / 2.0); deviceToFramebufferTransform.Translate(quad->rect.width() / 2.0, quad->rect.height() / 2.0);
deviceToFramebufferTransform.scale3d(quad->rect.width(), quad->rect.height(), 1); deviceToFramebufferTransform.Scale3d(quad->rect.width(), quad->rect.height(), 1);
deviceToFramebufferTransform.multiply(contentsDeviceTransformInverse); deviceToFramebufferTransform.PreconcatTransform(contentsDeviceTransformInverse);
copyTextureToFramebuffer(frame, filteredDeviceBackgroundTextureId, deviceRect, deviceToFramebufferTransform); copyTextureToFramebuffer(frame, filteredDeviceBackgroundTextureId, deviceRect, deviceToFramebufferTransform);
} }
@ -517,15 +516,15 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
if (!renderPass) if (!renderPass)
return; return;
WebTransformationMatrix quadRectMatrix; gfx::Transform quadRectMatrix;
quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); 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. // Can only draw surface if device matrix is invertible.
if (!contentsDeviceTransform.isInvertible()) if (!contentsDeviceTransform.IsInvertible())
return; return;
WebTransformationMatrix contentsDeviceTransformInverse = contentsDeviceTransform.inverse(); gfx::Transform contentsDeviceTransformInverse = MathUtil::inverse(contentsDeviceTransform);
scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters(
frame, quad, renderPass->background_filters, frame, quad, renderPass->background_filters,
contentsDeviceTransform, contentsDeviceTransformInverse); contentsDeviceTransform, contentsDeviceTransformInverse);
@ -749,8 +748,8 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua
gfx::QuadF localQuad; gfx::QuadF localQuad;
WebTransformationMatrix deviceTransform = WebTransformationMatrix(frame.windowMatrix * frame.projectionMatrix * quad->quadTransform()).to2dTransform(); gfx::Transform deviceTransform = MathUtil::to2dTransform(frame.windowMatrix * frame.projectionMatrix * quad->quadTransform());
if (!deviceTransform.isInvertible()) if (!deviceTransform.IsInvertible())
return; return;
bool clipped = false; bool clipped = false;
@ -840,7 +839,7 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua
LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); 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. // 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); localQuad = MathUtil::mapQuad(deviceTransformInverse, deviceQuad.ToQuadF(), clipped);
// We should not DCHECK(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become // 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; m_isScissorEnabled = false;
} }
void GLRenderer::toGLMatrix(float* flattened, const WebTransformationMatrix& m) void GLRenderer::toGLMatrix(float* glMatrix, const gfx::Transform& transform)
{ {
flattened[0] = m.m11(); transform.matrix().asColMajorf(glMatrix);
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();
} }
void GLRenderer::setShaderQuadF(const gfx::QuadF& quad, int quadLocation) 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)); 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); quadRectTransform(&quadRectMatrix, drawTransform, quadRect);
static float glMatrix[16]; static float glMatrix[16];
toGLMatrix(&glMatrix[0], frame.projectionMatrix * quadRectMatrix); 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)); 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(); const RenderPassProgram* program = renderPassProgram();

@ -87,15 +87,15 @@ protected:
virtual void ensureScissorTestDisabled() OVERRIDE; virtual void ensureScissorTestDisabled() OVERRIDE;
private: private:
static void toGLMatrix(float*, const WebKit::WebTransformationMatrix&); static void toGLMatrix(float*, const gfx::Transform&);
static int priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::PriorityCutoff); static int priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::PriorityCutoff);
void drawCheckerboardQuad(const DrawingFrame&, const CheckerboardDrawQuad*); void drawCheckerboardQuad(const DrawingFrame&, const CheckerboardDrawQuad*);
void drawDebugBorderQuad(const DrawingFrame&, const DebugBorderDrawQuad*); void drawDebugBorderQuad(const DrawingFrame&, const DebugBorderDrawQuad*);
scoped_ptr<ScopedResource> drawBackgroundFilters( scoped_ptr<ScopedResource> drawBackgroundFilters(
DrawingFrame&, const RenderPassDrawQuad*, const WebKit::WebFilterOperations&, DrawingFrame&, const RenderPassDrawQuad*, const WebKit::WebFilterOperations&,
const WebKit::WebTransformationMatrix& contentsDeviceTransform, const gfx::Transform& contentsDeviceTransform,
const WebKit::WebTransformationMatrix& contentsDeviceTransformInverse); const gfx::Transform& contentsDeviceTransformInverse);
void drawRenderPassQuad(DrawingFrame&, const RenderPassDrawQuad*); void drawRenderPassQuad(DrawingFrame&, const RenderPassDrawQuad*);
void drawSolidColorQuad(const DrawingFrame&, const SolidColorDrawQuad*); void drawSolidColorQuad(const DrawingFrame&, const SolidColorDrawQuad*);
void drawStreamVideoQuad(const DrawingFrame&, const StreamVideoDrawQuad*); void drawStreamVideoQuad(const DrawingFrame&, const StreamVideoDrawQuad*);
@ -106,9 +106,9 @@ private:
void setShaderOpacity(float opacity, int alphaLocation); void setShaderOpacity(float opacity, int alphaLocation);
void setShaderQuadF(const gfx::QuadF&, int quadLocation); 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); bool useScopedTexture(DrawingFrame&, const ScopedResource*, const gfx::Rect& viewportRect);

@ -13,7 +13,7 @@
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using namespace WebKit; using namespace WebKit;
using namespace WebKitTests; using namespace WebKitTests;
@ -60,7 +60,7 @@ public:
m_rootLayer->createRenderSurface(); m_rootLayer->createRenderSurface();
RenderPass::Id renderPassId = m_rootLayer->renderSurface()->renderPassId(); RenderPass::Id renderPassId = m_rootLayer->renderSurface()->renderPassId();
scoped_ptr<RenderPass> rootRenderPass = RenderPass::Create(); 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_renderPassesInDrawOrder.push_back(rootRenderPass.get());
m_renderPasses.set(renderPassId, rootRenderPass.Pass()); m_renderPasses.set(renderPassId, rootRenderPass.Pass());
} }
@ -531,7 +531,7 @@ TEST(GLRendererTest2, activeTextureState)
cc::RenderPass::Id id(1, 1); cc::RenderPass::Id id(1, 1);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 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()); pass->AppendOneOfEveryQuadType(resourceProvider.get());
context->setInDraw(); context->setInDraw();

@ -32,8 +32,8 @@ void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*,
int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize; int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize;
gfx::Size bounds; gfx::Size bounds;
WebKit::WebTransformationMatrix matrix; gfx::Transform matrix;
matrix.makeIdentity(); matrix.MakeIdentity();
if (settings.showPlatformLayerTree || settings.showDebugRects()) { if (settings.showPlatformLayerTree || settings.showDebugRects()) {
int width = std::min(maxTextureSize, layerTreeHost()->deviceViewportSize().width()); int width = std::min(maxTextureSize, layerTreeHost()->deviceViewportSize().width());
@ -41,7 +41,7 @@ void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*,
bounds = gfx::Size(width, height); bounds = gfx::Size(width, height);
} else { } else {
bounds = gfx::Size(256, 128); bounds = gfx::Size(256, 128);
matrix.translate(layerTreeHost()->deviceViewportSize().width() - 256, 0); matrix.Translate(layerTreeHost()->deviceViewportSize().width() - 256, 0);
} }
setBounds(bounds); setBounds(bounds);

@ -16,7 +16,6 @@
#include <public/WebSize.h> #include <public/WebSize.h>
using namespace std; using namespace std;
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
@ -384,7 +383,7 @@ void Layer::setPosition(const gfx::PointF& position)
setNeedsCommit(); setNeedsCommit();
} }
void Layer::setSublayerTransform(const WebTransformationMatrix& sublayerTransform) void Layer::setSublayerTransform(const gfx::Transform& sublayerTransform)
{ {
if (m_sublayerTransform == sublayerTransform) if (m_sublayerTransform == sublayerTransform)
return; return;
@ -392,7 +391,7 @@ void Layer::setSublayerTransform(const WebTransformationMatrix& sublayerTransfor
setNeedsCommit(); setNeedsCommit();
} }
void Layer::setTransform(const WebTransformationMatrix& transform) void Layer::setTransform(const gfx::Transform& transform)
{ {
if (m_transform == transform) if (m_transform == transform)
return; return;
@ -480,7 +479,7 @@ void Layer::setForceRenderSurface(bool force)
setNeedsCommit(); setNeedsCommit();
} }
void Layer::setImplTransform(const WebTransformationMatrix& transform) void Layer::setImplTransform(const gfx::Transform& transform)
{ {
if (m_implTransform == transform) if (m_implTransform == transform)
return; return;
@ -726,12 +725,12 @@ void Layer::setOpacityFromAnimation(float opacity)
m_opacity = opacity; m_opacity = opacity;
} }
const WebKit::WebTransformationMatrix& Layer::transform() const const gfx::Transform& Layer::transform() const
{ {
return m_transform; 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 // 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 // also being run on the impl thread, there is no need to request a commit to push

@ -5,6 +5,10 @@
#ifndef CC_LAYER_H_ #ifndef CC_LAYER_H_
#define CC_LAYER_H_ #define CC_LAYER_H_
#include <public/WebFilterOperations.h>
#include <string>
#include <vector>
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/layer_animation_controller.h" #include "cc/layer_animation_controller.h"
@ -14,10 +18,7 @@
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include <public/WebFilterOperations.h> #include "ui/gfx/transform.h"
#include <public/WebTransformationMatrix.h>
#include <string>
#include <vector>
namespace WebKit { namespace WebKit {
class WebAnimationDelegate; class WebAnimationDelegate;
@ -51,11 +52,11 @@ public:
virtual int id() const OVERRIDE; virtual int id() const OVERRIDE;
virtual void setOpacityFromAnimation(float) OVERRIDE; virtual void setOpacityFromAnimation(float) OVERRIDE;
virtual float opacity() const 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, // 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). // 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. // 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* rootLayer();
Layer* parent() { return m_parent; } Layer* parent() { return m_parent; }
@ -121,10 +122,10 @@ public:
void setFixedToContainerLayer(bool); void setFixedToContainerLayer(bool);
bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } bool fixedToContainerLayer() const { return m_fixedToContainerLayer; }
void setSublayerTransform(const WebKit::WebTransformationMatrix&); void setSublayerTransform(const gfx::Transform&);
const WebKit::WebTransformationMatrix& sublayerTransform() const { return m_sublayerTransform; } const gfx::Transform& sublayerTransform() const { return m_sublayerTransform; }
void setTransform(const WebKit::WebTransformationMatrix&); void setTransform(const gfx::Transform&);
bool transformIsAnimating() const; bool transformIsAnimating() const;
const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; } const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; }
@ -163,8 +164,8 @@ public:
gfx::Vector2d scrollDelta() const { return gfx::Vector2d(); } gfx::Vector2d scrollDelta() const { return gfx::Vector2d(); }
void setImplTransform(const WebKit::WebTransformationMatrix&); void setImplTransform(const gfx::Transform&);
const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; } const gfx::Transform& implTransform() const { return m_implTransform; }
void setDoubleSided(bool); void setDoubleSided(bool);
bool doubleSided() const { return m_doubleSided; } 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. // 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 // 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). // root render surface, then this converts to physical pixels).
const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; } const gfx::Transform& drawTransform() const { return m_drawTransform; }
void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_drawTransform = matrix; } 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. // 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. // It converts logical, non-page-scaled pixels to physical pixels.
const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; } const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix) { m_screenSpaceTransform = matrix; } void setScreenSpaceTransform(const gfx::Transform& matrix) { m_screenSpaceTransform = matrix; }
bool isClipped() const { return m_isClipped; } bool isClipped() const { return m_isClipped; }
void setIsClipped(bool isClipped) { m_isClipped = isClipped; } void setIsClipped(bool isClipped) { m_isClipped = isClipped; }
@ -386,8 +387,8 @@ private:
bool m_drawCheckerboardForMissingTiles; bool m_drawCheckerboardForMissingTiles;
bool m_forceRenderSurface; bool m_forceRenderSurface;
WebKit::WebTransformationMatrix m_transform; gfx::Transform m_transform;
WebKit::WebTransformationMatrix m_sublayerTransform; gfx::Transform m_sublayerTransform;
// Replica layer used for reflections. // Replica layer used for reflections.
scoped_refptr<Layer> m_replicaLayer; scoped_refptr<Layer> m_replicaLayer;
@ -399,8 +400,8 @@ private:
Layer* m_renderTarget; Layer* m_renderTarget;
WebKit::WebTransformationMatrix m_drawTransform; gfx::Transform m_drawTransform;
WebKit::WebTransformationMatrix m_screenSpaceTransform; gfx::Transform m_screenSpaceTransform;
bool m_drawTransformIsAnimating; bool m_drawTransformIsAnimating;
bool m_screenSpaceTransformIsAnimating; bool m_screenSpaceTransformIsAnimating;
@ -415,7 +416,7 @@ private:
bool m_automaticallyComputeRasterScale; bool m_automaticallyComputeRasterScale;
bool m_boundsContainPageScale; bool m_boundsContainPageScale;
WebKit::WebTransformationMatrix m_implTransform; gfx::Transform m_implTransform;
WebKit::WebAnimationDelegate* m_layerAnimationDelegate; WebKit::WebAnimationDelegate* m_layerAnimationDelegate;
WebKit::WebLayerScrollClient* m_layerScrollClient; WebKit::WebLayerScrollClient* m_layerScrollClient;

@ -6,9 +6,7 @@
#include "cc/active_animation.h" #include "cc/active_animation.h"
#include "cc/keyframed_animation_curve.h" #include "cc/keyframed_animation_curve.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
@ -373,7 +371,7 @@ void LayerAnimationController::tickAnimations(double monotonicTime)
case ActiveAnimation::Transform: { case ActiveAnimation::Transform: {
const TransformAnimationCurve* transformAnimationCurve = m_activeAnimations[i]->curve()->toTransformAnimationCurve(); 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)) if (m_activeAnimations[i]->isFinishedAt(monotonicTime))
m_activeAnimations[i]->setRunState(ActiveAnimation::Finished, monotonicTime); m_activeAnimations[i]->setRunState(ActiveAnimation::Finished, monotonicTime);

@ -12,8 +12,8 @@
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/scoped_ptr_vector.h" #include "cc/scoped_ptr_vector.h"
namespace WebKit { namespace gfx {
class WebTransformationMatrix; class Transform;
} }
namespace cc { namespace cc {
@ -28,8 +28,8 @@ public:
virtual int id() const = 0; virtual int id() const = 0;
virtual void setOpacityFromAnimation(float) = 0; virtual void setOpacityFromAnimation(float) = 0;
virtual float opacity() const = 0; virtual float opacity() const = 0;
virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix&) = 0; virtual void setTransformFromAnimation(const gfx::Transform&) = 0;
virtual const WebKit::WebTransformationMatrix& transform() const = 0; virtual const gfx::Transform& transform() const = 0;
}; };
class CC_EXPORT LayerAnimationController { class CC_EXPORT LayerAnimationController {

@ -9,17 +9,16 @@
#include "cc/test/animation_test_common.h" #include "cc/test/animation_test_common.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using namespace WebKitTests; using namespace WebKitTests;
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
namespace { 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) scoped_ptr<ActiveAnimation> createActiveAnimation(scoped_ptr<AnimationCurve> curve, int id, ActiveAnimation::TargetProperty property)

@ -18,8 +18,6 @@
#include "ui/gfx/point_conversions.h" #include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
LayerImpl::LayerImpl(int id) LayerImpl::LayerImpl(int id)
@ -236,14 +234,14 @@ InputHandlerClient::ScrollStatus LayerImpl::tryScroll(const gfx::PointF& screenS
return InputHandlerClient::ScrollOnMainThread; return InputHandlerClient::ScrollOnMainThread;
} }
if (!screenSpaceTransform().isInvertible()) { if (!screenSpaceTransform().IsInvertible()) {
TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform"); TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform");
return InputHandlerClient::ScrollIgnored; return InputHandlerClient::ScrollIgnored;
} }
if (!nonFastScrollableRegion().IsEmpty()) { if (!nonFastScrollableRegion().IsEmpty()) {
bool clipped = false; 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()); gfx::PointF hitTestPointInLayerSpace = gfx::ScalePoint(hitTestPointInContentSpace, 1 / contentsScaleX(), 1 / contentsScaleY());
if (!clipped && nonFastScrollableRegion().Contains(gfx::ToRoundedPoint(hitTestPointInLayerSpace))) { if (!clipped && nonFastScrollableRegion().Contains(gfx::ToRoundedPoint(hitTestPointInLayerSpace))) {
TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRegion"); TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRegion");
@ -308,10 +306,10 @@ void LayerImpl::dumpLayerProperties(std::string* str, int indent) const
str->append(indentStr); str->append(indentStr);
base::StringAppendF(str, "drawTransform: %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f\n", 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.matrix().getDouble(0, 0), m_drawTransform.matrix().getDouble(0, 1), m_drawTransform.matrix().getDouble(0, 2), m_drawTransform.matrix().getDouble(0, 3),
m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_drawTransform.m24(), 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.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_drawTransform.m34(), 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.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_drawTransform.m44()); 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); str->append(indentStr);
base::StringAppendF(str, "drawsContent: %s\n", m_drawsContent ? "yes" : "no"); base::StringAppendF(str, "drawsContent: %s\n", m_drawsContent ? "yes" : "no");
@ -433,12 +431,12 @@ void LayerImpl::setOpacityFromAnimation(float opacity)
setOpacity(opacity); setOpacity(opacity);
} }
const WebKit::WebTransformationMatrix& LayerImpl::transform() const const gfx::Transform& LayerImpl::transform() const
{ {
return m_transform; return m_transform;
} }
void LayerImpl::setTransformFromAnimation(const WebTransformationMatrix& transform) void LayerImpl::setTransformFromAnimation(const gfx::Transform& transform)
{ {
setTransform(transform); setTransform(transform);
} }
@ -595,7 +593,7 @@ void LayerImpl::setPreserves3D(bool preserves3D)
noteLayerPropertyChangedForSubtree(); noteLayerPropertyChangedForSubtree();
} }
void LayerImpl::setSublayerTransform(const WebTransformationMatrix& sublayerTransform) void LayerImpl::setSublayerTransform(const gfx::Transform& sublayerTransform)
{ {
if (m_sublayerTransform == sublayerTransform) if (m_sublayerTransform == sublayerTransform)
return; return;
@ -605,7 +603,7 @@ void LayerImpl::setSublayerTransform(const WebTransformationMatrix& sublayerTran
noteLayerPropertyChangedForDescendants(); noteLayerPropertyChangedForDescendants();
} }
void LayerImpl::setTransform(const WebTransformationMatrix& transform) void LayerImpl::setTransform(const gfx::Transform& transform)
{ {
if (m_transform == transform) if (m_transform == transform)
return; return;
@ -656,7 +654,7 @@ void LayerImpl::setScrollDelta(const gfx::Vector2dF& scrollDelta)
noteLayerPropertyChangedForSubtree(); noteLayerPropertyChangedForSubtree();
} }
void LayerImpl::setImplTransform(const WebKit::WebTransformationMatrix& transform) void LayerImpl::setImplTransform(const gfx::Transform& transform)
{ {
if (m_implTransform == transform) if (m_implTransform == transform)
return; return;

@ -5,6 +5,7 @@
#ifndef CC_LAYER_IMPL_H_ #ifndef CC_LAYER_IMPL_H_
#define CC_LAYER_IMPL_H_ #define CC_LAYER_IMPL_H_
#include <public/WebFilterOperations.h>
#include <string> #include <string>
#include "base/logging.h" #include "base/logging.h"
@ -21,8 +22,7 @@
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include <public/WebFilterOperations.h> #include "ui/gfx/transform.h"
#include <public/WebTransformationMatrix.h>
namespace cc { namespace cc {
@ -49,8 +49,8 @@ public:
virtual int id() const OVERRIDE; virtual int id() const OVERRIDE;
virtual void setOpacityFromAnimation(float) OVERRIDE; virtual void setOpacityFromAnimation(float) OVERRIDE;
virtual float opacity() const OVERRIDE; virtual float opacity() const OVERRIDE;
virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix&) OVERRIDE; virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE;
virtual const WebKit::WebTransformationMatrix& transform() const OVERRIDE; virtual const gfx::Transform& transform() const OVERRIDE;
// Tree structure. // Tree structure.
LayerImpl* parent() { return m_parent; } LayerImpl* parent() { return m_parent; }
@ -145,8 +145,8 @@ public:
void setUseLCDText(bool useLCDText) { m_useLCDText = useLCDText; } void setUseLCDText(bool useLCDText) { m_useLCDText = useLCDText; }
bool useLCDText() const { return m_useLCDText; } bool useLCDText() const { return m_useLCDText; }
void setSublayerTransform(const WebKit::WebTransformationMatrix&); void setSublayerTransform(const gfx::Transform&);
const WebKit::WebTransformationMatrix& sublayerTransform() const { return m_sublayerTransform; } const gfx::Transform& sublayerTransform() const { return m_sublayerTransform; }
// Debug layer name. // Debug layer name.
void setDebugName(const std::string& debugName) { m_debugName = debugName; } void setDebugName(const std::string& debugName) { m_debugName = debugName; }
@ -193,8 +193,8 @@ public:
const gfx::Vector2dF& scrollDelta() const { return m_scrollDelta; } const gfx::Vector2dF& scrollDelta() const { return m_scrollDelta; }
void setScrollDelta(const gfx::Vector2dF&); void setScrollDelta(const gfx::Vector2dF&);
const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; } const gfx::Transform& implTransform() const { return m_implTransform; }
void setImplTransform(const WebKit::WebTransformationMatrix& transform); void setImplTransform(const gfx::Transform& transform);
const gfx::Vector2d& sentScrollDelta() const { return m_sentScrollDelta; } const gfx::Vector2d& sentScrollDelta() const { return m_sentScrollDelta; }
void setSentScrollDelta(const gfx::Vector2d& sentScrollDelta) { m_sentScrollDelta = sentScrollDelta; } void setSentScrollDelta(const gfx::Vector2d& sentScrollDelta) { m_sentScrollDelta = sentScrollDelta; }
@ -228,13 +228,13 @@ public:
bool doubleSided() const { return m_doubleSided; } bool doubleSided() const { return m_doubleSided; }
void setDoubleSided(bool); void setDoubleSided(bool);
void setTransform(const WebKit::WebTransformationMatrix&); void setTransform(const gfx::Transform&);
bool transformIsAnimating() const; bool transformIsAnimating() const;
const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; } const gfx::Transform& drawTransform() const { return m_drawTransform; }
void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_drawTransform = matrix; } void setDrawTransform(const gfx::Transform& matrix) { m_drawTransform = matrix; }
const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; } const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix) { m_screenSpaceTransform = matrix; } void setScreenSpaceTransform(const gfx::Transform& matrix) { m_screenSpaceTransform = matrix; }
bool drawTransformIsAnimating() const { return m_drawTransformIsAnimating; } bool drawTransformIsAnimating() const { return m_drawTransformIsAnimating; }
void setDrawTransformIsAnimating(bool animating) { m_drawTransformIsAnimating = animating; } void setDrawTransformIsAnimating(bool animating) { m_drawTransformIsAnimating = animating; }
@ -357,8 +357,8 @@ private:
bool m_preserves3D; bool m_preserves3D;
bool m_useParentBackfaceVisibility; bool m_useParentBackfaceVisibility;
bool m_drawCheckerboardForMissingTiles; bool m_drawCheckerboardForMissingTiles;
WebKit::WebTransformationMatrix m_sublayerTransform; gfx::Transform m_sublayerTransform;
WebKit::WebTransformationMatrix m_transform; gfx::Transform m_transform;
bool m_useLCDText; bool m_useLCDText;
bool m_drawsContent; bool m_drawsContent;
@ -372,7 +372,7 @@ private:
gfx::Vector2dF m_scrollDelta; gfx::Vector2dF m_scrollDelta;
gfx::Vector2d m_sentScrollDelta; gfx::Vector2d m_sentScrollDelta;
gfx::Vector2d m_maxScrollOffset; gfx::Vector2d m_maxScrollOffset;
WebKit::WebTransformationMatrix m_implTransform; gfx::Transform m_implTransform;
// The layer whose coordinate space this layer draws into. This can be // The layer whose coordinate space this layer draws into. This can be
// either the same layer (m_renderTarget == this) or an ancestor of this // either the same layer (m_renderTarget == this) or an ancestor of this
@ -392,8 +392,8 @@ private:
WebKit::WebFilterOperations m_backgroundFilters; WebKit::WebFilterOperations m_backgroundFilters;
SkImageFilter* m_filter; SkImageFilter* m_filter;
WebKit::WebTransformationMatrix m_drawTransform; gfx::Transform m_drawTransform;
WebKit::WebTransformationMatrix m_screenSpaceTransform; gfx::Transform m_screenSpaceTransform;
bool m_drawTransformIsAnimating; bool m_drawTransformIsAnimating;
bool m_screenSpaceTransformIsAnimating; bool m_screenSpaceTransformIsAnimating;

@ -76,8 +76,8 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
gfx::Rect arbitraryRect = gfx::Rect(arbitraryPoint, arbitrarySize); gfx::Rect arbitraryRect = gfx::Rect(arbitraryPoint, arbitrarySize);
gfx::RectF arbitraryRectF = gfx::RectF(arbitraryPointF, gfx::SizeF(1.234f, 5.678f)); gfx::RectF arbitraryRectF = gfx::RectF(arbitraryPointF, gfx::SizeF(1.234f, 5.678f));
SkColor arbitraryColor = SkColorSetRGB(10, 20, 30); SkColor arbitraryColor = SkColorSetRGB(10, 20, 30);
WebTransformationMatrix arbitraryTransform; gfx::Transform arbitraryTransform;
arbitraryTransform.scale3d(0.1, 0.2, 0.3); arbitraryTransform.Scale3d(0.1, 0.2, 0.3);
WebFilterOperations arbitraryFilters; WebFilterOperations arbitraryFilters;
arbitraryFilters.append(WebFilterOperation::createOpacityFilter(0.5)); arbitraryFilters.append(WebFilterOperation::createOpacityFilter(0.5));
SkAutoTUnref<SkImageFilter> arbitraryFilter(new SkBlurImageFilter(SK_Scalar1, SK_Scalar1)); SkAutoTUnref<SkImageFilter> arbitraryFilter(new SkBlurImageFilter(SK_Scalar1, SK_Scalar1));

@ -8,9 +8,8 @@
#include "cc/layer_tree_host_common.h" #include "cc/layer_tree_host_common.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.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::Mock;
using ::testing::_; using ::testing::_;
using ::testing::AtLeast; using ::testing::AtLeast;

@ -12,10 +12,9 @@
#include "base/logging.h" #include "base/logging.h"
#include "cc/math_util.h" #include "cc/math_util.h"
#include "cc/render_surface_impl.h" #include "cc/render_surface_impl.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using namespace std; using namespace std;
using WebKit::WebTransformationMatrix;
namespace cc { 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)); 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() << ")"; DVLOG(2) << "Layer " << node.layer->id() << " (" << node.layer->bounds().width() << " x " << node.layer->bounds().height() << ")";
WebTransformationMatrix drawTransform; gfx::Transform drawTransform;
float layerWidth, layerHeight; float layerWidth, layerHeight;
if (renderSurface) { if (renderSurface) {
drawTransform = renderSurface->drawTransform(); drawTransform = renderSurface->drawTransform();

@ -30,8 +30,8 @@ struct hash<cc::GraphEdge*> {
} // namespace BASE_HASH_NAMESPACE } // namespace BASE_HASH_NAMESPACE
#endif // COMPILER #endif // COMPILER
namespace WebKit { namespace gfx {
class WebTransformationMatrix; class Transform;
} }
namespace cc { namespace cc {
@ -41,7 +41,7 @@ struct GraphEdge;
// Holds various useful properties derived from a layer's 3D outline. // Holds various useful properties derived from a layer's 3D outline.
struct CC_EXPORT LayerShape { struct CC_EXPORT LayerShape {
LayerShape(); LayerShape();
LayerShape(float width, float height, const WebKit::WebTransformationMatrix& drawTransform); LayerShape(float width, float height, const gfx::Transform& drawTransform);
~LayerShape(); ~LayerShape();
float layerZFromProjectedPoint(const gfx::PointF&) const; float layerZFromProjectedPoint(const gfx::PointF&) const;

@ -8,9 +8,7 @@
#include "cc/math_util.h" #include "cc/math_util.h"
#include "cc/single_thread_proxy.h" #include "cc/single_thread_proxy.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
namespace { namespace {
@ -26,12 +24,12 @@ TEST(LayerSorterTest, BasicOverlap)
float weight = 0; float weight = 0;
// Trivial test, with one layer directly obscuring the other. // Trivial test, with one layer directly obscuring the other.
WebTransformationMatrix neg4Translate; gfx::Transform neg4Translate;
neg4Translate.translate3d(0, 0, -4); neg4Translate.Translate3d(0, 0, -4);
LayerShape front(2, 2, neg4Translate); LayerShape front(2, 2, neg4Translate);
WebTransformationMatrix neg5Translate; gfx::Transform neg5Translate;
neg5Translate.translate3d(0, 0, -5); neg5Translate.Translate3d(0, 0, -5);
LayerShape back(2, 2, neg5Translate); LayerShape back(2, 2, neg5Translate);
overlapResult = LayerSorter::checkOverlap(&front, &back, zThreshold, weight); overlapResult = LayerSorter::checkOverlap(&front, &back, zThreshold, weight);
@ -43,8 +41,8 @@ TEST(LayerSorterTest, BasicOverlap)
EXPECT_EQ(1, weight); EXPECT_EQ(1, weight);
// One layer translated off to the right. No overlap should be detected. // One layer translated off to the right. No overlap should be detected.
WebTransformationMatrix rightTranslate; gfx::Transform rightTranslate;
rightTranslate.translate3d(10, 0, -5); rightTranslate.Translate3d(10, 0, -5);
LayerShape backRight(2, 2, rightTranslate); LayerShape backRight(2, 2, rightTranslate);
overlapResult = LayerSorter::checkOverlap(&front, &backRight, zThreshold, weight); overlapResult = LayerSorter::checkOverlap(&front, &backRight, zThreshold, weight);
EXPECT_EQ(LayerSorter::None, overlapResult); EXPECT_EQ(LayerSorter::None, overlapResult);
@ -60,18 +58,18 @@ TEST(LayerSorterTest, RightAngleOverlap)
const float zThreshold = 0.1f; const float zThreshold = 0.1f;
float weight = 0; float weight = 0;
WebTransformationMatrix perspectiveMatrix; gfx::Transform perspectiveMatrix;
perspectiveMatrix.applyPerspective(1000); perspectiveMatrix.ApplyPerspectiveDepth(1000);
// Two layers forming a right angle with a perspective viewing transform. // Two layers forming a right angle with a perspective viewing transform.
WebTransformationMatrix leftFaceMatrix; gfx::Transform leftFaceMatrix;
leftFaceMatrix.translate3d(-1, 0, -5); leftFaceMatrix.Translate3d(-1, 0, -5);
leftFaceMatrix.rotate3d(0, 1, 0, -90); MathUtil::rotateAxisAngle(&leftFaceMatrix, 0, 1, 0, -90);
leftFaceMatrix.translate(-1, -1); leftFaceMatrix.Translate(-1, -1);
LayerShape leftFace(2, 2, perspectiveMatrix * leftFaceMatrix); LayerShape leftFace(2, 2, perspectiveMatrix * leftFaceMatrix);
WebTransformationMatrix frontFaceMatrix; gfx::Transform frontFaceMatrix;
frontFaceMatrix.translate3d(0, 0, -4); frontFaceMatrix.Translate3d(0, 0, -4);
frontFaceMatrix.translate(-1, -1); frontFaceMatrix.Translate(-1, -1);
LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix); LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
overlapResult = LayerSorter::checkOverlap(&frontFace, &leftFace, zThreshold, weight); overlapResult = LayerSorter::checkOverlap(&frontFace, &leftFace, zThreshold, weight);
@ -84,20 +82,20 @@ TEST(LayerSorterTest, IntersectingLayerOverlap)
const float zThreshold = 0.1f; const float zThreshold = 0.1f;
float weight = 0; float weight = 0;
WebTransformationMatrix perspectiveMatrix; gfx::Transform perspectiveMatrix;
perspectiveMatrix.applyPerspective(1000); perspectiveMatrix.ApplyPerspectiveDepth(1000);
// Intersecting layers. An explicit order will be returned based on relative z // Intersecting layers. An explicit order will be returned based on relative z
// values at the overlapping features but the weight returned should be zero. // values at the overlapping features but the weight returned should be zero.
WebTransformationMatrix frontFaceMatrix; gfx::Transform frontFaceMatrix;
frontFaceMatrix.translate3d(0, 0, -4); frontFaceMatrix.Translate3d(0, 0, -4);
frontFaceMatrix.translate(-1, -1); frontFaceMatrix.Translate(-1, -1);
LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix); LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
WebTransformationMatrix throughMatrix; gfx::Transform throughMatrix;
throughMatrix.translate3d(0, 0, -4); throughMatrix.Translate3d(0, 0, -4);
throughMatrix.rotate3d(0, 1, 0, 45); MathUtil::rotateAxisAngle(&throughMatrix, 0, 1, 0, 45);
throughMatrix.translate(-1, -1); throughMatrix.Translate(-1, -1);
LayerShape rotatedFace(2, 2, perspectiveMatrix * throughMatrix); LayerShape rotatedFace(2, 2, perspectiveMatrix * throughMatrix);
overlapResult = LayerSorter::checkOverlap(&frontFace, &rotatedFace, zThreshold, weight); overlapResult = LayerSorter::checkOverlap(&frontFace, &rotatedFace, zThreshold, weight);
EXPECT_NE(LayerSorter::None, overlapResult); 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). // 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. // A and B don't overlap, so they're incomparable.
WebTransformationMatrix transformA; gfx::Transform transformA;
transformA.translate3d(-6, 0, 1); transformA.Translate3d(-6, 0, 1);
transformA.translate(-4, -10); transformA.Translate(-4, -10);
LayerShape layerA(8, 20, transformA); LayerShape layerA(8, 20, transformA);
WebTransformationMatrix transformB; gfx::Transform transformB;
transformB.translate3d(6, 0, -1); transformB.Translate3d(6, 0, -1);
transformB.translate(-4, -10); transformB.Translate(-4, -10);
LayerShape layerB(8, 20, transformB); LayerShape layerB(8, 20, transformB);
WebTransformationMatrix transformC; gfx::Transform transformC;
transformC.rotate3d(0, 1, 0, 40); MathUtil::rotateAxisAngle(&transformC, 0, 1, 0, 40);
transformC.translate(-4, -10); transformC.Translate(-4, -10);
LayerShape layerC(8, 20, transformC); LayerShape layerC(8, 20, transformC);
overlapResult = LayerSorter::checkOverlap(&layerA, &layerC, zThreshold, weight); 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 // 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. // different bounds than it really does, which can cause things to sort incorrectly.
WebTransformationMatrix perspectiveMatrix; gfx::Transform perspectiveMatrix;
perspectiveMatrix.applyPerspective(1); perspectiveMatrix.ApplyPerspectiveDepth(1);
WebTransformationMatrix transformA; gfx::Transform transformA;
transformA.translate3d(-15, 0, -2); transformA.Translate3d(-15, 0, -2);
transformA.translate(-5, -5); transformA.Translate(-5, -5);
LayerShape layerA(10, 10, perspectiveMatrix * transformA); LayerShape layerA(10, 10, perspectiveMatrix * transformA);
// With this sequence of transforms, when layer B is correctly clipped, it will be // 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 // 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 // not clipped, its bounds will actually incorrectly appear much smaller and the
// correct sorting dependency will not be found. // correct sorting dependency will not be found.
WebTransformationMatrix transformB; gfx::Transform transformB;
transformB.translate3d(0, 0, 0.7); transformB.Translate3d(0, 0, 0.7);
transformB.rotate3d(0, 45, 0); MathUtil::rotateEulerAngles(&transformB, 0, 45, 0);
transformB.translate(-5, -5); transformB.Translate(-5, -5);
LayerShape layerB(10, 10, perspectiveMatrix * transformB); LayerShape layerB(10, 10, perspectiveMatrix * transformB);
// Sanity check that the test case actually covers the intended scenario, where part // 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> layer4 = LayerImpl::create(4);
scoped_ptr<LayerImpl> layer5 = LayerImpl::create(5); scoped_ptr<LayerImpl> layer5 = LayerImpl::create(5);
WebTransformationMatrix BehindMatrix; gfx::Transform BehindMatrix;
BehindMatrix.translate3d(0, 0, 2); BehindMatrix.Translate3d(0, 0, 2);
WebTransformationMatrix FrontMatrix; gfx::Transform FrontMatrix;
FrontMatrix.translate3d(0, 0, 1); FrontMatrix.Translate3d(0, 0, 1);
layer1->setBounds(gfx::Size(10, 10)); layer1->setBounds(gfx::Size(10, 10));
layer1->setContentBounds(gfx::Size(10, 10)); layer1->setContentBounds(gfx::Size(10, 10));

@ -734,14 +734,14 @@ void LayerTreeHost::applyScrollAndScale(const ScrollAndScaleSet& info)
gfx::PointF LayerTreeHost::adjustEventPointForPinchZoom(const gfx::PointF& zoomedViewportPoint) gfx::PointF LayerTreeHost::adjustEventPointForPinchZoom(const gfx::PointF& zoomedViewportPoint)
const const
{ {
if (m_implTransform.isIdentity()) if (m_implTransform.IsIdentity())
return zoomedViewportPoint; return zoomedViewportPoint;
DCHECK(m_implTransform.isInvertible()); DCHECK(m_implTransform.IsInvertible());
// Scale to screen space before applying implTransform inverse. // Scale to screen space before applying implTransform inverse.
gfx::PointF zoomedScreenspacePoint = gfx::ScalePoint(zoomedViewportPoint, deviceScaleFactor()); gfx::PointF zoomedScreenspacePoint = gfx::ScalePoint(zoomedViewportPoint, deviceScaleFactor());
WebKit::WebTransformationMatrix inverseImplTransform = m_implTransform.inverse(); gfx::Transform inverseImplTransform = MathUtil::inverse(m_implTransform);
bool wasClipped = false; bool wasClipped = false;
gfx::PointF unzoomedScreenspacePoint = MathUtil::projectPoint(inverseImplTransform, zoomedScreenspacePoint, wasClipped); gfx::PointF unzoomedScreenspacePoint = MathUtil::projectPoint(inverseImplTransform, zoomedScreenspacePoint, wasClipped);
@ -753,7 +753,7 @@ gfx::PointF LayerTreeHost::adjustEventPointForPinchZoom(const gfx::PointF& zoome
return unzoomedViewportPoint; return unzoomedViewportPoint;
} }
void LayerTreeHost::setImplTransform(const WebKit::WebTransformationMatrix& transform) void LayerTreeHost::setImplTransform(const gfx::Transform& transform)
{ {
m_implTransform = transform; m_implTransform = transform;
} }

@ -206,7 +206,7 @@ public:
// logical pixels in the un-zoomed viewport, the latter being the coordinates // logical pixels in the un-zoomed viewport, the latter being the coordinates
// required for hit-testing. // required for hit-testing.
gfx::PointF adjustEventPointForPinchZoom(const gfx::PointF& zoomedViewportPoint) const; gfx::PointF adjustEventPointForPinchZoom(const gfx::PointF& zoomedViewportPoint) const;
void setImplTransform(const WebKit::WebTransformationMatrix&); void setImplTransform(const gfx::Transform&);
void startRateLimiter(WebKit::WebGraphicsContext3D*); void startRateLimiter(WebKit::WebGraphicsContext3D*);
void stopRateLimiter(WebKit::WebGraphicsContext3D*); void stopRateLimiter(WebKit::WebGraphicsContext3D*);
@ -289,7 +289,7 @@ private:
float m_pageScaleFactor; float m_pageScaleFactor;
float m_minPageScaleFactor, m_maxPageScaleFactor; float m_minPageScaleFactor, m_maxPageScaleFactor;
WebKit::WebTransformationMatrix m_implTransform; gfx::Transform m_implTransform;
bool m_triggerIdleUpdates; bool m_triggerIdleUpdates;
SkColor m_backgroundColor; SkColor m_backgroundColor;

@ -4,6 +4,8 @@
#include "cc/layer_tree_host_common.h" #include "cc/layer_tree_host_common.h"
#include <algorithm>
#include "cc/layer.h" #include "cc/layer.h"
#include "cc/layer_impl.h" #include "cc/layer_impl.h"
#include "cc/layer_iterator.h" #include "cc/layer_iterator.h"
@ -13,10 +15,7 @@
#include "cc/render_surface_impl.h" #include "cc/render_surface_impl.h"
#include "ui/gfx/point_conversions.h" #include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
#include <algorithm> #include "ui/gfx/transform.h"
#include <public/WebTransformationMatrix.h>
using WebKit::WebTransformationMatrix;
namespace cc { 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? // Is this layer fully contained within the target surface?
gfx::Rect layerInSurfaceSpace = MathUtil::mapClippedRect(transform, layerBoundRect); 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 // This bounding rectangle may be larger than it needs to be (being
// axis-aligned), but is a reasonable filter on the space to consider. // axis-aligned), but is a reasonable filter on the space to consider.
// Non-invertible transforms will create an empty rect here. // 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))); gfx::Rect layerRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(surfaceToLayer, gfx::RectF(minimalSurfaceRect)));
layerRect.Intersect(layerBoundRect); layerRect.Intersect(layerBoundRect);
return layerRect; return layerRect;
@ -86,21 +85,21 @@ static bool isLayerBackFaceVisible(LayerType* layer)
// rendering context by checking if the parent preserves 3d. // rendering context by checking if the parent preserves 3d.
if (layerIsInExisting3DRenderingContext(layer)) 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 // In this case, either the layer establishes a new 3d rendering context, or is not in
// a 3d rendering context at all. // a 3d rendering context at all.
return layer->transform().isBackFaceVisible(); return MathUtil::isBackFaceVisible(layer->transform());
} }
template<typename LayerType> template<typename LayerType>
static bool isSurfaceBackFaceVisible(LayerType* layer, const WebTransformationMatrix& drawTransform) static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& drawTransform)
{ {
if (layerIsInExisting3DRenderingContext(layer)) if (layerIsInExisting3DRenderingContext(layer))
return drawTransform.isBackFaceVisible(); return MathUtil::isBackFaceVisible(drawTransform);
if (isRootLayerOfNewRenderingContext(layer)) 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 // 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. // 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 // 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 // have convert the current surface's clipRect from its ancestor surface space to
// the current surface space. // 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()); 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()); 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() return !m.matrix().getDouble(1, 0) && !m.matrix().getDouble(2, 0) && !m.matrix().getDouble(3, 0)
&& !m.m21() && !m.m23() && !m.m24() && !m.matrix().getDouble(0, 1) && !m.matrix().getDouble(2, 1) && !m.matrix().getDouble(3, 1)
&& !m.m31() && !m.m32() && !m.m43() && !m.matrix().getDouble(0, 2) && !m.matrix().getDouble(1, 2) && !m.matrix().getDouble(2, 3)
&& m.m44(); && m.matrix().getDouble(3, 3);
} }
static inline bool transformToParentIsKnown(LayerImpl*) static inline bool transformToParentIsKnown(LayerImpl*)
@ -265,7 +264,7 @@ static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
return false; 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 // 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 // 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. // that fixed position layer is fixed onto the same renderTarget as this scrollingLayer.
// //
WebTransformationMatrix partialLayerOriginTransform = parentMatrix; gfx::Transform partialLayerOriginTransform = parentMatrix;
partialLayerOriginTransform.multiply(scrollingLayer->implTransform()); partialLayerOriginTransform.PreconcatTransform(scrollingLayer->implTransform());
WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3 gfx::Transform scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3
scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // Step 2 scrollCompensationForThisLayer.Translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // Step 2
scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse()); // Step 1 scrollCompensationForThisLayer.PreconcatTransform(MathUtil::inverse(partialLayerOriginTransform)); // Step 1
return scrollCompensationForThisLayer; 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. // The main thread (i.e. Layer) does not need to worry about scroll compensation.
// So we can just return an identity matrix here. // 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 // "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. // occurred since the nearest container layer, even if there are renderSurfaces in-between.
@ -323,7 +322,7 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
return currentScrollCompensationMatrix; return currentScrollCompensationMatrix;
// Start as identity matrix. // Start as identity matrix.
WebTransformationMatrix nextScrollCompensationMatrix; gfx::Transform nextScrollCompensationMatrix;
// If this layer is not a container, then it inherits the existing scroll compensations. // If this layer is not a container, then it inherits the existing scroll compensations.
if (!layer->isContainerForFixedPositionLayers()) 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 // If the current layer has a non-zero scrollDelta, then we should compute its local scrollCompensation
// and accumulate it to the nextScrollCompensationMatrix. // and accumulate it to the nextScrollCompensationMatrix.
if (!layer->scrollDelta().IsZero()) { if (!layer->scrollDelta().IsZero()) {
WebTransformationMatrix scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix); gfx::Transform scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix);
nextScrollCompensationMatrix.multiply(scrollCompensationForThisLayer); nextScrollCompensationMatrix.PreconcatTransform(scrollCompensationForThisLayer);
} }
// If the layer created its own renderSurface, we have to adjust nextScrollCompensationMatrix. // 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 1 (right-most in the math): transform from the new surface to the original ancestor surface
// Step 2: apply the scroll compensation // Step 2: apply the scroll compensation
// Step 3: transform back to the new surface. // Step 3: transform back to the new surface.
if (layer->renderSurface() && !nextScrollCompensationMatrix.isIdentity()) if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity())
nextScrollCompensationMatrix = layer->renderSurface()->drawTransform().inverse() * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform(); nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()->drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform();
return nextScrollCompensationMatrix; return nextScrollCompensationMatrix;
} }
// There is no contentsScale on impl thread. // 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(); float rasterScale = layer->rasterScale();
if (!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 // Recursively walks the layer tree starting at the given node and computes all the
// necessary transformations, clipRects, render surfaces, etc. // necessary transformations, clipRects, render surfaces, etc.
template<typename LayerType, typename LayerList, typename RenderSurfaceType, typename LayerSorter> template<typename LayerType, typename LayerList, typename RenderSurfaceType, typename LayerSorter>
static void calculateDrawTransformsInternal(LayerType* layer, const WebTransformationMatrix& parentMatrix, static void calculateDrawTransformsInternal(LayerType* layer, const gfx::Transform& parentMatrix,
const WebTransformationMatrix& fullHierarchyMatrix, const WebTransformationMatrix& currentScrollCompensationMatrix, const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScrollCompensationMatrix,
const gfx::Rect& clipRectFromAncestor, bool ancestorClipsSubtree, const gfx::Rect& clipRectFromAncestor, bool ancestorClipsSubtree,
RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceLayerList, LayerList& layerList, RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceLayerList, LayerList& layerList,
LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, gfx::Rect& drawableContentRectOfSubtree) 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. // 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", // 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 // the transform to the anchor point is specified in "layer space", where the bounds
// of the layer map to [bounds.width(), bounds.height()]. // 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) // 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. // 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] // 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 anchorPoint = layer->anchorPoint();
gfx::PointF position = layer->position() - layer->scrollDelta(); gfx::PointF position = layer->position() - layer->scrollDelta();
WebTransformationMatrix layerLocalTransform; gfx::Transform layerLocalTransform;
// LT = Tr[origin] * Tr[origin2anchor] // 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] // LT = Tr[origin] * Tr[origin2anchor] * M[layer]
layerLocalTransform.multiply(layer->transform()); layerLocalTransform.PreconcatTransform(layer->transform());
// LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] // 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; gfx::Transform combinedTransform = parentMatrix;
combinedTransform.multiply(layerLocalTransform); combinedTransform.PreconcatTransform(layerLocalTransform);
// The layer's contentsSize is determined from the combinedTransform, which then informs the // The layer's contentsSize is determined from the combinedTransform, which then informs the
// layer's drawTransform. // 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 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. // 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] // 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. // layerScreenSpaceTransform represents the transform between root layer's "screen space" and local content space.
WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix; gfx::Transform layerScreenSpaceTransform = fullHierarchyMatrix;
if (!layer->preserves3D()) if (!layer->preserves3D())
MathUtil::flattenTransformTo2d(layerScreenSpaceTransform); MathUtil::flattenTransformTo2d(layerScreenSpaceTransform);
layerScreenSpaceTransform.multiply(drawTransform); layerScreenSpaceTransform.PreconcatTransform(drawTransform);
layer->setScreenSpaceTransform(layerScreenSpaceTransform); layer->setScreenSpaceTransform(layerScreenSpaceTransform);
gfx::RectF contentRect(gfx::PointF(), layer->contentBounds()); 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. // 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. // nextHierarchyMatrix will only change if this layer uses a new RenderSurfaceImpl, otherwise remains the same.
WebTransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix; gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix;
WebTransformationMatrix sublayerMatrix; gfx::Transform sublayerMatrix;
gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::computeTransform2dScaleComponents(combinedTransform); 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 // 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. // replace with a scale from the surface's subtree into layer space.
drawTransform.scaleNonUniform(layer->contentsScaleX(), layer->contentsScaleY()); drawTransform.Scale(layer->contentsScaleX(), layer->contentsScaleY());
drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y()); drawTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
renderSurface->setDrawTransform(drawTransform); renderSurface->setDrawTransform(drawTransform);
// The origin of the new surface is the upper left corner of the layer. // The origin of the new surface is the upper left corner of the layer.
WebTransformationMatrix layerDrawTransform; gfx::Transform layerDrawTransform;
layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y()); layerDrawTransform.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
layerDrawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY()); layerDrawTransform.Scale(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
layer->setDrawTransform(layerDrawTransform); layer->setDrawTransform(layerDrawTransform);
// Inside the surface's subtree, we scale everything to the owning layer's scale. // Inside the surface's subtree, we scale everything to the owning layer's scale.
// The sublayer matrix transforms centered layer rects into target // The sublayer matrix transforms centered layer rects into target
// surface content space. // surface content space.
sublayerMatrix.makeIdentity(); sublayerMatrix.MakeIdentity();
sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y()); 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. // The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity.
renderSurface->setDrawOpacity(drawOpacity); 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 // Update the aggregate hierarchy matrix to include the transform of the
// newly created RenderSurfaceImpl. // newly created RenderSurfaceImpl.
nextHierarchyMatrix.multiply(renderSurface->drawTransform()); nextHierarchyMatrix.PreconcatTransform(renderSurface->drawTransform());
// The new renderSurface here will correctly clip the entire subtree. So, we do // 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 // 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); MathUtil::flattenTransformTo2d(sublayerMatrix);
// Apply the sublayer transform at the center of the layer. // Apply the sublayer transform at the center of the layer.
sublayerMatrix.translate(0.5 * bounds.width(), 0.5 * bounds.height()); sublayerMatrix.Translate(0.5 * bounds.width(), 0.5 * bounds.height());
sublayerMatrix.multiply(layer->sublayerTransform()); sublayerMatrix.PreconcatTransform(layer->sublayerTransform());
sublayerMatrix.translate(-0.5 * bounds.width(), -0.5 * bounds.height()); sublayerMatrix.Translate(-0.5 * bounds.width(), -0.5 * bounds.height());
LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->layerList() : layerList); LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->layerList() : layerList);
@ -677,7 +676,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
if (!layerShouldBeSkipped(layer)) if (!layerShouldBeSkipped(layer))
descendants.push_back(layer); descendants.push_back(layer);
WebTransformationMatrix nextScrollCompensationMatrix = computeScrollCompensationMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);; gfx::Transform nextScrollCompensationMatrix = computeScrollCompensationMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);;
gfx::Rect accumulatedDrawableContentRectOfChildren; gfx::Rect accumulatedDrawableContentRectOfChildren;
for (size_t i = 0; i < layer->children().size(); ++i) { 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 // 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. // replace with a scale from the surface's subtree into layer space.
WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransform(); gfx::Transform screenSpaceTransform = layer->screenSpaceTransform();
screenSpaceTransform.scaleNonUniform(layer->contentsScaleX(), layer->contentsScaleY()); screenSpaceTransform.Scale(layer->contentsScaleX(), layer->contentsScaleY());
screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y()); screenSpaceTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
renderSurface->setScreenSpaceTransform(screenSpaceTransform); renderSurface->setScreenSpaceTransform(screenSpaceTransform);
if (layer->replicaLayer()) { if (layer->replicaLayer()) {
WebTransformationMatrix surfaceOriginToReplicaOriginTransform; gfx::Transform surfaceOriginToReplicaOriginTransform;
surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y()); surfaceOriginToReplicaOriginTransform.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer()->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), surfaceOriginToReplicaOriginTransform.Translate(layer->replicaLayer()->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(),
layer->replicaLayer()->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); layer->replicaLayer()->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height());
surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()->transform()); surfaceOriginToReplicaOriginTransform.PreconcatTransform(layer->replicaLayer()->transform());
surfaceOriginToReplicaOriginTransform.translate(-layer->replicaLayer()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y() * bounds.height()); surfaceOriginToReplicaOriginTransform.Translate(-layer->replicaLayer()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y() * bounds.height());
surfaceOriginToReplicaOriginTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y()); 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. // 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); renderSurface->setReplicaDrawTransform(replicaOriginTransform);
// Compute the replica's "screenSpaceTransform" that maps from the replica's origin space to the screen's origin space. // 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); 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) void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerList)
{ {
gfx::Rect totalDrawableContentRect; gfx::Rect totalDrawableContentRect;
WebTransformationMatrix identityMatrix; gfx::Transform identityMatrix;
WebTransformationMatrix deviceScaleTransform; gfx::Transform deviceScaleTransform;
deviceScaleTransform.scale(deviceScaleFactor); deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor);
std::vector<scoped_refptr<Layer> > dummyLayerList; std::vector<scoped_refptr<Layer> > dummyLayerList;
// The root layer's renderSurface should receive the deviceViewport as the initial clipRect. // 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) void LayerTreeHostCommon::calculateDrawTransforms(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, LayerSorter* layerSorter, int maxTextureSize, std::vector<LayerImpl*>& renderSurfaceLayerList)
{ {
gfx::Rect totalDrawableContentRect; gfx::Rect totalDrawableContentRect;
WebTransformationMatrix identityMatrix; gfx::Transform identityMatrix;
WebTransformationMatrix deviceScaleTransform; gfx::Transform deviceScaleTransform;
deviceScaleTransform.scale(deviceScaleFactor); deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor);
std::vector<LayerImpl*> dummyLayerList; std::vector<LayerImpl*> dummyLayerList;
// The root layer's renderSurface should receive the deviceViewport as the initial clipRect. // 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()); 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 the transform is not invertible, then assume that this point doesn't hit this rect.
if (!localSpaceToScreenSpaceTransform.isInvertible()) if (!localSpaceToScreenSpaceTransform.IsInvertible())
return false; return false;
// Transform the hit test point from screen space to the local space of the given rect. // Transform the hit test point from screen space to the local space of the given rect.
bool clipped = false; 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 projectPoint could not project to a valid value, then we assume that this point doesn't hit this rect.
if (clipped) if (clipped)
@ -887,15 +886,15 @@ static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const WebTransfor
return localSpaceRect.Contains(hitTestPointInLocalSpace); 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 the transform is not invertible, then assume that this point doesn't hit this region.
if (!screenSpaceTransform.isInvertible()) if (!screenSpaceTransform.IsInvertible())
return false; return false;
// Transform the hit test point from screen space to the local space of the given region. // Transform the hit test point from screen space to the local space of the given region.
bool clipped = false; 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); 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. // If projectPoint could not project to a valid value, then we assume that this point doesn't hit this region.

@ -9,8 +9,8 @@
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/scoped_ptr_vector.h" #include "cc/scoped_ptr_vector.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "ui/gfx/transform.h"
#include "ui/gfx/vector2d.h" #include "ui/gfx/vector2d.h"
#include <public/WebTransformationMatrix.h>
namespace cc { namespace cc {
@ -20,7 +20,7 @@ class Layer;
class CC_EXPORT LayerTreeHostCommon { class CC_EXPORT LayerTreeHostCommon {
public: 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(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); static void calculateDrawTransforms(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, LayerSorter*, int maxTextureSize, std::vector<LayerImpl*>& renderSurfaceLayerList);

File diff suppressed because it is too large Load Diff

@ -36,8 +36,6 @@
#include "ui/gfx/size_conversions.h" #include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h" #include "ui/gfx/vector2d_conversions.h"
using WebKit::WebTransformationMatrix;
namespace { namespace {
void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible)
@ -135,19 +133,19 @@ gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
return overflow; return overflow;
} }
WebTransformationMatrix PinchZoomViewport::implTransform(bool pageScalePinchZoomEnabled) const gfx::Transform PinchZoomViewport::implTransform(bool pageScalePinchZoomEnabled) const
{ {
WebTransformationMatrix transform; gfx::Transform transform;
transform.scale(m_pageScaleDelta); transform.Scale(m_pageScaleDelta, m_pageScaleDelta);
// If the pinch state is applied in the impl, then push it to the // If the pinch state is applied in the impl, then push it to the
// impl transform, otherwise the scale is handled by WebCore. // impl transform, otherwise the scale is handled by WebCore.
if (pageScalePinchZoomEnabled) { if (pageScalePinchZoomEnabled) {
transform.scale(m_pageScaleFactor); transform.Scale(m_pageScaleFactor, m_pageScaleFactor);
// The offset needs to be scaled by deviceScaleFactor as this transform // The offset needs to be scaled by deviceScaleFactor as this transform
// needs to work with physical pixels. // needs to work with physical pixels.
gfx::Vector2dF zoomedDeviceViewportOffset = gfx::ScaleVector2d(m_zoomedViewportOffset, m_deviceScaleFactor); gfx::Vector2dF zoomedDeviceViewportOffset = gfx::ScaleVector2d(m_zoomedViewportOffset, m_deviceScaleFactor);
transform.translate(-zoomedDeviceViewportOffset.x(), -zoomedDeviceViewportOffset.y()); transform.Translate(-zoomedDeviceViewportOffset.x(), -zoomedDeviceViewportOffset.y());
} }
return transform; 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. // 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). // 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(); gfx::Rect rootTargetRect = rootLayer->renderSurface()->contentRect();
float opacity = 1; float opacity = 1;
@ -461,7 +459,7 @@ static void appendQuadsToFillScreen(RenderPass* targetRenderPass, LayerImpl* roo
opacity); opacity);
AppendQuadsData appendQuadsData; AppendQuadsData appendQuadsData;
WebTransformationMatrix transformToLayerSpace = rootLayer->screenSpaceTransform().inverse(); gfx::Transform transformToLayerSpace = MathUtil::inverse(rootLayer->screenSpaceTransform());
for (Region::Iterator fillRects(fillRegion); fillRects.has_rect(); fillRects.next()) { for (Region::Iterator fillRects(fillRegion); fillRects.has_rect(); fillRects.next()) {
// The root layer transform is composed of translations and scales only, // The root layer transform is composed of translations and scales only,
// no perspective, so mapping is sufficient. // 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 // Layers with non-invertible screen space transforms should not have passed the scroll hit
// test in the first place. // test in the first place.
DCHECK(layerImpl.screenSpaceTransform().isInvertible()); DCHECK(layerImpl.screenSpaceTransform().IsInvertible());
WebTransformationMatrix inverseScreenSpaceTransform = layerImpl.screenSpaceTransform().inverse(); gfx::Transform inverseScreenSpaceTransform = MathUtil::inverse(layerImpl.screenSpaceTransform());
gfx::PointF screenSpacePoint = gfx::ScalePoint(viewportPoint, scaleFromViewportToScreenSpace); gfx::PointF screenSpacePoint = gfx::ScalePoint(viewportPoint, scaleFromViewportToScreenSpace);
@ -1462,7 +1460,7 @@ scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::processScrollDeltas()
return scrollInfo.Pass(); return scrollInfo.Pass();
} }
WebTransformationMatrix LayerTreeHostImpl::implTransform() const gfx::Transform LayerTreeHostImpl::implTransform() const
{ {
return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnabled); return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnabled);
} }

@ -100,7 +100,7 @@ public:
// origin of the zoomedDeviceViewport. // origin of the zoomedDeviceViewport.
// //
// implTransform = S[pageScale] * Tr[-zoomedDeviceViewportOffset] // implTransform = S[pageScale] * Tr[-zoomedDeviceViewportOffset]
WebKit::WebTransformationMatrix implTransform(bool pageScalePinchZoomEnabled) const; gfx::Transform implTransform(bool pageScalePinchZoomEnabled) const;
private: private:
float m_pageScaleFactor; float m_pageScaleFactor;
@ -228,7 +228,7 @@ public:
void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor); void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor);
scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> processScrollDeltas();
WebKit::WebTransformationMatrix implTransform() const; gfx::Transform implTransform() const;
void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration); void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);

@ -552,7 +552,7 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
DCHECK(scrollLayer); DCHECK(scrollLayer);
const float minPageScale = 1, maxPageScale = 4; 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. // 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 minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5;
const float maxPageScale = 4; const float maxPageScale = 4;
const WebTransformationMatrix identityScaleTransform; const gfx::Transform identityScaleTransform;
// Basic pinch zoom in gesture // Basic pinch zoom in gesture
{ {
@ -718,7 +718,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2;
const base::TimeTicks endTime = startTime + duration; const base::TimeTicks endTime = startTime + duration;
const WebTransformationMatrix identityScaleTransform; const gfx::Transform identityScaleTransform;
// Non-anchor zoom-in // Non-anchor zoom-in
{ {
@ -1180,8 +1180,8 @@ TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild)
scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
m_hostImpl->setViewportSize(surfaceSize, surfaceSize); m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
WebTransformationMatrix matrix; gfx::Transform matrix;
matrix.rotate3d(180, 0, 0); MathUtil::rotateEulerAngles(&matrix, 180, 0, 0);
child->setTransform(matrix); child->setTransform(matrix);
child->setDoubleSided(false); child->setDoubleSided(false);
@ -1244,7 +1244,26 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale. // 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) TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
@ -1278,8 +1297,8 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta should match the new scale on the impl side. // The page scale delta should match the new scale on the impl side.
WebTransformationMatrix expectedScale; gfx::Transform expectedScale;
expectedScale.scale(pageScale); expectedScale.Scale(pageScale, pageScale);
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
} }
@ -1287,11 +1306,11 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
{ {
gfx::Size surfaceSize(10, 10); gfx::Size surfaceSize(10, 10);
float defaultPageScale = 1; float defaultPageScale = 1;
WebTransformationMatrix defaultPageScaleMatrix; gfx::Transform defaultPageScaleMatrix;
float newPageScale = 2; float newPageScale = 2;
WebTransformationMatrix newPageScaleMatrix; gfx::Transform newPageScaleMatrix;
newPageScaleMatrix.scale(newPageScale); newPageScaleMatrix.Scale(newPageScale, newPageScale);
// Create a normal scrollable root layer and another scrollable child layer. // Create a normal scrollable root layer and another scrollable child layer.
setupScrollAndContentsLayers(surfaceSize); setupScrollAndContentsLayers(surfaceSize);
@ -1320,12 +1339,12 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
m_hostImpl->drawLayers(frame); m_hostImpl->drawLayers(frame);
m_hostImpl->didDrawAllLayers(frame); m_hostImpl->didDrawAllLayers(frame);
EXPECT_EQ(root->drawTransform().m11(), newPageScale); EXPECT_EQ(root->drawTransform().matrix().getDouble(0, 0), newPageScale);
EXPECT_EQ(root->drawTransform().m22(), newPageScale); EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale);
EXPECT_EQ(child->drawTransform().m11(), newPageScale); EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale);
EXPECT_EQ(child->drawTransform().m22(), newPageScale); EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale);
EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale);
EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale);
} }
TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
@ -1367,8 +1386,8 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale. // The page scale delta remains constant because the impl thread did not scale.
WebTransformationMatrix identityTransform; gfx::Transform identityTransform;
EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); EXPECT_EQ(child->implTransform(), gfx::Transform());
} }
TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit) TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
@ -1456,8 +1475,8 @@ TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
setupScrollAndContentsLayers(gfx::Size(100, 100)); setupScrollAndContentsLayers(gfx::Size(100, 100));
// Rotate the root layer 90 degrees counter-clockwise about its center. // Rotate the root layer 90 degrees counter-clockwise about its center.
WebTransformationMatrix rotateTransform; gfx::Transform rotateTransform;
rotateTransform.rotate(-90); rotateTransform.Rotate(-90);
m_hostImpl->rootLayer()->setTransform(rotateTransform); m_hostImpl->rootLayer()->setTransform(rotateTransform);
gfx::Size surfaceSize(50, 50); 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. // Create a child layer that is rotated to a non-axis-aligned angle.
scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl->rootLayer()->contentBounds()); scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl->rootLayer()->contentBounds());
WebTransformationMatrix rotateTransform; gfx::Transform rotateTransform;
rotateTransform.translate(-50, -50); rotateTransform.Translate(-50, -50);
rotateTransform.rotate(childLayerAngle); rotateTransform.Rotate(childLayerAngle);
rotateTransform.translate(50, 50); rotateTransform.Translate(50, 50);
child->setTransform(rotateTransform); child->setTransform(rotateTransform);
// Only allow vertical scrolling. // Only allow vertical scrolling.
@ -1553,8 +1572,8 @@ TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
// Scale the layer to twice its normal size. // Scale the layer to twice its normal size.
int scale = 2; int scale = 2;
WebTransformationMatrix scaleTransform; gfx::Transform scaleTransform;
scaleTransform.scale(scale); scaleTransform.Scale(scale, scale);
m_hostImpl->rootLayer()->setTransform(scaleTransform); m_hostImpl->rootLayer()->setTransform(scaleTransform);
gfx::Size surfaceSize(50, 50); 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); ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 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(); 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(); 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); 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. // Rotation will put part of the child ouside the bounds of the root layer.
// Nevertheless, the child layers should be drawn. // Nevertheless, the child layers should be drawn.
WebTransformationMatrix transform = surfaceLayerPtr->transform(); gfx::Transform transform = surfaceLayerPtr->transform();
transform.translate(50, 50); transform.Translate(50, 50);
transform.rotate(35); transform.Rotate(35);
transform.translate(-50, -50); transform.Translate(-50, -50);
surfaceLayerPtr->setTransform(transform); surfaceLayerPtr->setTransform(transform);
{ {
@ -3203,9 +3222,9 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
} }
transform = surfaceLayerPtr->transform(); transform = surfaceLayerPtr->transform();
transform.translate(50, 50); transform.Translate(50, 50);
transform.rotate(-35); transform.Rotate(-35);
transform.translate(-50, -50); transform.Translate(-50, -50);
surfaceLayerPtr->setTransform(transform); surfaceLayerPtr->setTransform(transform);
// The surface is now aligned again, and the clipped parts are exposed. // 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. // "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached; // Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion. // Must keep S1 quads because texture contained external occlusion.
WebTransformationMatrix transform = layerS2Ptr->transform(); gfx::Transform transform = layerS2Ptr->transform();
transform.translate(150, 150); transform.Translate(150, 150);
layerS2Ptr->setTransform(transform); layerS2Ptr->setTransform(transform);
{ {
LayerTreeHostImpl::FrameData frame; LayerTreeHostImpl::FrameData frame;
@ -3322,7 +3341,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
// Must remove S1's render pass since it is now available in full. // Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed. // S2 has no change so must also be removed.
transform = layerS2Ptr->transform(); transform = layerS2Ptr->transform();
transform.translate(-15, -15); transform.Translate(-15, -15);
layerS2Ptr->setTransform(transform); layerS2Ptr->setTransform(transform);
{ {
LayerTreeHostImpl::FrameData frame; LayerTreeHostImpl::FrameData frame;
@ -3413,8 +3432,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
// "Unocclude" surface S1 and repeat draw. // "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached; // Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion. // Must keep S1 quads because texture contained external occlusion.
WebTransformationMatrix transform = layerS2Ptr->transform(); gfx::Transform transform = layerS2Ptr->transform();
transform.translate(100, 100); transform.Translate(100, 100);
layerS2Ptr->setTransform(transform); layerS2Ptr->setTransform(transform);
{ {
LayerTreeHostImpl::FrameData frame; LayerTreeHostImpl::FrameData frame;
@ -3437,7 +3456,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
// Must remove S1's render pass since it is now available in full. // Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed. // S2 has no change so must also be removed.
transform = layerS2Ptr->transform(); transform = layerS2Ptr->transform();
transform.translate(-15, -15); transform.Translate(-15, -15);
layerS2Ptr->setTransform(transform); layerS2Ptr->setTransform(transform);
{ {
LayerTreeHostImpl::FrameData frame; LayerTreeHostImpl::FrameData frame;
@ -3519,8 +3538,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
// "Unocclude" surface S1 and repeat draw. // "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached; // Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion. // Must keep S1 quads because texture contained external occlusion.
WebTransformationMatrix transform = layerS2Ptr->transform(); gfx::Transform transform = layerS2Ptr->transform();
transform.translate(300, 0); transform.Translate(300, 0);
layerS2Ptr->setTransform(transform); layerS2Ptr->setTransform(transform);
{ {
LayerTreeHostImpl::FrameData frame; LayerTreeHostImpl::FrameData frame;
@ -3573,10 +3592,10 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
layerS1Ptr->setForceRenderSurface(true); layerS1Ptr->setForceRenderSurface(true);
WebTransformationMatrix transform = layerS1Ptr->transform(); gfx::Transform transform = layerS1Ptr->transform();
transform.translate(200, 200); transform.Translate(200, 200);
transform.rotate(45); transform.Rotate(45);
transform.translate(-200, -200); transform.Translate(-200, -200);
layerS1Ptr->setTransform(transform); layerS1Ptr->setTransform(transform);
addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 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. // "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached; // Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion. // Must keep S1 quads because texture contained external occlusion.
WebTransformationMatrix transform = layerS2Ptr->transform(); gfx::Transform transform = layerS2Ptr->transform();
transform.translate(150, 150); transform.Translate(150, 150);
layerS2Ptr->setTransform(transform); layerS2Ptr->setTransform(transform);
{ {
LayerTreeHostImpl::FrameData frame; LayerTreeHostImpl::FrameData frame;
@ -3710,7 +3729,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
// Must remove S1's render pass since it is now available in full. // Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed. // S2 has no change so must also be removed.
transform = layerS2Ptr->transform(); transform = layerS2Ptr->transform();
transform.translate(-15, -15); transform.Translate(-15, -15);
layerS2Ptr->setTransform(transform); layerS2Ptr->setTransform(transform);
{ {
LayerTreeHostImpl::FrameData frame; LayerTreeHostImpl::FrameData frame;
@ -3968,8 +3987,8 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching)
} }
// Change location of the intermediate layer // Change location of the intermediate layer
WebTransformationMatrix transform = intermediateLayerPtr->transform(); gfx::Transform transform = intermediateLayerPtr->transform();
transform.setM41(1.0001); transform.matrix().setDouble(0, 3, 1.0001);
intermediateLayerPtr->setTransform(transform); intermediateLayerPtr->setTransform(transform);
{ {
LayerTreeHostImpl::FrameData frame; LayerTreeHostImpl::FrameData frame;
@ -4129,8 +4148,8 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
} }
// Change location of the intermediate layer // Change location of the intermediate layer
WebTransformationMatrix transform = intermediateLayerPtr->transform(); gfx::Transform transform = intermediateLayerPtr->transform();
transform.setM41(1.0001); transform.matrix().setDouble(0, 3, 1.0001);
intermediateLayerPtr->setTransform(transform); intermediateLayerPtr->setTransform(transform);
{ {
LayerTreeHostImpl::FrameData frame; 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 // One shared state for all quads - we don't need the correct details
testData.sharedQuadState = SharedQuadState::Create(); 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; const char* currentChar = testScript;
// Pre-create root pass // Pre-create root pass
RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1]); RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1]);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 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()); testData.renderPassCache.add(rootRenderPassId, pass.Pass());
while (*currentChar) { while (*currentChar) {
int layerId = *currentChar; int layerId = *currentChar;
@ -4291,7 +4310,7 @@ static void configureRenderPassTestData(const char* testScript, RenderPassRemova
renderer->setHaveCachedResourcesForRenderPassId(newRenderPassId); renderer->setHaveCachedResourcesForRenderPassId(newRenderPassId);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 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()); testData.renderPassCache.add(newRenderPassId, pass.Pass());
} }
@ -4538,8 +4557,8 @@ void LayerTreeHostImplTest::pinchZoomPanViewportForcesCommitRedraw(const float d
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform(); m_hostImpl->updateRootScrollLayerImplTransform();
WebTransformationMatrix expectedImplTransform; gfx::Transform expectedImplTransform;
expectedImplTransform.scale(pageScale); expectedImplTransform.Scale(pageScale, pageScale);
// Verify the pinch zoom took place. // Verify the pinch zoom took place.
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
@ -4610,8 +4629,8 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform(); m_hostImpl->updateRootScrollLayerImplTransform();
WebTransformationMatrix expectedImplTransform; gfx::Transform expectedImplTransform;
expectedImplTransform.scale(pageScale); expectedImplTransform.Scale(pageScale, pageScale);
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
@ -4628,7 +4647,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact
m_hostImpl->updateRootScrollLayerImplTransform(); m_hostImpl->updateRootScrollLayerImplTransform();
gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor()); 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()); EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
// No change expected. // No change expected.
@ -4645,7 +4664,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact
m_hostImpl->updateRootScrollLayerImplTransform(); m_hostImpl->updateRootScrollLayerImplTransform();
expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor()); 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()); EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
// No change expected. // No change expected.
@ -4690,8 +4709,8 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform(); m_hostImpl->updateRootScrollLayerImplTransform();
WebTransformationMatrix expectedImplTransform; gfx::Transform expectedImplTransform;
expectedImplTransform.scale(pageScale); expectedImplTransform.Scale(pageScale, pageScale);
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
@ -4727,7 +4746,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
gfx::Vector2d expectedPanDelta(scrollDelta); gfx::Vector2d expectedPanDelta(scrollDelta);
gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor()); 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); EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
@ -4762,7 +4781,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
expectedPanDelta = scrollDelta; expectedPanDelta = scrollDelta;
expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor()); 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()); EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
@ -4809,8 +4828,8 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform(); m_hostImpl->updateRootScrollLayerImplTransform();
WebTransformationMatrix expectedImplTransform; gfx::Transform expectedImplTransform;
expectedImplTransform.scale(pageScale); expectedImplTransform.Scale(pageScale, pageScale);
EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 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::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoomViewport pan.
gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor()); 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); EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
@ -4855,7 +4874,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
expectedPanDelta = gfx::Vector2d(0, 1); expectedPanDelta = gfx::Vector2d(0, 1);
expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor()); 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()); EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
} }

@ -1339,20 +1339,20 @@ public:
gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5)); gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5));
EXPECT_EQ(childBoundsScaled, child->contentBounds()); EXPECT_EQ(childBoundsScaled, child->contentBounds());
WebTransformationMatrix scaleTransform; gfx::Transform scaleTransform;
scaleTransform.scale(impl->deviceScaleFactor()); scaleTransform.Scale(impl->deviceScaleFactor(), impl->deviceScaleFactor());
// The root layer is scaled by 2x. // The root layer is scaled by 2x.
WebTransformationMatrix rootScreenSpaceTransform = scaleTransform; gfx::Transform rootScreenSpaceTransform = scaleTransform;
WebTransformationMatrix rootDrawTransform = scaleTransform; gfx::Transform rootDrawTransform = scaleTransform;
EXPECT_EQ(rootDrawTransform, root->drawTransform()); EXPECT_EQ(rootDrawTransform, root->drawTransform());
EXPECT_EQ(rootScreenSpaceTransform, root->screenSpaceTransform()); EXPECT_EQ(rootScreenSpaceTransform, root->screenSpaceTransform());
// The child is at position 2,2, which is transformed to 3,3 after the scale // The child is at position 2,2, which is transformed to 3,3 after the scale
WebTransformationMatrix childScreenSpaceTransform; gfx::Transform childScreenSpaceTransform;
childScreenSpaceTransform.translate(3, 3); childScreenSpaceTransform.Translate(3, 3);
WebTransformationMatrix childDrawTransform = childScreenSpaceTransform; gfx::Transform childDrawTransform = childScreenSpaceTransform;
EXPECT_EQ(childDrawTransform, child->drawTransform()); EXPECT_EQ(childDrawTransform, child->drawTransform());
EXPECT_EQ(childScreenSpaceTransform, child->screenSpaceTransform()); EXPECT_EQ(childScreenSpaceTransform, child->screenSpaceTransform());
@ -1465,7 +1465,7 @@ TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread)
runTest(true); 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(); layer->removeAllChildren();
if (parent) if (parent)
@ -1493,7 +1493,7 @@ public:
m_layerTreeHost->setRootLayer(m_parent); m_layerTreeHost->setRootLayer(m_parent);
m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); 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_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); 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; 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); setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bounds, opaque);
layer->clearOccludedScreenSpace(); layer->clearOccludedScreenSpace();
@ -1655,11 +1655,11 @@ public:
scoped_refptr<TestLayer> grandChild = TestLayer::create(); scoped_refptr<TestLayer> grandChild = TestLayer::create();
scoped_refptr<TestLayer> mask = TestLayer::create(); scoped_refptr<TestLayer> mask = TestLayer::create();
WebTransformationMatrix identityMatrix; gfx::Transform identityMatrix;
WebTransformationMatrix childTransform; gfx::Transform childTransform;
childTransform.translate(250, 250); childTransform.Translate(250, 250);
childTransform.rotate(90); childTransform.Rotate(90);
childTransform.translate(-250, -250); childTransform.Translate(-250, -250);
child->setMasksToBounds(true); child->setMasksToBounds(true);
@ -1828,11 +1828,11 @@ public:
scoped_refptr<TestLayer> grandChild = TestLayer::create(); scoped_refptr<TestLayer> grandChild = TestLayer::create();
scoped_refptr<TestLayer> mask = TestLayer::create(); scoped_refptr<TestLayer> mask = TestLayer::create();
WebTransformationMatrix identityMatrix; gfx::Transform identityMatrix;
WebTransformationMatrix childTransform; gfx::Transform childTransform;
childTransform.translate(250, 250); childTransform.Translate(250, 250);
childTransform.rotate(90); childTransform.Rotate(90);
childTransform.translate(-250, -250); childTransform.Translate(-250, -250);
child->setMasksToBounds(true); child->setMasksToBounds(true);
@ -1907,7 +1907,7 @@ public:
{ {
// We create enough RenderSurfaces that it will trigger Vector reallocation while computing occlusion. // We create enough RenderSurfaces that it will trigger Vector reallocation while computing occlusion.
Region occluded; Region occluded;
const WebTransformationMatrix identityMatrix; const gfx::Transform identityMatrix;
std::vector<scoped_refptr<TestLayer> > layers; std::vector<scoped_refptr<TestLayer> > layers;
std::vector<scoped_refptr<TestLayer> > children; std::vector<scoped_refptr<TestLayer> > children;
int numSurfaces = 20; int numSurfaces = 20;
@ -2708,7 +2708,7 @@ public:
m_layerTreeHost->setRootLayer(m_layer); m_layerTreeHost->setRootLayer(m_layer);
m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); 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); setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true);
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
@ -2841,7 +2841,7 @@ public:
m_layerTreeHost->setRootLayer(m_layer); m_layerTreeHost->setRootLayer(m_layer);
m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); 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); setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true);
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
@ -2966,7 +2966,7 @@ public:
m_layerTreeHost->setRootLayer(m_parent); m_layerTreeHost->setRootLayer(m_parent);
m_layerTreeHost->setViewportSize(gfx::Size(m_numChildren, 1), gfx::Size(m_numChildren, 1)); 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); 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++) 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); 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 virtual void beginTest() OVERRIDE
{ {
WebTransformationMatrix m; gfx::Transform m;
m.translate(250, 360); m.Translate(250, 360);
m.scale(2); m.Scale(2, 2);
gfx::Point point(400, 550); gfx::Point point(400, 550);
gfx::Point transformedPoint; gfx::Point transformedPoint;
// Unit transform, no change expected. // Unit transform, no change expected.
m_layerTreeHost->setImplTransform(WebTransformationMatrix()); m_layerTreeHost->setImplTransform(gfx::Transform());
transformedPoint = gfx::ToRoundedPoint(m_layerTreeHost->adjustEventPointForPinchZoom(point)); transformedPoint = gfx::ToRoundedPoint(m_layerTreeHost->adjustEventPointForPinchZoom(point));
EXPECT_EQ(point.x(), transformedPoint.x()); EXPECT_EQ(point.x(), transformedPoint.x());
EXPECT_EQ(point.y(), transformedPoint.y()); EXPECT_EQ(point.y(), transformedPoint.y());

@ -8,16 +8,16 @@
#include "cc/layer_impl.h" #include "cc/layer_impl.h"
#include "cc/layer_painter.h" #include "cc/layer_painter.h"
#include "cc/layer_tree_host.h" #include "cc/layer_tree_host.h"
#include "cc/math_util.h"
#include "cc/single_thread_proxy.h" #include "cc/single_thread_proxy.h"
#include "cc/thread.h" #include "cc/thread.h"
#include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/geometry_test_utils.h" #include "cc/test/geometry_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using namespace WebKitTests; using namespace WebKitTests;
using WebKit::WebTransformationMatrix;
using ::testing::Mock; using ::testing::Mock;
using ::testing::_; using ::testing::_;
using ::testing::AtLeast; 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->setUseLCDText(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5)); 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->setRenderTarget(0));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(WebTransformationMatrix())); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(gfx::Transform()));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(WebTransformationMatrix())); 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))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableContentRect(gfx::Rect(4, 5, 6, 7)));
EXPECT_FALSE(testLayer->needsDisplay()); 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->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->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->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->setScrollable(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOnMainThread(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->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->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->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->setDoubleSided(false));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer")); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer"));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDrawCheckerboardForMissingTiles(!testLayer->drawCheckerboardForMissingTiles())); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDrawCheckerboardForMissingTiles(!testLayer->drawCheckerboardForMissingTiles()));

@ -11,10 +11,8 @@
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include "ui/gfx/transform.h"
#include "ui/gfx/vector2d_f.h" #include "ui/gfx/vector2d_f.h"
#include <public/WebTransformationMatrix.h>
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
@ -22,39 +20,39 @@ const double MathUtil::PI_DOUBLE = 3.14159265358979323846;
const float MathUtil::PI_FLOAT = 3.14159265358979323846f; const float MathUtil::PI_FLOAT = 3.14159265358979323846f;
const double MathUtil::EPSILON = 1e-9; 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 // 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 // (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 // 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. // 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); return HomogeneousCoordinate(0, 0, 0, 1);
double x = p.x(); double x = p.x();
double y = p.y(); 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; // implicit definition of w = 1;
double outX = x * transform.m11() + y * transform.m21() + z * transform.m31() + transform.m41(); 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.m12() + y * transform.m22() + z * transform.m32() + transform.m42(); 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.m13() + y * transform.m23() + z * transform.m33() + transform.m43(); 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.m14() + y * transform.m24() + z * transform.m34() + transform.m44(); 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); 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 x = p.x();
double y = p.y(); double y = p.y();
double z = p.z(); double z = p.z();
// implicit definition of w = 1; // implicit definition of w = 1;
double outX = x * transform.m11() + y * transform.m21() + z * transform.m31() + transform.m41(); 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.m12() + y * transform.m22() + z * transform.m32() + transform.m42(); 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.m13() + y * transform.m23() + z * transform.m33() + transform.m43(); 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.m14() + y * transform.m24() + z * transform.m34() + transform.m44(); 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); return HomogeneousCoordinate(outX, outY, outZ, outW);
} }
@ -102,15 +100,15 @@ static inline void addVertexToClippedQuad(const gfx::PointF& newVertex, gfx::Poi
numVerticesInClippedQuad++; 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))); 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()) if (MathUtil::isIdentityOrTranslation(transform))
return srcRect + gfx::Vector2dF(static_cast<float>(transform.m41()), static_cast<float>(transform.m42())); 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. // Apply the transform, but retain the result in homogeneous coordinates.
gfx::QuadF q = gfx::QuadF(srcRect); gfx::QuadF q = gfx::QuadF(srcRect);
@ -122,10 +120,10 @@ gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, co
return computeEnclosingClippedRect(h1, h2, h3, h4); 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()) if (MathUtil::isIdentityOrTranslation(transform))
return srcRect + gfx::Vector2dF(static_cast<float>(transform.m41()), static_cast<float>(transform.m42())); 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. // Perform the projection, but retain the result in homogeneous coordinates.
gfx::QuadF q = gfx::QuadF(srcRect); gfx::QuadF q = gfx::QuadF(srcRect);
@ -137,7 +135,7 @@ gfx::RectF MathUtil::projectClippedRect(const WebTransformationMatrix& transform
return computeEnclosingClippedRect(h1, h2, h3, h4); 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 h1 = mapHomogeneousPoint(transform, gfx::Point3F(srcQuad.p1()));
HomogeneousCoordinate h2 = mapHomogeneousPoint(transform, gfx::Point3F(srcQuad.p2())); 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)); 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); 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; clipped = false;
return mappedQuad; 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()); 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)); HomogeneousCoordinate h = mapHomogeneousPoint(transform, gfx::Point3F(p));
@ -284,7 +282,7 @@ gfx::PointF MathUtil::mapPoint(const WebTransformationMatrix& transform, const g
return h.cartesianPoint2d(); 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); HomogeneousCoordinate h = mapHomogeneousPoint(transform, p);
@ -307,7 +305,7 @@ gfx::Point3F MathUtil::mapPoint(const WebTransformationMatrix& transform, const
return h.cartesianPoint3d(); 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; gfx::QuadF projectedQuad;
bool clippedPoint; bool clippedPoint;
@ -323,7 +321,7 @@ gfx::QuadF MathUtil::projectQuad(const WebTransformationMatrix& transform, const
return projectedQuad; 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); HomogeneousCoordinate h = projectHomogeneousPoint(transform, p);
@ -347,7 +345,7 @@ gfx::PointF MathUtil::projectPoint(const WebTransformationMatrix& transform, con
return h.cartesianPoint2d(); 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). // 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 // - Because of linearity of transforms, this flattened transform also preserves the
// effect that any subsequent (post-multiplied) transforms would have on z values. // effect that any subsequent (post-multiplied) transforms would have on z values.
// //
transform.setM13(0); transform.matrix().setDouble(2, 0, 0);
transform.setM23(0); transform.matrix().setDouble(2, 1, 0);
transform.setM31(0); transform.matrix().setDouble(0, 2, 0);
transform.setM32(0); transform.matrix().setDouble(1, 2, 0);
transform.setM33(1); transform.matrix().setDouble(2, 2, 1);
transform.setM34(0); transform.matrix().setDouble(3, 2, 0);
transform.setM43(0); transform.matrix().setDouble(2, 3, 0);
} }
static inline float scaleOnAxis(double a, double b, double c) 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); 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); return gfx::Vector2dF(1, 1);
float xScale = scaleOnAxis(transform.m11(), transform.m12(), transform.m13()); float xScale = scaleOnAxis(transform.matrix().getDouble(0, 0), transform.matrix().getDouble(1, 0), transform.matrix().getDouble(2, 0));
float yScale = scaleOnAxis(transform.m21(), transform.m22(), transform.m23()); float yScale = scaleOnAxis(transform.matrix().getDouble(0, 1), transform.matrix().getDouble(1, 1), transform.matrix().getDouble(2, 1));
return gfx::Vector2dF(xScale, yScale); 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()); 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(); // Compute whether a layer with a forward-facing normal of (0, 0, 1) would
double determinant = matrix.determinant(); // have its back face visible after applying the transform.
return abs(determinant) > EPSILON; //
} // 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) make this perform more efficiently - we do not
{ // actually need to instantiate/invert/transpose any matrices, exploiting the
// TODO (shawnsingh): to be implemented in a follow up patch very soon. // fact that we only need to transform (0, 0, 1, 0).
NOTREACHED(); gfx::Transform inverseTransform = MathUtil::inverse(transform);
return false; const SkMatrix44& mInv = inverseTransform.matrix();
}
bool MathUtil::isIdentity(const gfx::Transform& transform) return mInv.getDouble(2, 2) < 0;
{
return transform.matrix().isIdentity();
} }
bool MathUtil::isIdentityOrTranslation(const gfx::Transform& transform) 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); 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) void MathUtil::rotateEulerAngles(gfx::Transform* transform, double eulerX, double eulerY, double eulerZ)
{ {
// TODO (shawnsingh): make this implementation faster and more accurate by // TODO (shawnsingh): make this implementation faster and more accurate by

@ -11,14 +11,11 @@
#include "ui/gfx/point3_f.h" #include "ui/gfx/point3_f.h"
#include "ui/gfx/transform.h" #include "ui/gfx/transform.h"
namespace WebKit {
class WebTransformationMatrix;
}
namespace gfx { namespace gfx {
class QuadF; class QuadF;
class Rect; class Rect;
class RectF; class RectF;
class Transform;
class Vector2dF; class Vector2dF;
} }
@ -78,7 +75,7 @@ public:
static float Deg2Rad(float deg) { return deg * PI_FLOAT / 180; } static float Deg2Rad(float deg) { return deg * PI_FLOAT / 180; }
static float Rad2Deg(float rad) { return rad * 180 / PI_FLOAT; } 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 // 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 // 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 // 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, // These functions return the axis-aligned rect that encloses the correctly clipped,
// transformed polygon. // transformed polygon.
static gfx::Rect mapClippedRect(const WebKit::WebTransformationMatrix&, const gfx::Rect&); static gfx::Rect mapClippedRect(const gfx::Transform&, const gfx::Rect&);
static gfx::RectF mapClippedRect(const WebKit::WebTransformationMatrix&, const gfx::RectF&); static gfx::RectF mapClippedRect(const gfx::Transform&, const gfx::RectF&);
static gfx::RectF projectClippedRect(const WebKit::WebTransformationMatrix&, 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 // 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 // 0 to numVerticesInClippedQuad are valid in the clippedQuad array. Note that
// numVerticesInClippedQuad may be zero, which means the entire quad was clipped, and // numVerticesInClippedQuad may be zero, which means the entire quad was clipped, and
// none of the vertices in the array are valid. // 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 computeEnclosingRectOfVertices(gfx::PointF vertices[], int numVertices);
static gfx::RectF computeEnclosingClippedRect(const HomogeneousCoordinate& h1, const HomogeneousCoordinate& h2, const HomogeneousCoordinate& h3, const HomogeneousCoordinate& h4); 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 // NOTE: These functions do not do correct clipping against w = 0 plane, but they
// correctly detect the clipped condition via the boolean clipped. // correctly detect the clipped condition via the boolean clipped.
static gfx::QuadF mapQuad(const WebKit::WebTransformationMatrix&, const gfx::QuadF&, bool& clipped); static gfx::QuadF mapQuad(const gfx::Transform&, const gfx::QuadF&, bool& clipped);
static gfx::PointF mapPoint(const WebKit::WebTransformationMatrix&, const gfx::PointF&, bool& clipped); static gfx::PointF mapPoint(const gfx::Transform&, const gfx::PointF&, bool& clipped);
static gfx::Point3F mapPoint(const WebKit::WebTransformationMatrix&, const gfx::Point3F&, bool& clipped); static gfx::Point3F mapPoint(const gfx::Transform&, const gfx::Point3F&, bool& clipped);
static gfx::QuadF projectQuad(const WebKit::WebTransformationMatrix&, const gfx::QuadF&, bool& clipped); static gfx::QuadF projectQuad(const gfx::Transform&, const gfx::QuadF&, bool& clipped);
static gfx::PointF projectPoint(const WebKit::WebTransformationMatrix&, const gfx::PointF&, 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 // Returns the smallest angle between the given two vectors in degrees. Neither vector is
// assumed to be normalized. // assumed to be normalized.
@ -118,17 +115,14 @@ public:
// Projects the |source| vector onto |destination|. Neither vector is assumed to be normalized. // Projects the |source| vector onto |destination|. Neither vector is assumed to be normalized.
static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF destination); 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. // to gfx::Transform.
// //
// TODO(shawnsingh, vollick) we should phase out as much as possible of // TODO(shawnsingh, vollick) we should phase out as much as possible of
// these temporary functions, putting functionality into gfx::Transform. // these temporary functions, putting functionality into gfx::Transform.
static bool isInvertible(const gfx::Transform&);
static bool isBackFaceVisible(const gfx::Transform&); static bool isBackFaceVisible(const gfx::Transform&);
static bool isIdentity(const gfx::Transform&);
static bool isIdentityOrTranslation(const gfx::Transform&); static bool isIdentityOrTranslation(const gfx::Transform&);
static bool hasPerspective(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 rotateEulerAngles(gfx::Transform*, double eulerX, double eulerY, double eulerZ);
static void rotateAxisAngle(gfx::Transform*, double i, double j, double k, double degrees); static void rotateAxisAngle(gfx::Transform*, double i, double j, double k, double degrees);
static gfx::Transform inverse(const gfx::Transform&); static gfx::Transform inverse(const gfx::Transform&);

@ -11,37 +11,35 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
namespace { namespace {
TEST(MathUtilTest, verifyBackfaceVisibilityBasicCases) TEST(MathUtilTest, verifyBackfaceVisibilityBasicCases)
{ {
WebTransformationMatrix transform; gfx::Transform transform;
transform.makeIdentity(); transform.MakeIdentity();
EXPECT_FALSE(transform.isBackFaceVisible()); EXPECT_FALSE(MathUtil::isBackFaceVisible(transform));
transform.makeIdentity(); transform.MakeIdentity();
transform.rotate3d(0, 80, 0); MathUtil::rotateEulerAngles(&transform, 0, 80, 0);
EXPECT_FALSE(transform.isBackFaceVisible()); EXPECT_FALSE(MathUtil::isBackFaceVisible(transform));
transform.makeIdentity(); transform.MakeIdentity();
transform.rotate3d(0, 100, 0); MathUtil::rotateEulerAngles(&transform, 0, 100, 0);
EXPECT_TRUE(transform.isBackFaceVisible()); EXPECT_TRUE(MathUtil::isBackFaceVisible(transform));
// Edge case, 90 degree rotation should return false. // Edge case, 90 degree rotation should return false.
transform.makeIdentity(); transform.MakeIdentity();
transform.rotate3d(0, 90, 0); MathUtil::rotateEulerAngles(&transform, 0, 90, 0);
EXPECT_FALSE(transform.isBackFaceVisible()); EXPECT_FALSE(MathUtil::isBackFaceVisible(transform));
} }
TEST(MathUtilTest, verifyBackfaceVisibilityForPerspective) TEST(MathUtilTest, verifyBackfaceVisibilityForPerspective)
{ {
WebTransformationMatrix layerSpaceToProjectionPlane; gfx::Transform layerSpaceToProjectionPlane;
// This tests if isBackFaceVisible works properly under perspective transforms. // This tests if isBackFaceVisible works properly under perspective transforms.
// Specifically, layers that may have their back face visible in orthographic // 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 // 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 // prespective projection. In this case, the layer's back-side is visible to
// the camera. // the camera.
layerSpaceToProjectionPlane.makeIdentity(); layerSpaceToProjectionPlane.MakeIdentity();
layerSpaceToProjectionPlane.applyPerspective(1); layerSpaceToProjectionPlane.ApplyPerspectiveDepth(1);
layerSpaceToProjectionPlane.translate3d(0, 0, 0); layerSpaceToProjectionPlane.Translate3d(0, 0, 0);
layerSpaceToProjectionPlane.rotate3d(0, 100, 0); MathUtil::rotateEulerAngles(&layerSpaceToProjectionPlane, 0, 100, 0);
EXPECT_TRUE(layerSpaceToProjectionPlane.isBackFaceVisible()); EXPECT_TRUE(MathUtil::isBackFaceVisible(layerSpaceToProjectionPlane));
// Case 2: Layer is rotated by slightly more than 90 degrees, but shifted off to the // 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 // 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 -->| \ / // back side of layer -->| \ /
// \./ <-- camera origin // \./ <-- camera origin
// //
layerSpaceToProjectionPlane.makeIdentity(); layerSpaceToProjectionPlane.MakeIdentity();
layerSpaceToProjectionPlane.applyPerspective(1); layerSpaceToProjectionPlane.ApplyPerspectiveDepth(1);
layerSpaceToProjectionPlane.translate3d(-10, 0, 0); layerSpaceToProjectionPlane.Translate3d(-10, 0, 0);
layerSpaceToProjectionPlane.rotate3d(0, 100, 0); MathUtil::rotateEulerAngles(&layerSpaceToProjectionPlane, 0, 100, 0);
EXPECT_FALSE(layerSpaceToProjectionPlane.isBackFaceVisible()); EXPECT_FALSE(MathUtil::isBackFaceVisible(layerSpaceToProjectionPlane));
// Case 3: Additionally rotating the layer by 180 degrees should of course show the // Case 3: Additionally rotating the layer by 180 degrees should of course show the
// opposite result of case 2. // opposite result of case 2.
layerSpaceToProjectionPlane.rotate3d(0, 180, 0); MathUtil::rotateEulerAngles(&layerSpaceToProjectionPlane, 0, 180, 0);
EXPECT_TRUE(layerSpaceToProjectionPlane.isBackFaceVisible()); EXPECT_TRUE(MathUtil::isBackFaceVisible(layerSpaceToProjectionPlane));
} }
TEST(MathUtilTest, verifyProjectionOfPerpendicularPlane) 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 // In this case, the m33() element of the transform becomes zero, which could cause a
// divide-by-zero when projecting points/quads. // divide-by-zero when projecting points/quads.
WebTransformationMatrix transform; gfx::Transform transform;
transform.makeIdentity(); transform.MakeIdentity();
transform.setM33(0); transform.matrix().setDouble(2, 2, 0);
gfx::RectF rect = gfx::RectF(0, 0, 1, 1); gfx::RectF rect = gfx::RectF(0, 0, 1, 1);
gfx::RectF projectedRect = MathUtil::projectClippedRect(transform, rect); gfx::RectF projectedRect = MathUtil::projectClippedRect(transform, rect);
@ -293,7 +291,7 @@ TEST(MathUtilGfxTransformTest, verifyDefaultConstructorCreatesIdentityMatrix)
EXPECT_ROW2_EQ(0, 1, 0, 0, A); EXPECT_ROW2_EQ(0, 1, 0, 0, A);
EXPECT_ROW3_EQ(0, 0, 1, 0, A); EXPECT_ROW3_EQ(0, 0, 1, 0, A);
EXPECT_ROW4_EQ(0, 0, 0, 1, A); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
EXPECT_TRUE(MathUtil::isIdentity(A)); EXPECT_TRUE(A.IsIdentity());
} }
TEST(MathUtilGfxTransformTest, verifyCreateGfxTransformFor2dElements) TEST(MathUtilGfxTransformTest, verifyCreateGfxTransformFor2dElements)
@ -332,7 +330,7 @@ TEST(MathUtilGfxTransformTest, verifyMatrixInversion)
// Invert a translation // Invert a translation
gfx::Transform translation; gfx::Transform translation;
translation.Translate3d(2, 3, 4); translation.Translate3d(2, 3, 4);
EXPECT_TRUE(MathUtil::isInvertible(translation)); EXPECT_TRUE(translation.IsInvertible());
gfx::Transform inverseTranslation = MathUtil::inverse(translation); gfx::Transform inverseTranslation = MathUtil::inverse(translation);
EXPECT_ROW1_EQ(1, 0, 0, -2, inverseTranslation); EXPECT_ROW1_EQ(1, 0, 0, -2, inverseTranslation);
@ -349,7 +347,7 @@ TEST(MathUtilGfxTransformTest, verifyMatrixInversion)
// Invert a non-uniform scale // Invert a non-uniform scale
gfx::Transform scale; gfx::Transform scale;
scale.Scale3d(4, 10, 100); scale.Scale3d(4, 10, 100);
EXPECT_TRUE(MathUtil::isInvertible(scale)); EXPECT_TRUE(scale.IsInvertible());
gfx::Transform inverseScale = MathUtil::inverse(scale); gfx::Transform inverseScale = MathUtil::inverse(scale);
EXPECT_ROW1_EQ(0.25, 0, 0, 0, inverseScale); 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(1, 1, 0);
notInvertible.matrix().setDouble(2, 2, 0); notInvertible.matrix().setDouble(2, 2, 0);
notInvertible.matrix().setDouble(3, 3, 0); notInvertible.matrix().setDouble(3, 3, 0);
EXPECT_FALSE(MathUtil::isInvertible(notInvertible)); EXPECT_FALSE(notInvertible.IsInvertible());
gfx::Transform inverseOfNotInvertible; gfx::Transform inverseOfNotInvertible;
initializeTestMatrix(&inverseOfNotInvertible); // initialize this to something non-identity, to make sure that assignment below actually took place. initializeTestMatrix(&inverseOfNotInvertible); // initialize this to something non-identity, to make sure that assignment below actually took place.
inverseOfNotInvertible = MathUtil::inverse(notInvertible); inverseOfNotInvertible = MathUtil::inverse(notInvertible);
EXPECT_TRUE(MathUtil::isIdentity(inverseOfNotInvertible)); EXPECT_TRUE(inverseOfNotInvertible.IsIdentity());
} }
TEST(MathUtilGfxTransformTest, verifyTo2DTransform) TEST(MathUtilGfxTransformTest, verifyTo2DTransform)
@ -553,12 +551,12 @@ TEST(MathUtilGfxTransformTest, verifyMakeIdentiy)
{ {
gfx::Transform A; gfx::Transform A;
initializeTestMatrix(&A); initializeTestMatrix(&A);
MathUtil::makeIdentity(&A); A.MakeIdentity();
EXPECT_ROW1_EQ(1, 0, 0, 0, A); EXPECT_ROW1_EQ(1, 0, 0, 0, A);
EXPECT_ROW2_EQ(0, 1, 0, 0, A); EXPECT_ROW2_EQ(0, 1, 0, 0, A);
EXPECT_ROW3_EQ(0, 0, 1, 0, A); EXPECT_ROW3_EQ(0, 0, 1, 0, A);
EXPECT_ROW4_EQ(0, 0, 0, 1, A); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
EXPECT_TRUE(MathUtil::isIdentity(A)); EXPECT_TRUE(A.IsIdentity());
} }
TEST(MathUtilGfxTransformTest, verifyTranslate) TEST(MathUtilGfxTransformTest, verifyTranslate)
@ -571,7 +569,7 @@ TEST(MathUtilGfxTransformTest, verifyTranslate)
EXPECT_ROW4_EQ(0, 0, 0, 1, A); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that Translate() post-multiplies the existing matrix. // Verify that Translate() post-multiplies the existing matrix.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Scale(5, 5); A.Scale(5, 5);
A.Translate(2, 3); A.Translate(2, 3);
EXPECT_ROW1_EQ(5, 0, 0, 10, A); EXPECT_ROW1_EQ(5, 0, 0, 10, A);
@ -590,7 +588,7 @@ TEST(MathUtilGfxTransformTest, verifyTranslate3d)
EXPECT_ROW4_EQ(0, 0, 0, 1, A); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that Translate3d() post-multiplies the existing matrix. // Verify that Translate3d() post-multiplies the existing matrix.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Scale3d(6, 7, 8); A.Scale3d(6, 7, 8);
A.Translate3d(2, 3, 4); A.Translate3d(2, 3, 4);
EXPECT_ROW1_EQ(6, 0, 0, 12, A); EXPECT_ROW1_EQ(6, 0, 0, 12, A);
@ -609,7 +607,7 @@ TEST(MathUtilGfxTransformTest, verifyScale)
EXPECT_ROW4_EQ(0, 0, 0, 1, A); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that Scale() post-multiplies the existing matrix. // Verify that Scale() post-multiplies the existing matrix.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Translate3d(2, 3, 4); A.Translate3d(2, 3, 4);
A.Scale(6, 7); A.Scale(6, 7);
EXPECT_ROW1_EQ(6, 0, 0, 2, A); EXPECT_ROW1_EQ(6, 0, 0, 2, A);
@ -628,7 +626,7 @@ TEST(MathUtilGfxTransformTest, verifyScale3d)
EXPECT_ROW4_EQ(0, 0, 0, 1, A); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that scale3d() post-multiplies the existing matrix. // Verify that scale3d() post-multiplies the existing matrix.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Translate3d(2, 3, 4); A.Translate3d(2, 3, 4);
A.Scale3d(6, 7, 8); A.Scale3d(6, 7, 8);
EXPECT_ROW1_EQ(6, 0, 0, 2, A); EXPECT_ROW1_EQ(6, 0, 0, 2, A);
@ -647,7 +645,7 @@ TEST(MathUtilGfxTransformTest, verifyRotate)
EXPECT_ROW4_EQ(0, 0, 0, 1, A); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that Rotate() post-multiplies the existing matrix. // Verify that Rotate() post-multiplies the existing matrix.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Scale3d(6, 7, 8); A.Scale3d(6, 7, 8);
A.Rotate(90); A.Rotate(90);
EXPECT_ROW1_NEAR(0, -6, 0, 0, A, ERROR_THRESHOLD); EXPECT_ROW1_NEAR(0, -6, 0, 0, A, ERROR_THRESHOLD);
@ -661,7 +659,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateEulerAngles)
gfx::Transform A; gfx::Transform A;
// Check rotation about z-axis // Check rotation about z-axis
MathUtil::makeIdentity(&A); A.MakeIdentity();
MathUtil::rotateEulerAngles(&A, 0, 0, 90); MathUtil::rotateEulerAngles(&A, 0, 0, 90);
EXPECT_ROW1_NEAR(0, -1, 0, 0, A, ERROR_THRESHOLD); EXPECT_ROW1_NEAR(0, -1, 0, 0, A, ERROR_THRESHOLD);
EXPECT_ROW2_NEAR(1, 0, 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); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Check rotation about x-axis // Check rotation about x-axis
MathUtil::makeIdentity(&A); A.MakeIdentity();
MathUtil::rotateEulerAngles(&A, 90, 0, 0); MathUtil::rotateEulerAngles(&A, 90, 0, 0);
EXPECT_ROW1_EQ(1, 0, 0, 0, A); EXPECT_ROW1_EQ(1, 0, 0, 0, A);
EXPECT_ROW2_NEAR(0, 0, -1, 0, A, ERROR_THRESHOLD); EXPECT_ROW2_NEAR(0, 0, -1, 0, A, ERROR_THRESHOLD);
@ -678,7 +676,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateEulerAngles)
// Check rotation about y-axis. // Check rotation about y-axis.
// Note carefully, the expected pattern is inverted compared to rotating about x axis or z 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); MathUtil::rotateEulerAngles(&A, 0, 90, 0);
EXPECT_ROW1_NEAR(0, 0, 1, 0, A, ERROR_THRESHOLD); EXPECT_ROW1_NEAR(0, 0, 1, 0, A, ERROR_THRESHOLD);
EXPECT_ROW2_EQ(0, 1, 0, 0, A); EXPECT_ROW2_EQ(0, 1, 0, 0, A);
@ -686,7 +684,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateEulerAngles)
EXPECT_ROW4_EQ(0, 0, 0, 1, A); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that rotate3d(rx, ry, rz) post-multiplies the existing matrix. // Verify that rotate3d(rx, ry, rz) post-multiplies the existing matrix.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Scale3d(6, 7, 8); A.Scale3d(6, 7, 8);
MathUtil::rotateEulerAngles(&A, 0, 0, 90); MathUtil::rotateEulerAngles(&A, 0, 0, 90);
EXPECT_ROW1_NEAR(0, -6, 0, 0, A, ERROR_THRESHOLD); 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. // from the other orderings. That way, this test verifies the exact ordering.
gfx::Transform A; gfx::Transform A;
MathUtil::makeIdentity(&A); A.MakeIdentity();
MathUtil::rotateEulerAngles(&A, 10, 20, 30); MathUtil::rotateEulerAngles(&A, 10, 20, 30);
EXPECT_ROW1_NEAR(0.8137976813493738026394908, EXPECT_ROW1_NEAR(0.8137976813493738026394908,
@ -734,7 +732,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateAxisAngleForAlignedAxes)
gfx::Transform A; gfx::Transform A;
// Check rotation about z-axis // Check rotation about z-axis
MathUtil::makeIdentity(&A); A.MakeIdentity();
MathUtil::rotateAxisAngle(&A, 0, 0, 1, 90); MathUtil::rotateAxisAngle(&A, 0, 0, 1, 90);
EXPECT_ROW1_NEAR(0, -1, 0, 0, A, ERROR_THRESHOLD); EXPECT_ROW1_NEAR(0, -1, 0, 0, A, ERROR_THRESHOLD);
EXPECT_ROW2_NEAR(1, 0, 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); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Check rotation about x-axis // Check rotation about x-axis
MathUtil::makeIdentity(&A); A.MakeIdentity();
MathUtil::rotateAxisAngle(&A, 1, 0, 0, 90); MathUtil::rotateAxisAngle(&A, 1, 0, 0, 90);
EXPECT_ROW1_EQ(1, 0, 0, 0, A); EXPECT_ROW1_EQ(1, 0, 0, 0, A);
EXPECT_ROW2_NEAR(0, 0, -1, 0, A, ERROR_THRESHOLD); EXPECT_ROW2_NEAR(0, 0, -1, 0, A, ERROR_THRESHOLD);
@ -751,7 +749,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateAxisAngleForAlignedAxes)
// Check rotation about y-axis. // Check rotation about y-axis.
// Note carefully, the expected pattern is inverted compared to rotating about x axis or z 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); MathUtil::rotateAxisAngle(&A, 0, 1, 0, 90);
EXPECT_ROW1_NEAR(0, 0, 1, 0, A, ERROR_THRESHOLD); EXPECT_ROW1_NEAR(0, 0, 1, 0, A, ERROR_THRESHOLD);
EXPECT_ROW2_EQ(0, 1, 0, 0, A); EXPECT_ROW2_EQ(0, 1, 0, 0, A);
@ -759,7 +757,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateAxisAngleForAlignedAxes)
EXPECT_ROW4_EQ(0, 0, 0, 1, A); EXPECT_ROW4_EQ(0, 0, 0, 1, A);
// Verify that rotate3d(axis, angle) post-multiplies the existing matrix. // Verify that rotate3d(axis, angle) post-multiplies the existing matrix.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Scale3d(6, 7, 8); A.Scale3d(6, 7, 8);
MathUtil::rotateAxisAngle(&A, 0, 0, 1, 90); MathUtil::rotateAxisAngle(&A, 0, 0, 1, 90);
EXPECT_ROW1_NEAR(0, -6, 0, 0, A, ERROR_THRESHOLD); EXPECT_ROW1_NEAR(0, -6, 0, 0, A, ERROR_THRESHOLD);
@ -796,7 +794,7 @@ TEST(MathUtilGfxTransformTest, verifyRotateAxisAngleForDegenerateAxis)
MathUtil::rotateAxisAngle(&A, 0, 0, 0, 45); MathUtil::rotateAxisAngle(&A, 0, 0, 0, 45);
// Verify that A remains unchanged. // Verify that A remains unchanged.
EXPECT_TRUE(MathUtil::isIdentity(A)); EXPECT_TRUE(A.IsIdentity());
initializeTestMatrix(&A); initializeTestMatrix(&A);
MathUtil::rotateAxisAngle(&A, 0, 0, 0, 35); MathUtil::rotateAxisAngle(&A, 0, 0, 0, 35);
@ -819,7 +817,7 @@ TEST(MathUtilGfxTransformTest, verifySkewX)
// Verify that skewX() post-multiplies the existing matrix. // 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. // 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.Scale3d(6, 7, 8);
A.SkewX(45); A.SkewX(45);
EXPECT_ROW1_EQ(6, 6, 0, 0, A); EXPECT_ROW1_EQ(6, 6, 0, 0, A);
@ -839,7 +837,7 @@ TEST(MathUtilGfxTransformTest, verifySkewY)
// Verify that skewY() post-multiplies the existing matrix. // 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. // 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.Scale3d(6, 7, 8);
A.SkewY(45); A.SkewY(45);
EXPECT_ROW1_EQ(6, 0, 0, 0, A); EXPECT_ROW1_EQ(6, 0, 0, 0, A);
@ -858,7 +856,7 @@ TEST(MathUtilGfxTransformTest, verifyPerspectiveDepth)
EXPECT_ROW4_EQ(0, 0, -1, 1, A); EXPECT_ROW4_EQ(0, 0, -1, 1, A);
// Verify that PerspectiveDepth() post-multiplies the existing matrix. // Verify that PerspectiveDepth() post-multiplies the existing matrix.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Translate3d(2, 3, 4); A.Translate3d(2, 3, 4);
A.ApplyPerspectiveDepth(1); A.ApplyPerspectiveDepth(1);
EXPECT_ROW1_EQ(1, 0, -2, 2, A); EXPECT_ROW1_EQ(1, 0, -2, 2, A);
@ -873,27 +871,27 @@ TEST(MathUtilGfxTransformTest, verifyHasPerspective)
A.ApplyPerspectiveDepth(1); A.ApplyPerspectiveDepth(1);
EXPECT_TRUE(MathUtil::hasPerspective(A)); EXPECT_TRUE(MathUtil::hasPerspective(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.ApplyPerspectiveDepth(0); A.ApplyPerspectiveDepth(0);
EXPECT_FALSE(MathUtil::hasPerspective(A)); EXPECT_FALSE(MathUtil::hasPerspective(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(3, 0, -1); A.matrix().setDouble(3, 0, -1);
EXPECT_TRUE(MathUtil::hasPerspective(A)); EXPECT_TRUE(MathUtil::hasPerspective(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(3, 1, -1); A.matrix().setDouble(3, 1, -1);
EXPECT_TRUE(MathUtil::hasPerspective(A)); EXPECT_TRUE(MathUtil::hasPerspective(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(3, 2, -0.3); A.matrix().setDouble(3, 2, -0.3);
EXPECT_TRUE(MathUtil::hasPerspective(A)); EXPECT_TRUE(MathUtil::hasPerspective(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(3, 3, 0.5); A.matrix().setDouble(3, 3, 0.5);
EXPECT_TRUE(MathUtil::hasPerspective(A)); EXPECT_TRUE(MathUtil::hasPerspective(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(3, 3, 0); A.matrix().setDouble(3, 3, 0);
EXPECT_TRUE(MathUtil::hasPerspective(A)); EXPECT_TRUE(MathUtil::hasPerspective(A));
} }
@ -903,55 +901,55 @@ TEST(MathUtilGfxTransformTest, verifyIsInvertible)
gfx::Transform A; gfx::Transform A;
// Translations, rotations, scales, skews and arbitrary combinations of them are invertible. // Translations, rotations, scales, skews and arbitrary combinations of them are invertible.
MathUtil::makeIdentity(&A); A.MakeIdentity();
EXPECT_TRUE(MathUtil::isInvertible(A)); EXPECT_TRUE(A.IsInvertible());
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Translate3d(2, 3, 4); A.Translate3d(2, 3, 4);
EXPECT_TRUE(MathUtil::isInvertible(A)); EXPECT_TRUE(A.IsInvertible());
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.Scale3d(6, 7, 8); 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); MathUtil::rotateEulerAngles(&A, 10, 20, 30);
EXPECT_TRUE(MathUtil::isInvertible(A)); EXPECT_TRUE(A.IsInvertible());
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.SkewX(45); A.SkewX(45);
EXPECT_TRUE(MathUtil::isInvertible(A)); EXPECT_TRUE(A.IsInvertible());
// A perspective matrix (projection plane at z=0) is invertible. The intuitive // 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 // explanation is that perspective is eqivalent to a skew of the w-axis; skews are
// invertible. // invertible.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.ApplyPerspectiveDepth(1); 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 // A "pure" perspective matrix derived by similar triangles, with m44() set to zero
// (i.e. camera positioned at the origin), is not invertible. // (i.e. camera positioned at the origin), is not invertible.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.ApplyPerspectiveDepth(1); A.ApplyPerspectiveDepth(1);
A.matrix().setDouble(3, 3, 0); 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. // 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.ApplyPerspectiveDepth(1);
A.matrix().setDouble(3, 3, 0); A.matrix().setDouble(3, 3, 0);
A.Scale3d(6, 7, 8); A.Scale3d(6, 7, 8);
MathUtil::rotateEulerAngles(&A, 10, 20, 30); MathUtil::rotateEulerAngles(&A, 10, 20, 30);
A.Translate3d(6, 7, 8); A.Translate3d(6, 7, 8);
EXPECT_FALSE(MathUtil::isInvertible(A)); EXPECT_FALSE(A.IsInvertible());
// A degenerate matrix of all zeros is not invertible. // A degenerate matrix of all zeros is not invertible.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(0, 0, 0); A.matrix().setDouble(0, 0, 0);
A.matrix().setDouble(1, 1, 0); A.matrix().setDouble(1, 1, 0);
A.matrix().setDouble(2, 2, 0); A.matrix().setDouble(2, 2, 0);
A.matrix().setDouble(3, 3, 0); A.matrix().setDouble(3, 3, 0);
EXPECT_FALSE(MathUtil::isInvertible(A)); EXPECT_FALSE(A.IsInvertible());
} }
TEST(MathUtilGfxTransformTest, verifyIsIdentity) TEST(MathUtilGfxTransformTest, verifyIsIdentity)
@ -959,75 +957,75 @@ TEST(MathUtilGfxTransformTest, verifyIsIdentity)
gfx::Transform A; gfx::Transform A;
initializeTestMatrix(&A); initializeTestMatrix(&A);
EXPECT_FALSE(MathUtil::isIdentity(A)); EXPECT_FALSE(A.IsIdentity());
MathUtil::makeIdentity(&A); A.MakeIdentity();
EXPECT_TRUE(MathUtil::isIdentity(A)); EXPECT_TRUE(A.IsIdentity());
// Modifying any one individual element should cause the matrix to no longer be identity. // 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); A.matrix().setDouble(3, 3, 2);
EXPECT_FALSE(MathUtil::isIdentity(A)); EXPECT_FALSE(A.IsIdentity());
} }
TEST(MathUtilGfxTransformTest, verifyIsIdentityOrTranslation) TEST(MathUtilGfxTransformTest, verifyIsIdentityOrTranslation)
@ -1037,76 +1035,76 @@ TEST(MathUtilGfxTransformTest, verifyIsIdentityOrTranslation)
initializeTestMatrix(&A); initializeTestMatrix(&A);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A)); EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A));
// Modifying any non-translation components should cause isIdentityOrTranslation() to // Modifying any non-translation components should cause isIdentityOrTranslation() to
// return false. NOTE: (0, 3), (1, 3), and (2, 3) are the translation components, so // return false. NOTE: (0, 3), (1, 3), and (2, 3) are the translation components, so
// modifying them should still return true for isIdentityOrTranslation(). // modifying them should still return true for isIdentityOrTranslation().
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(0, 0, 2); A.matrix().setDouble(0, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(1, 0, 2); A.matrix().setDouble(1, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(2, 0, 2); A.matrix().setDouble(2, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(3, 0, 2); A.matrix().setDouble(3, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(0, 0, 2); A.matrix().setDouble(0, 0, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(1, 1, 2); A.matrix().setDouble(1, 1, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(2, 1, 2); A.matrix().setDouble(2, 1, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(3, 1, 2); A.matrix().setDouble(3, 1, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(0, 2, 2); A.matrix().setDouble(0, 2, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(1, 2, 2); A.matrix().setDouble(1, 2, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(2, 2, 2); A.matrix().setDouble(2, 2, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(3, 2, 2); A.matrix().setDouble(3, 2, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
// Note carefully - expecting true here. // Note carefully - expecting true here.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(0, 3, 2); A.matrix().setDouble(0, 3, 2);
EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A)); EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A));
// Note carefully - expecting true here. // Note carefully - expecting true here.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(1, 3, 2); A.matrix().setDouble(1, 3, 2);
EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A)); EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A));
// Note carefully - expecting true here. // Note carefully - expecting true here.
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(2, 3, 2); A.matrix().setDouble(2, 3, 2);
EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A)); EXPECT_TRUE(MathUtil::isIdentityOrTranslation(A));
MathUtil::makeIdentity(&A); A.MakeIdentity();
A.matrix().setDouble(3, 3, 2); A.matrix().setDouble(3, 3, 2);
EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A)); EXPECT_FALSE(MathUtil::isIdentityOrTranslation(A));
} }

@ -16,7 +16,7 @@
#include "ui/gfx/safe_integer_conversions.h" #include "ui/gfx/safe_integer_conversions.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
namespace cc { namespace cc {
namespace { namespace {
@ -48,8 +48,8 @@ TEST(NinePatchLayerImplTest, verifyDrawQuads)
// This scale should not affect the generated quad geometry, but only // This scale should not affect the generated quad geometry, but only
// the shared draw transform. // the shared draw transform.
WebKit::WebTransformationMatrix transform; gfx::Transform transform;
transform.scale(10); transform.Scale(10, 10);
layer->setDrawTransform(transform); layer->setDrawTransform(transform);
AppendQuadsData data; AppendQuadsData data;

@ -14,7 +14,6 @@
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
using namespace std; using namespace std;
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
@ -121,7 +120,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::finishedRenderTarget(co
} }
template<typename RenderSurfaceType> 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 // 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. // 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> 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()) if (surfaceRect.IsEmpty())
return; return;
@ -249,7 +248,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::leaveToRenderTarget(con
// FIXME: Remove usePaintTracking when paint tracking is on for paint culling. // FIXME: Remove usePaintTracking when paint tracking is on for paint culling.
template<typename LayerType> 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())); 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. // remain rectilinear, then we don't add any occlusion in screen space.
if (layerTransformsToScreenKnown(layer)) { if (layerTransformsToScreenKnown(layer)) {
WebTransformationMatrix targetToScreenTransform = m_stack.back().target->renderSurface()->screenSpaceTransform(); gfx::Transform targetToScreenTransform = m_stack.back().target->renderSurface()->screenSpaceTransform();
bool clipped; bool clipped;
gfx::QuadF clipQuadInScreen = MathUtil::mapQuad(targetToScreenTransform, gfx::QuadF(clipRectInTarget), clipped); gfx::QuadF clipQuadInScreen = MathUtil::mapQuad(targetToScreenTransform, gfx::QuadF(clipRectInTarget), clipped);
// FIXME: Find a rect interior to the transformed clip quad. // 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)); gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform, gfx::RectF(contentRect));
// Take the gfx::ToEnclosingRect, as we want to include partial pixels in the test. // 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> 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) if (hasOcclusionFromOutsideTargetSurface)
*hasOcclusionFromOutsideTargetSurface = false; *hasOcclusionFromOutsideTargetSurface = false;
@ -368,21 +367,21 @@ static inline gfx::Rect rectSubtractRegion(const gfx::Rect& rect, const Region&
return rectRegion.bounds(); 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; return contentRect;
// Take the ToEnclosingRect at each step, as we want to contain any unoccluded partial pixels in the resulting Rect. // 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::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform, gfx::RectF(contentRect));
gfx::Rect shrunkRect = rectSubtractRegion(gfx::IntersectRects(gfx::ToEnclosingRect(transformedRect), clipRectInTarget), occlusion); 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. // 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); return gfx::IntersectRects(unoccludedRect, contentRect);
} }
template<typename LayerType, typename RenderSurfaceType> 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()); DCHECK(!m_stack.empty());
if (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). // found just below the top of the stack (if it exists).
bool hasOcclusion = m_stack.size() > 1; bool hasOcclusion = m_stack.size() > 1;
const WebTransformationMatrix& transformToScreen = forReplica ? surface->replicaScreenSpaceTransform() : surface->screenSpaceTransform(); const gfx::Transform& transformToScreen = forReplica ? surface->replicaScreenSpaceTransform() : surface->screenSpaceTransform();
const WebTransformationMatrix& transformToTarget = forReplica ? surface->replicaDrawTransform() : surface->drawTransform(); const gfx::Transform& transformToTarget = forReplica ? surface->replicaDrawTransform() : surface->drawTransform();
gfx::Rect unoccludedInScreen = contentRect; gfx::Rect unoccludedInScreen = contentRect;
if (surfaceTransformsToScreenKnown(surface)) { if (surfaceTransformsToScreenKnown(surface)) {

@ -35,9 +35,9 @@ public:
void leaveLayer(const LayerIteratorPosition<LayerType>&); 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. // 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. // 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. // 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. // Used when considering occlusion for a contributing surface that is rendering into another target.

@ -4,6 +4,9 @@
#include "cc/occlusion_tracker.h" #include "cc/occlusion_tracker.h"
#include <public/WebFilterOperation.h>
#include <public/WebFilterOperations.h>
#include "cc/layer.h" #include "cc/layer.h"
#include "cc/layer_animation_controller.h" #include "cc/layer_animation_controller.h"
#include "cc/layer_impl.h" #include "cc/layer_impl.h"
@ -16,9 +19,7 @@
#include "cc/test/occlusion_tracker_test_common.h" #include "cc/test/occlusion_tracker_test_common.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebFilterOperation.h> #include "ui/gfx/transform.h"
#include <public/WebFilterOperations.h>
#include <public/WebTransformationMatrix.h>
using namespace WebKit; using namespace WebKit;
using namespace WebKitTests; using namespace WebKitTests;
@ -197,7 +198,7 @@ protected:
LayerTreeHost::setNeedsFilterContext(false); 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::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get(); typename Types::ContentLayerType* layerPtr = layer.get();
@ -208,7 +209,7 @@ protected:
return layerPtr; 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::LayerPtrType layer(Types::createLayer());
typename Types::LayerType* layerPtr = layer.get(); typename Types::LayerType* layerPtr = layer.get();
@ -217,7 +218,7 @@ protected:
return layerPtr; 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); typename Types::LayerType* layer = createLayer(parent, transform, position, bounds);
WebFilterOperations filters; WebFilterOperations filters;
@ -226,7 +227,7 @@ protected:
return layer; 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::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get(); typename Types::ContentLayerType* layerPtr = layer.get();
@ -246,7 +247,7 @@ protected:
return layerPtr; 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::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get(); typename Types::ContentLayerType* layerPtr = layer.get();
@ -264,7 +265,7 @@ protected:
return layerPtr; 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); typename Types::ContentLayerType* layer = createDrawingLayer(parent, transform, position, bounds, opaque);
WebFilterOperations filters; WebFilterOperations filters;
@ -349,24 +350,24 @@ protected:
m_layerIterator = m_layerIteratorBegin; m_layerIterator = m_layerIteratorBegin;
} }
const WebTransformationMatrix identityMatrix; const gfx::Transform identityMatrix;
private: 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->setTransform(transform);
layer->setSublayerTransform(WebTransformationMatrix()); layer->setSublayerTransform(gfx::Transform());
layer->setAnchorPoint(gfx::PointF(0, 0)); layer->setAnchorPoint(gfx::PointF(0, 0));
layer->setPosition(position); layer->setPosition(position);
layer->setBounds(bounds); 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); 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); setBaseProperties(layer, transform, position, bounds);
@ -503,8 +504,8 @@ protected:
OcclusionTrackerTestQuadsMismatchLayer(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} OcclusionTrackerTestQuadsMismatchLayer(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix layerTransform; gfx::Transform layerTransform;
layerTransform.translate(10, 10); layerTransform.Translate(10, 10);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::Point(0, 0), gfx::Size(100, 100)); 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); 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 // layers, e.g. in terms of transforms or clip rect. This is typical for
// DelegatedRendererLayer. // DelegatedRendererLayer.
WebTransformationMatrix quadTransform; gfx::Transform quadTransform;
quadTransform.translate(30, 30); quadTransform.Translate(30, 30);
gfx::Rect clipRectInTarget(0, 0, 100, 100); gfx::Rect clipRectInTarget(0, 0, 100, 100);
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, gfx::Rect(0, 0, 10, 10), quadTransform, false, clipRectInTarget).IsEmpty()); 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) {} OcclusionTrackerTestRotatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix layerTransform; gfx::Transform layerTransform;
layerTransform.translate(250, 250); layerTransform.Translate(250, 250);
layerTransform.rotate(90); layerTransform.Rotate(90);
layerTransform.translate(-250, -250); layerTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); 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); 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) {} OcclusionTrackerTestTranslatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix layerTransform; gfx::Transform layerTransform;
layerTransform.translate(20, 20); layerTransform.Translate(20, 20);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); 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); 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) {} OcclusionTrackerTestChildInRotatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix childTransform; gfx::Transform childTransform;
childTransform.translate(250, 250); childTransform.Translate(250, 250);
childTransform.rotate(90); childTransform.Rotate(90);
childTransform.translate(-250, -250); childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true); parent->setMasksToBounds(true);
@ -737,13 +738,13 @@ protected:
{ {
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(200, 200)); typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(200, 200));
WebTransformationMatrix layer1Matrix; gfx::Transform layer1Matrix;
layer1Matrix.scale(2); layer1Matrix.Scale(2, 2);
typename Types::ContentLayerType* layer1 = this->createDrawingLayer(parent, layer1Matrix, gfx::PointF(0, 0), gfx::Size(100, 100), true); typename Types::ContentLayerType* layer1 = this->createDrawingLayer(parent, layer1Matrix, gfx::PointF(0, 0), gfx::Size(100, 100), true);
layer1->setForceRenderSurface(true); layer1->setForceRenderSurface(true);
WebTransformationMatrix layer2Matrix; gfx::Transform layer2Matrix;
layer2Matrix.translate(25, 25); layer2Matrix.Translate(25, 25);
typename Types::ContentLayerType* layer2 = this->createDrawingLayer(layer1, layer2Matrix, gfx::PointF(0, 0), gfx::Size(50, 50), true); 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); typename Types::ContentLayerType* occluder = this->createDrawingLayer(parent, this->identityMatrix, gfx::PointF(100, 100), gfx::Size(500, 500), true);
this->calcDrawEtc(parent); this->calcDrawEtc(parent);
@ -771,10 +772,10 @@ protected:
OcclusionTrackerTestVisitTargetTwoTimes(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} OcclusionTrackerTestVisitTargetTwoTimes(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix childTransform; gfx::Transform childTransform;
childTransform.translate(250, 250); childTransform.Translate(250, 250);
childTransform.rotate(90); childTransform.Rotate(90);
childTransform.translate(-250, -250); childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true); parent->setMasksToBounds(true);
@ -876,13 +877,13 @@ protected:
OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix childTransform; gfx::Transform childTransform;
childTransform.translate(250, 250); childTransform.Translate(250, 250);
childTransform.rotate(95); childTransform.Rotate(95);
childTransform.translate(-250, -250); childTransform.Translate(-250, -250);
WebTransformationMatrix layerTransform; gfx::Transform layerTransform;
layerTransform.translate(10, 10); layerTransform.Translate(10, 10);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); 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)); 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) {} OcclusionTrackerTestSurfaceWithTwoOpaqueChildren(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix childTransform; gfx::Transform childTransform;
childTransform.translate(250, 250); childTransform.Translate(250, 250);
childTransform.rotate(90); childTransform.Rotate(90);
childTransform.translate(-250, -250); childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true); parent->setMasksToBounds(true);
@ -1025,10 +1026,10 @@ protected:
OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix childTransform; gfx::Transform childTransform;
childTransform.translate(250, 250); childTransform.Translate(250, 250);
childTransform.rotate(90); childTransform.Rotate(90);
childTransform.translate(-250, -250); childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true); parent->setMasksToBounds(true);
@ -1130,15 +1131,15 @@ protected:
OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix child1Transform; gfx::Transform child1Transform;
child1Transform.translate(250, 250); child1Transform.Translate(250, 250);
child1Transform.rotate(-90); child1Transform.Rotate(-90);
child1Transform.translate(-250, -250); child1Transform.Translate(-250, -250);
WebTransformationMatrix child2Transform; gfx::Transform child2Transform;
child2Transform.translate(250, 250); child2Transform.Translate(250, 250);
child2Transform.rotate(90); child2Transform.Rotate(90);
child2Transform.translate(-250, -250); child2Transform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true); parent->setMasksToBounds(true);
@ -1233,10 +1234,10 @@ protected:
OcclusionTrackerTestFilters(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} OcclusionTrackerTestFilters(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix layerTransform; gfx::Transform layerTransform;
layerTransform.translate(250, 250); layerTransform.Translate(250, 250);
layerTransform.rotate(90); layerTransform.Rotate(90);
layerTransform.translate(-250, -250); layerTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true); parent->setMasksToBounds(true);
@ -1867,8 +1868,8 @@ protected:
OcclusionTrackerTest3dTransform(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} OcclusionTrackerTest3dTransform(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix transform; gfx::Transform transform;
transform.rotate3d(0, 30, 0); MathUtil::rotateEulerAngles(&transform, 0, 30, 0);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300)); 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)); 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 // behavior is that a 3d layer simply does not add any occlusion to the occlusion
// tracker. // tracker.
WebTransformationMatrix translationToFront; gfx::Transform translationToFront;
translationToFront.translate3d(0, 0, -10); translationToFront.Translate3d(0, 0, -10);
WebTransformationMatrix translationToBack; gfx::Transform translationToBack;
translationToFront.translate3d(0, 0, -100); translationToFront.Translate3d(0, 0, -100);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300)); 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); 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) {} OcclusionTrackerTestPerspectiveTransform(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix transform; gfx::Transform transform;
transform.translate(150, 150); transform.Translate(150, 150);
transform.applyPerspective(400); transform.ApplyPerspectiveDepth(400);
transform.rotate3d(1, 0, 0, -30); MathUtil::rotateAxisAngle(&transform, 1, 0, 0, -30);
transform.translate(-150, -150); transform.Translate(-150, -150);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300)); 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)); typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
@ -1960,13 +1961,13 @@ protected:
void runMyTest() void runMyTest()
{ {
// This test is based on the platform/chromium/compositing/3d-corners.html layout test. // This test is based on the platform/chromium/compositing/3d-corners.html layout test.
WebTransformationMatrix transform; gfx::Transform transform;
transform.translate(250, 50); transform.Translate(250, 50);
transform.applyPerspective(10); transform.ApplyPerspectiveDepth(10);
transform.translate(-250, -50); transform.Translate(-250, -50);
transform.translate(250, 50); transform.Translate(250, 50);
transform.rotate3d(1, 0, 0, -167); MathUtil::rotateAxisAngle(&transform, 1, 0, 0, -167);
transform.translate(-250, -50); transform.Translate(-250, -50);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 100)); 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)); 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) {} OcclusionTrackerTestLayerBehindCameraDoesNotOcclude(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix transform; gfx::Transform transform;
transform.translate(50, 50); transform.Translate(50, 50);
transform.applyPerspective(100); transform.ApplyPerspectiveDepth(100);
transform.translate3d(0, 0, 110); transform.Translate3d(0, 0, 110);
transform.translate(-50, -50); transform.Translate(-50, -50);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); 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); 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) {} OcclusionTrackerTestLargePixelsOccludeInsideClipRect(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix transform; gfx::Transform transform;
transform.translate(50, 50); transform.Translate(50, 50);
transform.applyPerspective(100); transform.ApplyPerspectiveDepth(100);
transform.translate3d(0, 0, 99); transform.Translate3d(0, 0, 99);
transform.translate(-50, -50); transform.Translate(-50, -50);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true); parent->setMasksToBounds(true);
@ -2249,10 +2250,10 @@ protected:
OcclusionTrackerTestSurfaceOcclusionTranslatesToParent(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} OcclusionTrackerTestSurfaceOcclusionTranslatesToParent(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix surfaceTransform; gfx::Transform surfaceTransform;
surfaceTransform.translate(300, 300); surfaceTransform.Translate(300, 300);
surfaceTransform.scale(2); surfaceTransform.Scale(2, 2);
surfaceTransform.translate(-150, -150); surfaceTransform.Translate(-150, -150);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 500)); 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); 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) {} OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix scaleByHalf; gfx::Transform scaleByHalf;
scaleByHalf.scale(0.5); 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. // 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 // 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) {} OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix scaleByHalf; gfx::Transform scaleByHalf;
scaleByHalf.scale(0.5); 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. // 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)); 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) {} OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix scaleByHalf; gfx::Transform scaleByHalf;
scaleByHalf.scale(0.5); scaleByHalf.Scale(0.5, 0.5);
// Make a surface and its replica, each 50x50, with a smaller 30x30 layer centered below each. // 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 // 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) {} OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix scaleByHalf; gfx::Transform scaleByHalf;
scaleByHalf.scale(0.5); 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. // 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 // 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) {} OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest() void runMyTest()
{ {
WebTransformationMatrix scaleByHalf; gfx::Transform scaleByHalf;
scaleByHalf.scale(0.5); 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. // 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 // 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

@ -11,9 +11,7 @@
#include "cc/math_util.h" #include "cc/math_util.h"
#include "ui/gfx/quad_f.h" #include "ui/gfx/quad_f.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { 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. // 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]; gfx::PointF clippedQuad[8];
int numVerticesInClippedQuad = 0; int numVerticesInClippedQuad = 0;
@ -71,7 +69,7 @@ void OverdrawMetrics::didCullTilesForUpload(int count)
m_tilesCulledForUpload += 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) if (!m_recordMetricsForFrame)
return; return;
@ -99,7 +97,7 @@ void OverdrawMetrics::didUseRenderSurfaceTextureMemoryBytes(size_t renderSurface
m_renderSurfaceTextureUseBytes += renderSurfaceUseBytes; 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) if (!m_recordMetricsForFrame)
return; return;
@ -110,7 +108,7 @@ void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transform
m_pixelsCulledForDrawing += beforeCullArea - afterCullArea; 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) if (!m_recordMetricsForFrame)
return; return;

@ -9,10 +9,7 @@
namespace gfx { namespace gfx {
class Rect; class Rect;
} class Transform;
namespace WebKit {
class WebTransformationMatrix;
} }
namespace cc { 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. // 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); void didCullTilesForUpload(int count);
// Records pixels that were uploaded to texture memory. // 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. // Record contents texture(s) behind present using the given number of bytes.
void didUseContentsTextureMemoryBytes(size_t contentsTextureUseBytes); void didUseContentsTextureMemoryBytes(size_t contentsTextureUseBytes);
// Record RenderSurfaceImpl texture(s) being present using the given number of bytes. // 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. // These methods are used for saving metrics during draw.
// Record pixels that were not drawn to screen. // 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. // 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 LayerTreeHost*) const;
void recordMetrics(const LayerTreeHostImpl*) const; void recordMetrics(const LayerTreeHostImpl*) const;

@ -12,7 +12,7 @@
#include "cc/overdraw_metrics.h" #include "cc/overdraw_metrics.h"
#include "cc/render_pass.h" #include "cc/render_pass.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using namespace std; using namespace std;

@ -14,9 +14,7 @@
#include "cc/tiled_layer_impl.h" #include "cc/tiled_layer_impl.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
namespace { namespace {
@ -38,7 +36,7 @@ private:
typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; 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<TiledLayerImpl> layer = TiledLayerImpl::create(1);
scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(100, 100), LayerTilingData::NoBorderTexels); 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; \ QuadList quadList; \
SharedQuadStateList sharedStateList; \ SharedQuadStateList sharedStateList; \
std::vector<LayerImpl*> renderSurfaceLayerList; \ std::vector<LayerImpl*> renderSurfaceLayerList; \
WebTransformationMatrix childTransform; \ gfx::Transform childTransform; \
gfx::Size rootSize = gfx::Size(300, 300); \ gfx::Size rootSize = gfx::Size(300, 300); \
gfx::Rect rootRect = gfx::Rect(rootSize); \ gfx::Rect rootRect = gfx::Rect(rootSize); \
gfx::Size childSize = gfx::Size(200, 200); \ gfx::Size childSize = gfx::Size(200, 200); \
@ -99,8 +97,8 @@ TEST(QuadCullerTest, verifyNoCulling)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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(), WebTransformationMatrix(), childRect, 1, false, 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)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -116,8 +114,8 @@ TEST(QuadCullerTest, verifyCullChildLinesUpTopLeft)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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(), 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)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -133,7 +131,7 @@ TEST(QuadCullerTest, verifyCullWhenChildOpacityNotOne)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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); scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 0.9f, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -150,7 +148,7 @@ TEST(QuadCullerTest, verifyCullWhenChildOpaqueFlagFalse)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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); scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -167,9 +165,9 @@ TEST(QuadCullerTest, verifyCullCenterTileOnly)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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); scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -202,13 +200,13 @@ TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize1)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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 // 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. // sure it doesn't get culled due to transform rounding.
WebTransformationMatrix rootTransform; gfx::Transform rootTransform;
rootTransform.translate(99.1, 99.1); rootTransform.Translate(99.1, 99.1);
rootTransform.scale(1.018); rootTransform.Scale(1.018, 1.018);
rootRect = childRect = gfx::Rect(0, 0, 100, 100); 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. // 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. // Verify the child does not cause the quad below to be culled due to rounding.
childTransform.translate(100.1, 100.1); childTransform.Translate(100.1, 100.1);
childTransform.scale(0.982); childTransform.Scale(0.982, 0.982);
WebTransformationMatrix rootTransform; gfx::Transform rootTransform;
rootTransform.translate(100, 100); rootTransform.Translate(100, 100);
rootRect = childRect = gfx::Rect(0, 0, 100, 100); rootRect = childRect = gfx::Rect(0, 0, 100, 100);
@ -258,9 +256,9 @@ TEST(QuadCullerTest, verifyCullChildLinesUpBottomRight)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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); scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -277,9 +275,9 @@ TEST(QuadCullerTest, verifyCullSubRegion)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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); 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); scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
@ -297,9 +295,9 @@ TEST(QuadCullerTest, verifyCullSubRegion2)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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); 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); scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
@ -317,9 +315,9 @@ TEST(QuadCullerTest, verifyCullSubRegionCheckOvercull)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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); 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); scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
@ -338,9 +336,9 @@ TEST(QuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude)
DECLARE_AND_INITIALIZE_TEST_QUADS DECLARE_AND_INITIALIZE_TEST_QUADS
// Use a small rotation so as to not disturb the geometry significantly. // 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); scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -363,11 +361,11 @@ TEST(QuadCullerTest, verifyNonAxisAlignedQuadsSafelyCulled)
DECLARE_AND_INITIALIZE_TEST_QUADS DECLARE_AND_INITIALIZE_TEST_QUADS
// Use a small rotation so as to not disturb the geometry significantly. // Use a small rotation so as to not disturb the geometry significantly.
WebTransformationMatrix parentTransform; gfx::Transform parentTransform;
parentTransform.rotate(1); parentTransform.Rotate(1);
scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, parentTransform, rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 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)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -383,8 +381,8 @@ TEST(QuadCullerTest, verifyCullOutsideScissorOverTile)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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(), 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(200, 100, 100, 100)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(200, 100, 100, 100));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -400,8 +398,8 @@ TEST(QuadCullerTest, verifyCullOutsideScissorOverCulledTile)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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(), 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, 100, 100)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(100, 100, 100, 100));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -417,8 +415,8 @@ TEST(QuadCullerTest, verifyCullOutsideScissorOverPartialTiles)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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(), 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(50, 50, 200, 200)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(50, 50, 200, 200));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -434,8 +432,8 @@ TEST(QuadCullerTest, verifyCullOutsideScissorOverNoTiles)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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(), 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(500, 500, 100, 100)); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(500, 500, 100, 100));
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
@ -451,8 +449,8 @@ TEST(QuadCullerTest, verifyWithoutMetrics)
{ {
DECLARE_AND_INITIALIZE_TEST_QUADS 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(), 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(50, 50, 200, 200), false); TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(50, 50, 200, 200), false);
LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);

@ -6,8 +6,6 @@
#include "third_party/skia/include/core/SkImageFilter.h" #include "third_party/skia/include/core/SkImageFilter.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
scoped_ptr<RenderPass> RenderPass::Create() { scoped_ptr<RenderPass> RenderPass::Create() {
@ -44,7 +42,7 @@ scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const {
void RenderPass::SetNew(Id id, void RenderPass::SetNew(Id id,
gfx::Rect output_rect, gfx::Rect output_rect,
gfx::RectF damage_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_GT(id.layer_id, 0);
DCHECK_GE(id.index, 0); DCHECK_GE(id.index, 0);
@ -60,7 +58,7 @@ void RenderPass::SetNew(Id id,
void RenderPass::SetAll(Id id, void RenderPass::SetAll(Id id,
gfx::Rect output_rect, gfx::Rect output_rect,
gfx::RectF damage_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_transparent_background,
bool has_occlusion_from_outside_target_surface, bool has_occlusion_from_outside_target_surface,
const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& filters,

@ -5,6 +5,9 @@
#ifndef CC_RENDER_PASS_H_ #ifndef CC_RENDER_PASS_H_
#define CC_RENDER_PASS_H_ #define CC_RENDER_PASS_H_
#include <public/WebFilterOperations.h>
#include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/draw_quad.h" #include "cc/draw_quad.h"
@ -14,9 +17,7 @@
#include "cc/shared_quad_state.h" #include "cc/shared_quad_state.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include <public/WebFilterOperations.h> #include "ui/gfx/transform.h"
#include <public/WebTransformationMatrix.h>
#include <vector>
class SkImageFilter; class SkImageFilter;
@ -66,12 +67,12 @@ class CC_EXPORT RenderPass {
void SetNew(Id id, void SetNew(Id id,
gfx::Rect output_rect, gfx::Rect output_rect,
gfx::RectF damage_rect, gfx::RectF damage_rect,
const WebKit::WebTransformationMatrix& transform_to_root_target); const gfx::Transform& transform_to_root_target);
void SetAll(Id id, void SetAll(Id id,
gfx::Rect output_rect, gfx::Rect output_rect,
gfx::RectF damage_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_transparent_background,
bool has_occlusion_from_outside_target_surface, bool has_occlusion_from_outside_target_surface,
const WebKit::WebFilterOperations& filters, 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 // Transforms from the origin of the |output_rect| to the origin of the root
// render pass' |output_rect|. // 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. // If false, the pixels in the render pass' texture are all opaque.
bool has_transparent_background; bool has_transparent_background;

@ -4,17 +4,18 @@
#include "cc/render_pass.h" #include "cc/render_pass.h"
#include <public/WebFilterOperations.h>
#include "cc/checkerboard_draw_quad.h" #include "cc/checkerboard_draw_quad.h"
#include "cc/math_util.h"
#include "cc/test/geometry_test_utils.h" #include "cc/test/geometry_test_utils.h"
#include "cc/test/render_pass_test_common.h" #include "cc/test/render_pass_test_common.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/effects/SkBlurImageFilter.h" #include "third_party/skia/include/effects/SkBlurImageFilter.h"
#include <public/WebFilterOperations.h> #include "ui/gfx/transform.h"
#include <public/WebTransformationMatrix.h>
using WebKit::WebFilterOperation; using WebKit::WebFilterOperation;
using WebKit::WebFilterOperations; using WebKit::WebFilterOperations;
using WebKit::WebTransformationMatrix;
using WebKitTests::TestRenderPass; using WebKitTests::TestRenderPass;
namespace cc { namespace cc {
@ -25,7 +26,7 @@ struct RenderPassSize {
RenderPass::Id m_id; RenderPass::Id m_id;
QuadList m_quadList; QuadList m_quadList;
SharedQuadStateList m_sharedQuadStateList; SharedQuadStateList m_sharedQuadStateList;
WebKit::WebTransformationMatrix m_transformToRootTarget; gfx::Transform m_transformToRootTarget;
gfx::Rect m_outputRect; gfx::Rect m_outputRect;
gfx::RectF m_damageRect; gfx::RectF m_damageRect;
bool m_hasTransparentBackground; bool m_hasTransparentBackground;
@ -39,7 +40,7 @@ TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads)
{ {
RenderPass::Id id(3, 2); RenderPass::Id id(3, 2);
gfx::Rect outputRect(45, 22, 120, 13); 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); gfx::Rect damageRect(56, 123, 19, 43);
bool hasTransparentBackground = true; bool hasTransparentBackground = true;
bool hasOcclusionFromOutsideTargetSurface = true; bool hasOcclusionFromOutsideTargetSurface = true;
@ -63,7 +64,7 @@ TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads)
// Stick a quad in the pass, this should not get copied. // Stick a quad in the pass, this should not get copied.
scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); 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()); pass->AppendSharedQuadState(sharedState.Pass());
scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = CheckerboardDrawQuad::Create(); scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = CheckerboardDrawQuad::Create();

@ -6,9 +6,7 @@
#include "cc/layer.h" #include "cc/layer.h"
#include "cc/math_util.h" #include "cc/math_util.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {

@ -6,13 +6,14 @@
#ifndef CC_RENDER_SURFACE_H_ #ifndef CC_RENDER_SURFACE_H_
#define CC_RENDER_SURFACE_H_ #define CC_RENDER_SURFACE_H_
#include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "cc/cc_export.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
#include <vector>
#include "cc/cc_export.h"
namespace cc { 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 // 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. // 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; } const gfx::Transform& drawTransform() const { return m_drawTransform; }
void setDrawTransform(const WebKit::WebTransformationMatrix& drawTransform) { m_drawTransform = drawTransform; } void setDrawTransform(const gfx::Transform& drawTransform) { m_drawTransform = drawTransform; }
const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; } const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; } void setScreenSpaceTransform(const gfx::Transform& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; }
const WebKit::WebTransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; } const gfx::Transform& replicaDrawTransform() const { return m_replicaDrawTransform; }
void setReplicaDrawTransform(const WebKit::WebTransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; } void setReplicaDrawTransform(const gfx::Transform& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; } const gfx::Transform& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; }
void setReplicaScreenSpaceTransform(const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; } void setReplicaScreenSpaceTransform(const gfx::Transform& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; }
bool targetSurfaceTransformsAreAnimating() const { return m_targetSurfaceTransformsAreAnimating; } bool targetSurfaceTransformsAreAnimating() const { return m_targetSurfaceTransformsAreAnimating; }
void setTargetSurfaceTransformsAreAnimating(bool animating) { m_targetSurfaceTransformsAreAnimating = animating; } void setTargetSurfaceTransformsAreAnimating(bool animating) { m_targetSurfaceTransformsAreAnimating = animating; }
@ -80,10 +81,10 @@ private:
float m_drawOpacity; float m_drawOpacity;
bool m_drawOpacityIsAnimating; bool m_drawOpacityIsAnimating;
WebKit::WebTransformationMatrix m_drawTransform; gfx::Transform m_drawTransform;
WebKit::WebTransformationMatrix m_screenSpaceTransform; gfx::Transform m_screenSpaceTransform;
WebKit::WebTransformationMatrix m_replicaDrawTransform; gfx::Transform m_replicaDrawTransform;
WebKit::WebTransformationMatrix m_replicaScreenSpaceTransform; gfx::Transform m_replicaScreenSpaceTransform;
bool m_targetSurfaceTransformsAreAnimating; bool m_targetSurfaceTransformsAreAnimating;
bool m_screenSpaceTransformsAreAnimating; bool m_screenSpaceTransformsAreAnimating;

@ -21,9 +21,7 @@
#include "cc/shared_quad_state.h" #include "cc/shared_quad_state.h"
#include "third_party/skia/include/core/SkImageFilter.h" #include "third_party/skia/include/core/SkImageFilter.h"
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
@ -80,10 +78,10 @@ void RenderSurfaceImpl::dumpSurface(std::string* str, int indent) const
str->append(indentStr); str->append(indentStr);
base::StringAppendF(str, "drawTransform: %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", 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.matrix().getDouble(0, 0), m_drawTransform.matrix().getDouble(0, 1), m_drawTransform.matrix().getDouble(0, 2), m_drawTransform.matrix().getDouble(0, 3),
m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_drawTransform.m24(), 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.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_drawTransform.m34(), 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.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_drawTransform.m44()); 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); str->append(indentStr);
base::StringAppendF(str, "damageRect is pos(%f, %f), size(%f, %f)\n", 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()); DCHECK(!forReplica || m_owningLayer->hasReplica());
gfx::Rect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer); 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* sharedQuadState = quadSink.useSharedQuadState(SharedQuadState::Create());
sharedQuadState->SetAll(drawTransform, m_contentRect, clippedRectInTarget, m_clipRect, m_isClipped, m_drawOpacity); sharedQuadState->SetAll(drawTransform, m_contentRect, clippedRectInTarget, m_clipRect, m_isClipped, m_drawOpacity);

@ -12,7 +12,7 @@
#include "cc/shared_quad_state.h" #include "cc/shared_quad_state.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
namespace cc { namespace cc {
@ -46,17 +46,17 @@ public:
bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating; } bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating; }
void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating) { m_drawOpacityIsAnimating = drawOpacityIsAnimating; } void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating) { m_drawOpacityIsAnimating = drawOpacityIsAnimating; }
void setDrawTransform(const WebKit::WebTransformationMatrix& drawTransform) { m_drawTransform = drawTransform; } void setDrawTransform(const gfx::Transform& drawTransform) { m_drawTransform = drawTransform; }
const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; } const gfx::Transform& drawTransform() const { return m_drawTransform; }
void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; } void setScreenSpaceTransform(const gfx::Transform& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; }
const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; } const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
void setReplicaDrawTransform(const WebKit::WebTransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; } void setReplicaDrawTransform(const gfx::Transform& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
const WebKit::WebTransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; } const gfx::Transform& replicaDrawTransform() const { return m_replicaDrawTransform; }
void setReplicaScreenSpaceTransform(const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; } void setReplicaScreenSpaceTransform(const gfx::Transform& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; }
const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; } const gfx::Transform& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; }
bool targetSurfaceTransformsAreAnimating() const { return m_targetSurfaceTransformsAreAnimating; } bool targetSurfaceTransformsAreAnimating() const { return m_targetSurfaceTransformsAreAnimating; }
void setTargetSurfaceTransformsAreAnimating(bool animating) { m_targetSurfaceTransformsAreAnimating = animating; } void setTargetSurfaceTransformsAreAnimating(bool animating) { m_targetSurfaceTransformsAreAnimating = animating; }
@ -100,10 +100,10 @@ private:
float m_drawOpacity; float m_drawOpacity;
bool m_drawOpacityIsAnimating; bool m_drawOpacityIsAnimating;
WebKit::WebTransformationMatrix m_drawTransform; gfx::Transform m_drawTransform;
WebKit::WebTransformationMatrix m_screenSpaceTransform; gfx::Transform m_screenSpaceTransform;
WebKit::WebTransformationMatrix m_replicaDrawTransform; gfx::Transform m_replicaDrawTransform;
WebKit::WebTransformationMatrix m_replicaScreenSpaceTransform; gfx::Transform m_replicaScreenSpaceTransform;
bool m_targetSurfaceTransformsAreAnimating; bool m_targetSurfaceTransformsAreAnimating;
bool m_screenSpaceTransformsAreAnimating; bool m_screenSpaceTransformsAreAnimating;

@ -14,9 +14,7 @@
#include "cc/test/mock_quad_culler.h" #include "cc/test/mock_quad_culler.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
namespace { namespace {
@ -58,8 +56,8 @@ TEST(RenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(testRect)); EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(testRect));
scoped_ptr<LayerImpl> dummyMask = LayerImpl::create(1); scoped_ptr<LayerImpl> dummyMask = LayerImpl::create(1);
WebTransformationMatrix dummyMatrix; gfx::Transform dummyMatrix;
dummyMatrix.translate(1.0, 2.0); dummyMatrix.Translate(1.0, 2.0);
// The rest of the surface properties are either internal and should not cause change, // The rest of the surface properties are either internal and should not cause change,
// or they are already accounted for by the owninglayer->layerPropertyChanged(). // 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 contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50));
gfx::Rect clipRect = gfx::Rect(gfx::Point(5, 5), gfx::Size(40, 40)); 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->setDrawTransform(origin);
renderSurface->setContentRect(contentRect); renderSurface->setContentRect(contentRect);
@ -103,8 +101,8 @@ TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
ASSERT_EQ(1u, sharedStateList.size()); ASSERT_EQ(1u, sharedStateList.size());
SharedQuadState* sharedQuadState = sharedStateList[0]; SharedQuadState* sharedQuadState = sharedStateList[0];
EXPECT_EQ(30, sharedQuadState->content_to_target_transform.m41()); EXPECT_EQ(30, sharedQuadState->content_to_target_transform.matrix().getDouble(0, 3));
EXPECT_EQ(40, sharedQuadState->content_to_target_transform.m42()); EXPECT_EQ(40, sharedQuadState->content_to_target_transform.matrix().getDouble(1, 3));
EXPECT_RECT_EQ(contentRect, gfx::Rect(sharedQuadState->visible_content_rect)); EXPECT_RECT_EQ(contentRect, gfx::Rect(sharedQuadState->visible_content_rect));
EXPECT_EQ(1, sharedQuadState->opacity); EXPECT_EQ(1, sharedQuadState->opacity);
} }
@ -132,8 +130,8 @@ TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass)
rootLayer->addChild(owningLayer.Pass()); rootLayer->addChild(owningLayer.Pass());
gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50)); gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50));
WebTransformationMatrix origin; gfx::Transform origin;
origin.translate(30, 40); origin.Translate(30, 40);
renderSurface->setScreenSpaceTransform(origin); renderSurface->setScreenSpaceTransform(origin);
renderSurface->setContentRect(contentRect); renderSurface->setContentRect(contentRect);

@ -19,7 +19,7 @@ scoped_ptr<SharedQuadState> SharedQuadState::Copy() const {
} }
void SharedQuadState::SetAll( 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& visible_content_rect,
const gfx::Rect& clipped_rect_in_target, const gfx::Rect& clipped_rect_in_target,
const gfx::Rect& clip_rect, const gfx::Rect& clip_rect,

@ -6,9 +6,9 @@
#define CC_SHARED_QUAD_STATE_H_ #define CC_SHARED_QUAD_STATE_H_
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "ui/gfx/rect.h"
#include <public/WebTransformationMatrix.h>
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/transform.h"
namespace cc { namespace cc {
@ -19,7 +19,7 @@ class CC_EXPORT SharedQuadState {
scoped_ptr<SharedQuadState> Copy() const; 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& visible_content_rect,
const gfx::Rect& clipped_rect_in_target, const gfx::Rect& clipped_rect_in_target,
const gfx::Rect& clip_rect, const gfx::Rect& clip_rect,
@ -27,7 +27,7 @@ class CC_EXPORT SharedQuadState {
float opacity); float opacity);
// Transforms from quad's original content space to its target content space. // 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. // This rect lives in the content space for the quad's originating layer.
gfx::Rect visible_content_rect; gfx::Rect visible_content_rect;
gfx::Rect clipped_rect_in_target; gfx::Rect clipped_rect_in_target;

@ -4,8 +4,13 @@
#include "cc/software_renderer.h" #include "cc/software_renderer.h"
#include <public/WebCompositorSoftwareOutputDevice.h>
#include <public/WebImage.h>
#include <public/WebSize.h>
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "cc/debug_border_draw_quad.h" #include "cc/debug_border_draw_quad.h"
#include "cc/math_util.h"
#include "cc/render_pass_draw_quad.h" #include "cc/render_pass_draw_quad.h"
#include "cc/solid_color_draw_quad.h" #include "cc/solid_color_draw_quad.h"
#include "cc/texture_draw_quad.h" #include "cc/texture_draw_quad.h"
@ -17,31 +22,27 @@
#include "third_party/skia/include/effects/SkLayerRasterizer.h" #include "third_party/skia/include/effects/SkLayerRasterizer.h"
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include <public/WebCompositorSoftwareOutputDevice.h> #include "ui/gfx/transform.h"
#include <public/WebImage.h>
#include <public/WebSize.h>
#include <public/WebTransformationMatrix.h>
using WebKit::WebCompositorSoftwareOutputDevice; using WebKit::WebCompositorSoftwareOutputDevice;
using WebKit::WebSize; using WebKit::WebSize;
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
namespace { 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. // Convert from 4x4 to 3x3 by dropping the third row and column.
flattened->set(0, SkDoubleToScalar(m.m11())); flattened->set(0, SkDoubleToScalar(m.matrix().getDouble(0, 0)));
flattened->set(1, SkDoubleToScalar(m.m21())); flattened->set(1, SkDoubleToScalar(m.matrix().getDouble(0, 1)));
flattened->set(2, SkDoubleToScalar(m.m41())); flattened->set(2, SkDoubleToScalar(m.matrix().getDouble(0, 3)));
flattened->set(3, SkDoubleToScalar(m.m12())); flattened->set(3, SkDoubleToScalar(m.matrix().getDouble(1, 0)));
flattened->set(4, SkDoubleToScalar(m.m22())); flattened->set(4, SkDoubleToScalar(m.matrix().getDouble(1, 1)));
flattened->set(5, SkDoubleToScalar(m.m42())); flattened->set(5, SkDoubleToScalar(m.matrix().getDouble(1, 3)));
flattened->set(6, SkDoubleToScalar(m.m14())); flattened->set(6, SkDoubleToScalar(m.matrix().getDouble(3, 0)));
flattened->set(7, SkDoubleToScalar(m.m24())); flattened->set(7, SkDoubleToScalar(m.matrix().getDouble(3, 1)));
flattened->set(8, SkDoubleToScalar(m.m44())); flattened->set(8, SkDoubleToScalar(m.matrix().getDouble(3, 3)));
} }
bool isScaleAndTranslate(const SkMatrix& matrix) bool isScaleAndTranslate(const SkMatrix& matrix)
@ -184,9 +185,9 @@ bool SoftwareRenderer::isSoftwareResource(ResourceProvider::ResourceId id) const
void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad)
{ {
TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad"); TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad");
WebTransformationMatrix quadRectMatrix; gfx::Transform quadRectMatrix;
quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); 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; SkMatrix skDeviceMatrix;
toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); toSkMatrix(&skDeviceMatrix, contentsDeviceTransform);
m_skCurrentCanvas->setMatrix(skDeviceMatrix); m_skCurrentCanvas->setMatrix(skDeviceMatrix);

@ -67,10 +67,10 @@ TEST_F(SoftwareRendererTest, solidColorQuad)
initializeRenderer(); initializeRenderer();
scoped_ptr<SharedQuadState> sharedQuadState = SharedQuadState::Create(); 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); RenderPass::Id rootRenderPassId = RenderPass::Id(1, 1);
scoped_ptr<TestRenderPass> rootRenderPass = TestRenderPass::Create(); 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(); scoped_ptr<SolidColorDrawQuad> outerQuad = SolidColorDrawQuad::Create();
outerQuad->SetNew(sharedQuadState.get(), outerRect, SK_ColorYELLOW); outerQuad->SetNew(sharedQuadState.get(), outerRect, SK_ColorYELLOW);
scoped_ptr<SolidColorDrawQuad> innerQuad = SolidColorDrawQuad::Create(); scoped_ptr<SolidColorDrawQuad> innerQuad = SolidColorDrawQuad::Create();
@ -128,10 +128,10 @@ TEST_F(SoftwareRendererTest, tileQuad)
gfx::Rect rect = gfx::Rect(gfx::Point(), deviceViewportSize()); gfx::Rect rect = gfx::Rect(gfx::Point(), deviceViewportSize());
scoped_ptr<SharedQuadState> sharedQuadState = SharedQuadState::Create(); 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); RenderPass::Id rootRenderPassId = RenderPass::Id(1, 1);
scoped_ptr<TestRenderPass> rootRenderPass = TestRenderPass::Create(); 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(); scoped_ptr<TileDrawQuad> outerQuad = TileDrawQuad::Create();
outerQuad->SetNew(sharedQuadState.get(), outerRect, outerRect, resourceYellow, gfx::RectF(gfx::PointF(), outerSize), outerSize, false, false, false, false, false); outerQuad->SetNew(sharedQuadState.get(), outerRect, outerRect, resourceYellow, gfx::RectF(gfx::PointF(), outerSize), outerSize, false, false, false, false, false);
scoped_ptr<TileDrawQuad> innerQuad = TileDrawQuad::Create(); scoped_ptr<TileDrawQuad> innerQuad = TileDrawQuad::Create();

@ -7,8 +7,6 @@
#include "cc/quad_sink.h" #include "cc/quad_sink.h"
#include "cc/solid_color_draw_quad.h" #include "cc/solid_color_draw_quad.h"
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
SolidColorLayerImpl::SolidColorLayerImpl(int id) SolidColorLayerImpl::SolidColorLayerImpl(int id)

@ -7,7 +7,6 @@
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/layer_impl.h" #include "cc/layer_impl.h"
#include <public/WebTransformationMatrix.h>
namespace cc { namespace cc {

@ -18,7 +18,7 @@ void StreamVideoDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
gfx::Rect rect, gfx::Rect rect,
gfx::Rect opaque_rect, gfx::Rect opaque_rect,
unsigned texture_id, unsigned texture_id,
const WebKit::WebTransformationMatrix& matrix) { const gfx::Transform& matrix) {
gfx::Rect visible_rect = rect; gfx::Rect visible_rect = rect;
bool needs_blending = false; bool needs_blending = false;
DrawQuad::SetAll(shared_quad_state, DrawQuad::STREAM_VIDEO_CONTENT, rect, 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, gfx::Rect visible_rect,
bool needs_blending, bool needs_blending,
unsigned texture_id, unsigned texture_id,
const WebKit::WebTransformationMatrix& matrix) { const gfx::Transform& matrix) {
DrawQuad::SetAll(shared_quad_state, DrawQuad::STREAM_VIDEO_CONTENT, rect, DrawQuad::SetAll(shared_quad_state, DrawQuad::STREAM_VIDEO_CONTENT, rect,
opaque_rect, visible_rect, needs_blending); opaque_rect, visible_rect, needs_blending);
this->texture_id = texture_id; this->texture_id = texture_id;

@ -8,7 +8,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/draw_quad.h" #include "cc/draw_quad.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
namespace cc { namespace cc {
@ -20,7 +20,7 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad {
gfx::Rect rect, gfx::Rect rect,
gfx::Rect opaque_rect, gfx::Rect opaque_rect,
unsigned texture_id, unsigned texture_id,
const WebKit::WebTransformationMatrix& matrix); const gfx::Transform& matrix);
void SetAll(const SharedQuadState* shared_quad_state, void SetAll(const SharedQuadState* shared_quad_state,
gfx::Rect rect, gfx::Rect rect,
@ -28,10 +28,10 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad {
gfx::Rect visible_rect, gfx::Rect visible_rect,
bool needs_blending, bool needs_blending,
unsigned texture_id, unsigned texture_id,
const WebKit::WebTransformationMatrix& matrix); const gfx::Transform& matrix);
unsigned texture_id; unsigned texture_id;
WebKit::WebTransformationMatrix matrix; gfx::Transform matrix;
static const StreamVideoDrawQuad* MaterialCast(const DrawQuad*); static const StreamVideoDrawQuad* MaterialCast(const DrawQuad*);
private: private:

@ -174,12 +174,12 @@ float FakeLayerAnimationControllerClient::opacity() const
return m_opacity; return m_opacity;
} }
void FakeLayerAnimationControllerClient::setTransformFromAnimation(const WebKit::WebTransformationMatrix& transform) void FakeLayerAnimationControllerClient::setTransformFromAnimation(const gfx::Transform& transform)
{ {
m_transform = transform; m_transform = transform;
} }
const WebKit::WebTransformationMatrix& FakeLayerAnimationControllerClient::transform() const const gfx::Transform& FakeLayerAnimationControllerClient::transform() const
{ {
return m_transform; return m_transform;
} }

@ -69,12 +69,12 @@ public:
virtual int id() const OVERRIDE; virtual int id() const OVERRIDE;
virtual void setOpacityFromAnimation(float) OVERRIDE; virtual void setOpacityFromAnimation(float) OVERRIDE;
virtual float opacity() const OVERRIDE; virtual float opacity() const OVERRIDE;
virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix&) OVERRIDE; virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE;
virtual const WebKit::WebTransformationMatrix& transform() const OVERRIDE; virtual const gfx::Transform& transform() const OVERRIDE;
private: private:
float m_opacity; float m_opacity;
WebKit::WebTransformationMatrix m_transform; gfx::Transform m_transform;
}; };
int addOpacityTransitionToController(cc::LayerAnimationController&, double duration, float startOpacity, float endOpacity, bool useTimingFunction); int addOpacityTransitionToController(cc::LayerAnimationController&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);

@ -4,11 +4,17 @@
#include "cc/test/geometry_test_utils.h" #include "cc/test/geometry_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h> #include <public/WebTransformationMatrix.h>
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/transform.h"
namespace WebKitTests { 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, void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expected,
const WebKit::WebTransformationMatrix& actual) const WebKit::WebTransformationMatrix& actual)
{ {
@ -30,4 +36,25 @@ void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expecte
EXPECT_FLOAT_EQ((expected).m44(), (actual).m44()); 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 } // namespace WebKitTests

@ -5,6 +5,10 @@
#ifndef CC_TEST_GEOMETRY_TEST_UTILS_H_ #ifndef CC_TEST_GEOMETRY_TEST_UTILS_H_
#define CC_TEST_GEOMETRY_TEST_UTILS_H_ #define CC_TEST_GEOMETRY_TEST_UTILS_H_
namespace gfx {
class Transform;
}
namespace WebKit { namespace WebKit {
class WebTransformationMatrix; class WebTransformationMatrix;
} }
@ -50,6 +54,9 @@ do { \
// in bulk, it causes a significant slow-down in compilation time. This problem // 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 // 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 // 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, void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expected,
const WebKit::WebTransformationMatrix& actual); const WebKit::WebTransformationMatrix& actual);

@ -15,12 +15,11 @@
#include "cc/tile_draw_quad.h" #include "cc/tile_draw_quad.h"
#include "cc/yuv_video_draw_quad.h" #include "cc/yuv_video_draw_quad.h"
#include "cc/resource_provider.h" #include "cc/resource_provider.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
namespace WebKitTests { namespace WebKitTests {
using cc::DrawQuad; using cc::DrawQuad;
using WebKit::WebTransformationMatrix;
void TestRenderPass::AppendOneOfEveryQuadType(cc::ResourceProvider* resourceProvider) { void TestRenderPass::AppendOneOfEveryQuadType(cc::ResourceProvider* resourceProvider) {
gfx::Rect rect(0, 0, 100, 100); gfx::Rect rect(0, 0, 100, 100);
@ -28,7 +27,7 @@ void TestRenderPass::AppendOneOfEveryQuadType(cc::ResourceProvider* resourceProv
cc::ResourceProvider::ResourceId texture_resource = cc::ResourceProvider::ResourceId texture_resource =
resourceProvider->createResourceFromExternalTexture(1); resourceProvider->createResourceFromExternalTexture(1);
scoped_ptr<cc::SharedQuadState> shared_state = cc::SharedQuadState::Create(); scoped_ptr<cc::SharedQuadState> shared_state = cc::SharedQuadState::Create();
shared_state->SetAll(WebTransformationMatrix(), shared_state->SetAll(gfx::Transform(),
rect, rect,
rect, rect,
rect, rect,
@ -87,7 +86,7 @@ void TestRenderPass::AppendOneOfEveryQuadType(cc::ResourceProvider* resourceProv
rect, rect,
opaque_rect, opaque_rect,
1, 1,
WebKit::WebTransformationMatrix()); gfx::Transform());
AppendQuad(stream_video_quad.PassAs<DrawQuad>()); AppendQuad(stream_video_quad.PassAs<DrawQuad>());
scoped_ptr<cc::TextureDrawQuad> texture_quad = scoped_ptr<cc::TextureDrawQuad> texture_quad =

@ -86,7 +86,7 @@ private:
base::TimeTicks monotonicFrameBeginTime; base::TimeTicks monotonicFrameBeginTime;
scoped_ptr<ScrollAndScaleSet> scrollInfo; scoped_ptr<ScrollAndScaleSet> scrollInfo;
WebKit::WebTransformationMatrix implTransform; gfx::Transform implTransform;
PrioritizedResourceManager::BackingList evictedContentsTexturesBackings; PrioritizedResourceManager::BackingList evictedContentsTexturesBackings;
size_t memoryAllocationLimitBytes; size_t memoryAllocationLimitBytes;
}; };

@ -14,7 +14,6 @@
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
using namespace std; using namespace std;
using WebKit::WebTransformationMatrix;
namespace cc { 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); tile->updaterResource()->update(queue, sourceRect, destOffset, tile->partialUpdate, stats);
if (occlusion) if (occlusion)
occlusion->overdrawMetrics().didUpload(WebTransformationMatrix(), sourceRect, tile->opaqueRect()); occlusion->overdrawMetrics().didUpload(gfx::Transform(), sourceRect, tile->opaqueRect());
} }
} }

@ -20,7 +20,6 @@
#include "ui/gfx/quad_f.h" #include "ui/gfx/quad_f.h"
using namespace std; using namespace std;
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {

@ -7,7 +7,6 @@
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/layer_impl.h" #include "cc/layer_impl.h"
#include <public/WebTransformationMatrix.h>
namespace cc { namespace cc {

@ -18,10 +18,9 @@
#include "cc/test/tiled_layer_test_common.h" #include "cc/test/tiled_layer_test_common.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
using namespace WebKitTests; using namespace WebKitTests;
using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
namespace { namespace {
@ -1141,8 +1140,8 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms)
// This makes sure the painting works when the occluded region (in screen space) // This makes sure the painting works when the occluded region (in screen space)
// is transformed differently than the layer. // is transformed differently than the layer.
layer->setBounds(gfx::Size(600, 600)); layer->setBounds(gfx::Size(600, 600));
WebTransformationMatrix screenTransform; gfx::Transform screenTransform;
screenTransform.scale(0.5); screenTransform.Scale(0.5, 0.5);
layer->setScreenSpaceTransform(screenTransform); layer->setScreenSpaceTransform(screenTransform);
layer->setDrawTransform(screenTransform); layer->setDrawTransform(screenTransform);
@ -1173,8 +1172,9 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
layer->setContentsScale(0.5); layer->setContentsScale(0.5);
EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY()); EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY());
layer->setBounds(gfx::Size(600, 600)); layer->setBounds(gfx::Size(600, 600));
WebTransformationMatrix drawTransform; gfx::Transform drawTransform;
drawTransform.scale(1 / layer->contentsScaleX()); double invScaleFactor = 1 / layer->contentsScaleX();
drawTransform.Scale(invScaleFactor, invScaleFactor);
layer->setDrawTransform(drawTransform); layer->setDrawTransform(drawTransform);
layer->setScreenSpaceTransform(drawTransform); layer->setScreenSpaceTransform(drawTransform);
@ -1215,8 +1215,8 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
layer->fakeLayerUpdater()->clearUpdateCount(); layer->fakeLayerUpdater()->clearUpdateCount();
// This makes sure content scaling and transforms work together. // This makes sure content scaling and transforms work together.
WebTransformationMatrix screenTransform; gfx::Transform screenTransform;
screenTransform.scale(0.5); screenTransform.Scale(0.5, 0.5);
layer->setScreenSpaceTransform(screenTransform); layer->setScreenSpaceTransform(screenTransform);
layer->setDrawTransform(screenTransform); layer->setDrawTransform(screenTransform);

@ -7,6 +7,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "cc/io_surface_draw_quad.h" #include "cc/io_surface_draw_quad.h"
#include "cc/layer_tree_host_impl.h" #include "cc/layer_tree_host_impl.h"
#include "cc/math_util.h"
#include "cc/quad_sink.h" #include "cc/quad_sink.h"
#include "cc/resource_provider.h" #include "cc/resource_provider.h"
#include "cc/stream_video_draw_quad.h" #include "cc/stream_video_draw_quad.h"
@ -30,7 +31,7 @@ VideoLayerImpl::VideoLayerImpl(int id, WebKit::WebVideoFrameProvider* provider,
, m_externalTextureResource(0) , m_externalTextureResource(0)
{ {
// This matrix is the default transformation for stream textures, and flips on the Y axis. // 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, 1, 0, 0, 0,
0, -1, 0, 0, 0, -1, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0,
@ -252,8 +253,8 @@ void VideoLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuad
} }
case GL_TEXTURE_EXTERNAL_OES: { case GL_TEXTURE_EXTERNAL_OES: {
// StreamTexture hardware decoder. // StreamTexture hardware decoder.
WebKit::WebTransformationMatrix transform(m_streamTextureMatrix); gfx::Transform transform(m_streamTextureMatrix);
transform.scaleNonUniform(texWidthScale, texHeightScale); transform.Scale(texWidthScale, texHeightScale);
scoped_ptr<StreamVideoDrawQuad> streamVideoQuad = StreamVideoDrawQuad::Create(); scoped_ptr<StreamVideoDrawQuad> streamVideoQuad = StreamVideoDrawQuad::Create();
streamVideoQuad->SetNew(sharedQuadState, quadRect, opaqueRect, m_frame->texture_id(), transform); streamVideoQuad->SetNew(sharedQuadState, quadRect, opaqueRect, m_frame->texture_id(), transform);
quadSink.append(streamVideoQuad.PassAs<DrawQuad>(), appendQuadsData); quadSink.append(streamVideoQuad.PassAs<DrawQuad>(), appendQuadsData);
@ -401,7 +402,7 @@ void VideoLayerImpl::didReceiveFrame()
void VideoLayerImpl::didUpdateMatrix(const float matrix[16]) void VideoLayerImpl::didUpdateMatrix(const float matrix[16])
{ {
m_streamTextureMatrix = WebKit::WebTransformationMatrix( m_streamTextureMatrix = MathUtil::createGfxTransform(
matrix[0], matrix[1], matrix[2], matrix[3], matrix[0], matrix[1], matrix[2], matrix[3],
matrix[4], matrix[5], matrix[6], matrix[7], matrix[4], matrix[5], matrix[6], matrix[7],
matrix[8], matrix[9], matrix[10], matrix[11], matrix[8], matrix[9], matrix[10], matrix[11],

@ -5,6 +5,8 @@
#ifndef CC_VIDEO_LAYER_IMPL_H_ #ifndef CC_VIDEO_LAYER_IMPL_H_
#define CC_VIDEO_LAYER_IMPL_H_ #define CC_VIDEO_LAYER_IMPL_H_
#include <public/WebVideoFrameProvider.h>
#include "base/callback.h" #include "base/callback.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
@ -12,8 +14,7 @@
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2.h"
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
#include <public/WebTransformationMatrix.h> #include "ui/gfx/transform.h"
#include <public/WebVideoFrameProvider.h>
namespace WebKit { namespace WebKit {
class WebVideoFrame; class WebVideoFrame;
@ -80,7 +81,7 @@ private:
base::Lock m_providerLock; base::Lock m_providerLock;
WebKit::WebVideoFrameProvider* m_provider; WebKit::WebVideoFrameProvider* m_provider;
WebKit::WebTransformationMatrix m_streamTextureMatrix; gfx::Transform m_streamTextureMatrix;
FrameUnwrapper m_unwrapper; FrameUnwrapper m_unwrapper;
WebKit::WebVideoFrame *m_webFrame; WebKit::WebVideoFrame *m_webFrame;

@ -7,7 +7,7 @@
#include "content/public/common/common_param_traits.h" #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/WebData.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations.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 { namespace IPC {
@ -208,104 +208,108 @@ void ParamTraits<WebKit::WebFilterOperations>::Log(
l->append(")"); l->append(")");
} }
void ParamTraits<WebKit::WebTransformationMatrix>::Write( void ParamTraits<gfx::Transform>::Write(
Message* m, const param_type& p) { Message* m, const param_type& p) {
WriteParam(m, p.m11()); WriteParam(m, p.matrix().getDouble(0, 0));
WriteParam(m, p.m12()); WriteParam(m, p.matrix().getDouble(1, 0));
WriteParam(m, p.m13()); WriteParam(m, p.matrix().getDouble(2, 0));
WriteParam(m, p.m14()); WriteParam(m, p.matrix().getDouble(3, 0));
WriteParam(m, p.m21()); WriteParam(m, p.matrix().getDouble(0, 1));
WriteParam(m, p.m22()); WriteParam(m, p.matrix().getDouble(1, 1));
WriteParam(m, p.m23()); WriteParam(m, p.matrix().getDouble(2, 1));
WriteParam(m, p.m24()); WriteParam(m, p.matrix().getDouble(3, 1));
WriteParam(m, p.m31()); WriteParam(m, p.matrix().getDouble(0, 2));
WriteParam(m, p.m32()); WriteParam(m, p.matrix().getDouble(1, 2));
WriteParam(m, p.m33()); WriteParam(m, p.matrix().getDouble(2, 2));
WriteParam(m, p.m34()); WriteParam(m, p.matrix().getDouble(3, 2));
WriteParam(m, p.m41()); WriteParam(m, p.matrix().getDouble(0, 3));
WriteParam(m, p.m42()); WriteParam(m, p.matrix().getDouble(1, 3));
WriteParam(m, p.m43()); WriteParam(m, p.matrix().getDouble(2, 3));
WriteParam(m, p.m44()); 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) { 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, double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44; m41, m42, m43, m44;
bool success = bool success =
ReadParam(m, iter, &m11) && ReadParam(m, iter, &m11) &&
ReadParam(m, iter, &m12) &&
ReadParam(m, iter, &m13) &&
ReadParam(m, iter, &m14) &&
ReadParam(m, iter, &m21) && ReadParam(m, iter, &m21) &&
ReadParam(m, iter, &m22) &&
ReadParam(m, iter, &m23) &&
ReadParam(m, iter, &m24) &&
ReadParam(m, iter, &m31) && ReadParam(m, iter, &m31) &&
ReadParam(m, iter, &m32) &&
ReadParam(m, iter, &m33) &&
ReadParam(m, iter, &m34) &&
ReadParam(m, iter, &m41) && ReadParam(m, iter, &m41) &&
ReadParam(m, iter, &m12) &&
ReadParam(m, iter, &m22) &&
ReadParam(m, iter, &m32) &&
ReadParam(m, iter, &m42) && ReadParam(m, iter, &m42) &&
ReadParam(m, iter, &m13) &&
ReadParam(m, iter, &m23) &&
ReadParam(m, iter, &m33) &&
ReadParam(m, iter, &m43) && ReadParam(m, iter, &m43) &&
ReadParam(m, iter, &m14) &&
ReadParam(m, iter, &m24) &&
ReadParam(m, iter, &m34) &&
ReadParam(m, iter, &m44); ReadParam(m, iter, &m44);
if (success) { if (success) {
r->setM11(m11); r->matrix().setDouble(0, 0, m11);
r->setM12(m12); r->matrix().setDouble(1, 0, m21);
r->setM13(m13); r->matrix().setDouble(2, 0, m31);
r->setM14(m14); r->matrix().setDouble(3, 0, m41);
r->setM21(m21); r->matrix().setDouble(0, 1, m12);
r->setM22(m22); r->matrix().setDouble(1, 1, m22);
r->setM23(m23); r->matrix().setDouble(2, 1, m32);
r->setM24(m24); r->matrix().setDouble(3, 1, m42);
r->setM31(m31); r->matrix().setDouble(0, 2, m13);
r->setM32(m32); r->matrix().setDouble(1, 2, m23);
r->setM33(m33); r->matrix().setDouble(2, 2, m33);
r->setM34(m34); r->matrix().setDouble(3, 2, m43);
r->setM41(m41); r->matrix().setDouble(0, 3, m14);
r->setM42(m42); r->matrix().setDouble(1, 3, m24);
r->setM43(m43); r->matrix().setDouble(2, 3, m34);
r->setM44(m44); r->matrix().setDouble(3, 3, m44);
} }
return success; return success;
} }
void ParamTraits<WebKit::WebTransformationMatrix>::Log( void ParamTraits<gfx::Transform>::Log(
const param_type& p, std::string* l) { const param_type& p, std::string* l) {
l->append("("); l->append("(");
LogParam(p.m11(), l); LogParam(p.matrix().getDouble(0, 0), l);
l->append(", "); l->append(", ");
LogParam(p.m12(), l); LogParam(p.matrix().getDouble(1, 0), l);
l->append(", "); l->append(", ");
LogParam(p.m13(), l); LogParam(p.matrix().getDouble(2, 0), l);
l->append(", "); l->append(", ");
LogParam(p.m14(), l); LogParam(p.matrix().getDouble(3, 0), l);
l->append(", "); l->append(", ");
LogParam(p.m21(), l); LogParam(p.matrix().getDouble(0, 1), l);
l->append(", "); l->append(", ");
LogParam(p.m22(), l); LogParam(p.matrix().getDouble(1, 1), l);
l->append(", "); l->append(", ");
LogParam(p.m23(), l); LogParam(p.matrix().getDouble(2, 1), l);
l->append(", "); l->append(", ");
LogParam(p.m24(), l); LogParam(p.matrix().getDouble(3, 1), l);
l->append(", "); l->append(", ");
LogParam(p.m31(), l); LogParam(p.matrix().getDouble(0, 2), l);
l->append(", "); l->append(", ");
LogParam(p.m32(), l); LogParam(p.matrix().getDouble(1, 2), l);
l->append(", "); l->append(", ");
LogParam(p.m33(), l); LogParam(p.matrix().getDouble(2, 2), l);
l->append(", "); l->append(", ");
LogParam(p.m34(), l); LogParam(p.matrix().getDouble(3, 2), l);
l->append(", "); l->append(", ");
LogParam(p.m41(), l); LogParam(p.matrix().getDouble(0, 3), l);
l->append(", "); l->append(", ");
LogParam(p.m42(), l); LogParam(p.matrix().getDouble(1, 3), l);
l->append(", "); l->append(", ");
LogParam(p.m43(), l); LogParam(p.matrix().getDouble(2, 3), l);
l->append(", "); l->append(", ");
LogParam(p.m44(), l); LogParam(p.matrix().getDouble(3, 3), l);
l->append(") "); l->append(") ");
} }
@ -406,7 +410,7 @@ bool ParamTraits<cc::RenderPass>::Read(
cc::RenderPass::Id id(-1, -1); cc::RenderPass::Id id(-1, -1);
gfx::Rect output_rect; gfx::Rect output_rect;
gfx::RectF damage_rect; gfx::RectF damage_rect;
WebKit::WebTransformationMatrix transform_to_root_target; gfx::Transform transform_to_root_target;
bool has_transparent_background; bool has_transparent_background;
bool has_occlusion_from_outside_target_surface; bool has_occlusion_from_outside_target_surface;
WebKit::WebFilterOperations filters; WebKit::WebFilterOperations filters;

@ -24,10 +24,13 @@
#ifndef CONTENT_COMMON_CC_MESSAGES_H_ #ifndef CONTENT_COMMON_CC_MESSAGES_H_
#define CONTENT_COMMON_CC_MESSAGES_H_ #define CONTENT_COMMON_CC_MESSAGES_H_
namespace gfx {
class Transform;
}
namespace WebKit { namespace WebKit {
class WebData; class WebData;
class WebFilterOperations; class WebFilterOperations;
class WebTransformationMatrix;
} }
namespace IPC { namespace IPC {
@ -57,8 +60,8 @@ struct ParamTraits<WebKit::WebFilterOperations> {
}; };
template <> template <>
struct ParamTraits<WebKit::WebTransformationMatrix> { struct ParamTraits<gfx::Transform> {
typedef WebKit::WebTransformationMatrix param_type; typedef gfx::Transform param_type;
static void Write(Message* m, const param_type& p); static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, PickleIterator* iter, param_type* r); static bool Read(const Message* m, PickleIterator* iter, param_type* r);
static void Log(const param_type& p, std::string* l); static void Log(const param_type& p, std::string* l);

@ -23,9 +23,9 @@ using cc::TileDrawQuad;
using cc::StreamVideoDrawQuad; using cc::StreamVideoDrawQuad;
using cc::VideoLayerImpl; using cc::VideoLayerImpl;
using cc::YUVVideoDrawQuad; using cc::YUVVideoDrawQuad;
using gfx::Transform;
using WebKit::WebFilterOperation; using WebKit::WebFilterOperation;
using WebKit::WebFilterOperations; using WebKit::WebFilterOperations;
using WebKit::WebTransformationMatrix;
class CCMessagesTest : public testing::Test { class CCMessagesTest : public testing::Test {
protected: protected:
@ -173,10 +173,10 @@ class CCMessagesTest : public testing::Test {
TEST_F(CCMessagesTest, AllQuads) { TEST_F(CCMessagesTest, AllQuads) {
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
WebTransformationMatrix arbitrary_matrix; Transform arbitrary_matrix;
arbitrary_matrix.scale(3); arbitrary_matrix.Scale(3, 3);
arbitrary_matrix.translate(-5, 20); arbitrary_matrix.Translate(-5, 20);
arbitrary_matrix.rotate(15); arbitrary_matrix.Rotate(15);
gfx::Rect arbitrary_rect1(-5, 9, 3, 15); gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
gfx::Rect arbitrary_rect2(40, 23, 11, 7); gfx::Rect arbitrary_rect2(40, 23, 11, 7);
gfx::Rect arbitrary_rect3(7, -53, 22, 19); gfx::Rect arbitrary_rect3(7, -53, 22, 19);

@ -772,7 +772,7 @@ void Layer::RecomputeTransform() {
translate.Translate(bounds_.x(), bounds_.y()); translate.Translate(bounds_.x(), bounds_.y());
transform.ConcatTransform(translate); transform.ConcatTransform(translate);
transform.ConcatTransform(scale_translate); transform.ConcatTransform(scale_translate);
cc_layer_->setTransform(WebKit::WebTransformationMatrix(transform)); cc_layer_->setTransform(transform);
} }
void Layer::RecomputeDrawsContentAndUVRect() { void Layer::RecomputeDrawsContentAndUVRect() {

@ -23,42 +23,6 @@ using cc::Layer;
namespace WebKit { 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() WebLayer* WebLayer::create()
{ {
return new WebLayerImpl(); return new WebLayerImpl();
@ -203,32 +167,36 @@ WebFloatPoint WebLayerImpl::position() const
void WebLayerImpl::setSublayerTransform(const SkMatrix44& matrix) 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) void WebLayerImpl::setSublayerTransform(const WebTransformationMatrix& matrix)
{ {
m_layer->setSublayerTransform(matrix); m_layer->setSublayerTransform(matrix.toTransform());
} }
SkMatrix44 WebLayerImpl::sublayerTransform() const SkMatrix44 WebLayerImpl::sublayerTransform() const
{ {
return skMatrix44FromTransformationMatrix(m_layer->sublayerTransform()); return m_layer->sublayerTransform().matrix();
} }
void WebLayerImpl::setTransform(const SkMatrix44& 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) void WebLayerImpl::setTransform(const WebTransformationMatrix& matrix)
{ {
m_layer->setTransform(matrix); m_layer->setTransform(matrix.toTransform());
} }
SkMatrix44 WebLayerImpl::transform() const SkMatrix44 WebLayerImpl::transform() const
{ {
return skMatrix44FromTransformationMatrix(m_layer->transform()); return m_layer->transform().matrix();
} }
void WebLayerImpl::setDrawsContent(bool drawsContent) void WebLayerImpl::setDrawsContent(bool drawsContent)