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_
#define CC_ANIMATION_CURVE_H_
#include <public/WebTransformationMatrix.h>
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
#include <public/WebTransformationMatrix.h>
namespace cc {

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

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

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

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

@ -39,8 +39,8 @@ public:
gfx::RectF rootDamageRect;
WebKit::WebTransformationMatrix projectionMatrix;
WebKit::WebTransformationMatrix windowMatrix;
gfx::Transform projectionMatrix;
gfx::Transform windowMatrix;
bool flippedY;
};
@ -71,7 +71,7 @@ protected:
};
static gfx::RectF quadVertexRect();
static void quadRectTransform(WebKit::WebTransformationMatrix* quadRectTransform, const WebKit::WebTransformationMatrix& quadTransform, const gfx::RectF& quadRect);
static void quadRectTransform(gfx::Transform* quadRectTransform, const gfx::Transform& quadTransform, const gfx::RectF& quadRect);
static void initializeMatrices(DrawingFrame&, const gfx::Rect& drawRect, bool flipY);
static gfx::Rect moveScissorToWindowSpace(const DrawingFrame&, gfx::RectF scissorRect);
static gfx::RectF computeScissorRectForRenderPass(const DrawingFrame& frame);

@ -35,7 +35,7 @@ class CC_EXPORT DrawQuad {
const SharedQuadState* copied_shared_quad_state) const;
// TODO(danakj): Chromify or remove these SharedQuadState helpers.
const WebKit::WebTransformationMatrix& quadTransform() const { return shared_quad_state->content_to_target_transform; }
const gfx::Transform& quadTransform() const { return shared_quad_state->content_to_target_transform; }
gfx::Rect visibleContentRect() const { return shared_quad_state->visible_content_rect; }
gfx::Rect clippedRectInTarget() const { return shared_quad_state->clipped_rect_in_target; }
gfx::Rect clipRect() const { return shared_quad_state->clip_rect; }

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

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

@ -43,7 +43,6 @@ using namespace std;
using WebKit::WebGraphicsContext3D;
using WebKit::WebGraphicsMemoryAllocation;
using WebKit::WebSharedGraphicsContext3D;
using WebKit::WebTransformationMatrix;
namespace cc {
@ -329,9 +328,9 @@ void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde
// Use the full quadRect for debug quads to not move the edges based on partial swaps.
const gfx::Rect& layerRect = quad->rect;
WebTransformationMatrix renderMatrix = quad->quadTransform();
renderMatrix.translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerRect.height() + layerRect.y());
renderMatrix.scaleNonUniform(layerRect.width(), layerRect.height());
gfx::Transform renderMatrix = quad->quadTransform();
renderMatrix.Translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerRect.height() + layerRect.y());
renderMatrix.Scale(layerRect.width(), layerRect.height());
GLRenderer::toGLMatrix(&glMatrix[0], frame.projectionMatrix * renderMatrix);
GLC(context(), context()->uniformMatrix4fv(program->vertexShader().matrixLocation(), 1, false, &glMatrix[0]));
@ -435,8 +434,8 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
DrawingFrame& frame, const RenderPassDrawQuad* quad,
const WebKit::WebFilterOperations& filters,
const WebTransformationMatrix& contentsDeviceTransform,
const WebTransformationMatrix& contentsDeviceTransformInverse)
const gfx::Transform& contentsDeviceTransform,
const gfx::Transform& contentsDeviceTransformInverse)
{
// This method draws a background filter, which applies a filter to any pixels behind the quad and seen through its background.
// The algorithm works as follows:
@ -492,10 +491,10 @@ scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
if (usingBackgroundTexture) {
// Copy the readback pixels from device to the background texture for the surface.
WebTransformationMatrix deviceToFramebufferTransform;
deviceToFramebufferTransform.translate(quad->rect.width() / 2.0, quad->rect.height() / 2.0);
deviceToFramebufferTransform.scale3d(quad->rect.width(), quad->rect.height(), 1);
deviceToFramebufferTransform.multiply(contentsDeviceTransformInverse);
gfx::Transform deviceToFramebufferTransform;
deviceToFramebufferTransform.Translate(quad->rect.width() / 2.0, quad->rect.height() / 2.0);
deviceToFramebufferTransform.Scale3d(quad->rect.width(), quad->rect.height(), 1);
deviceToFramebufferTransform.PreconcatTransform(contentsDeviceTransformInverse);
copyTextureToFramebuffer(frame, filteredDeviceBackgroundTextureId, deviceRect, deviceToFramebufferTransform);
}
@ -517,15 +516,15 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
if (!renderPass)
return;
WebTransformationMatrix quadRectMatrix;
gfx::Transform quadRectMatrix;
quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect);
WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * frame.projectionMatrix * quadRectMatrix).to2dTransform();
gfx::Transform contentsDeviceTransform = MathUtil::to2dTransform(frame.windowMatrix * frame.projectionMatrix * quadRectMatrix);
// Can only draw surface if device matrix is invertible.
if (!contentsDeviceTransform.isInvertible())
if (!contentsDeviceTransform.IsInvertible())
return;
WebTransformationMatrix contentsDeviceTransformInverse = contentsDeviceTransform.inverse();
gfx::Transform contentsDeviceTransformInverse = MathUtil::inverse(contentsDeviceTransform);
scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters(
frame, quad, renderPass->background_filters,
contentsDeviceTransform, contentsDeviceTransformInverse);
@ -749,8 +748,8 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua
gfx::QuadF localQuad;
WebTransformationMatrix deviceTransform = WebTransformationMatrix(frame.windowMatrix * frame.projectionMatrix * quad->quadTransform()).to2dTransform();
if (!deviceTransform.isInvertible())
gfx::Transform deviceTransform = MathUtil::to2dTransform(frame.windowMatrix * frame.projectionMatrix * quad->quadTransform());
if (!deviceTransform.IsInvertible())
return;
bool clipped = false;
@ -840,7 +839,7 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua
LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge);
// Map device space quad to local space. deviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to project.
WebTransformationMatrix deviceTransformInverse = deviceTransform.inverse();
gfx::Transform deviceTransformInverse = MathUtil::inverse(deviceTransform);
localQuad = MathUtil::mapQuad(deviceTransformInverse, deviceQuad.ToQuadF(), clipped);
// We should not DCHECK(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become
@ -1063,24 +1062,9 @@ void GLRenderer::ensureScissorTestDisabled()
m_isScissorEnabled = false;
}
void GLRenderer::toGLMatrix(float* flattened, const WebTransformationMatrix& m)
void GLRenderer::toGLMatrix(float* glMatrix, const gfx::Transform& transform)
{
flattened[0] = m.m11();
flattened[1] = m.m12();
flattened[2] = m.m13();
flattened[3] = m.m14();
flattened[4] = m.m21();
flattened[5] = m.m22();
flattened[6] = m.m23();
flattened[7] = m.m24();
flattened[8] = m.m31();
flattened[9] = m.m32();
flattened[10] = m.m33();
flattened[11] = m.m34();
flattened[12] = m.m41();
flattened[13] = m.m42();
flattened[14] = m.m43();
flattened[15] = m.m44();
transform.matrix().asColMajorf(glMatrix);
}
void GLRenderer::setShaderQuadF(const gfx::QuadF& quad, int quadLocation)
@ -1106,9 +1090,9 @@ void GLRenderer::setShaderOpacity(float opacity, int alphaLocation)
GLC(m_context, m_context->uniform1f(alphaLocation, opacity));
}
void GLRenderer::drawQuadGeometry(const DrawingFrame& frame, const WebKit::WebTransformationMatrix& drawTransform, const gfx::RectF& quadRect, int matrixLocation)
void GLRenderer::drawQuadGeometry(const DrawingFrame& frame, const gfx::Transform& drawTransform, const gfx::RectF& quadRect, int matrixLocation)
{
WebTransformationMatrix quadRectMatrix;
gfx::Transform quadRectMatrix;
quadRectTransform(&quadRectMatrix, drawTransform, quadRect);
static float glMatrix[16];
toGLMatrix(&glMatrix[0], frame.projectionMatrix * quadRectMatrix);
@ -1117,7 +1101,7 @@ void GLRenderer::drawQuadGeometry(const DrawingFrame& frame, const WebKit::WebTr
GLC(m_context, m_context->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
}
void GLRenderer::copyTextureToFramebuffer(const DrawingFrame& frame, int textureId, const gfx::Rect& rect, const WebTransformationMatrix& drawMatrix)
void GLRenderer::copyTextureToFramebuffer(const DrawingFrame& frame, int textureId, const gfx::Rect& rect, const gfx::Transform& drawMatrix)
{
const RenderPassProgram* program = renderPassProgram();

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

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

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

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

@ -5,6 +5,10 @@
#ifndef CC_LAYER_H_
#define CC_LAYER_H_
#include <public/WebFilterOperations.h>
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "cc/cc_export.h"
#include "cc/layer_animation_controller.h"
@ -14,10 +18,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h"
#include <public/WebFilterOperations.h>
#include <public/WebTransformationMatrix.h>
#include <string>
#include <vector>
#include "ui/gfx/transform.h"
namespace WebKit {
class WebAnimationDelegate;
@ -51,11 +52,11 @@ public:
virtual int id() const OVERRIDE;
virtual void setOpacityFromAnimation(float) OVERRIDE;
virtual float opacity() const OVERRIDE;
virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix&) OVERRIDE;
virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE;
// A layer's transform operates layer space. That is, entirely in logical,
// non-page-scaled pixels (that is, they have page zoom baked in, but not page scale).
// The root layer is a special case -- it operates in physical pixels.
virtual const WebKit::WebTransformationMatrix& transform() const OVERRIDE;
virtual const gfx::Transform& transform() const OVERRIDE;
Layer* rootLayer();
Layer* parent() { return m_parent; }
@ -121,10 +122,10 @@ public:
void setFixedToContainerLayer(bool);
bool fixedToContainerLayer() const { return m_fixedToContainerLayer; }
void setSublayerTransform(const WebKit::WebTransformationMatrix&);
const WebKit::WebTransformationMatrix& sublayerTransform() const { return m_sublayerTransform; }
void setSublayerTransform(const gfx::Transform&);
const gfx::Transform& sublayerTransform() const { return m_sublayerTransform; }
void setTransform(const WebKit::WebTransformationMatrix&);
void setTransform(const gfx::Transform&);
bool transformIsAnimating() const;
const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; }
@ -163,8 +164,8 @@ public:
gfx::Vector2d scrollDelta() const { return gfx::Vector2d(); }
void setImplTransform(const WebKit::WebTransformationMatrix&);
const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; }
void setImplTransform(const gfx::Transform&);
const gfx::Transform& implTransform() const { return m_implTransform; }
void setDoubleSided(bool);
bool doubleSided() const { return m_doubleSided; }
@ -225,12 +226,12 @@ public:
// This moves from layer space, with origin in the center to target space with origin in the top left.
// That is, it converts from logical, non-page-scaled, to target pixels (and if the target is the
// root render surface, then this converts to physical pixels).
const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; }
void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_drawTransform = matrix; }
const gfx::Transform& drawTransform() const { return m_drawTransform; }
void setDrawTransform(const gfx::Transform& matrix) { m_drawTransform = matrix; }
// This moves from content space, with origin the top left to screen space with origin in the top left.
// It converts logical, non-page-scaled pixels to physical pixels.
const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; }
void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix) { m_screenSpaceTransform = matrix; }
const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
void setScreenSpaceTransform(const gfx::Transform& matrix) { m_screenSpaceTransform = matrix; }
bool isClipped() const { return m_isClipped; }
void setIsClipped(bool isClipped) { m_isClipped = isClipped; }
@ -386,8 +387,8 @@ private:
bool m_drawCheckerboardForMissingTiles;
bool m_forceRenderSurface;
WebKit::WebTransformationMatrix m_transform;
WebKit::WebTransformationMatrix m_sublayerTransform;
gfx::Transform m_transform;
gfx::Transform m_sublayerTransform;
// Replica layer used for reflections.
scoped_refptr<Layer> m_replicaLayer;
@ -399,8 +400,8 @@ private:
Layer* m_renderTarget;
WebKit::WebTransformationMatrix m_drawTransform;
WebKit::WebTransformationMatrix m_screenSpaceTransform;
gfx::Transform m_drawTransform;
gfx::Transform m_screenSpaceTransform;
bool m_drawTransformIsAnimating;
bool m_screenSpaceTransformIsAnimating;
@ -415,7 +416,7 @@ private:
bool m_automaticallyComputeRasterScale;
bool m_boundsContainPageScale;
WebKit::WebTransformationMatrix m_implTransform;
gfx::Transform m_implTransform;
WebKit::WebAnimationDelegate* m_layerAnimationDelegate;
WebKit::WebLayerScrollClient* m_layerScrollClient;

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

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

@ -9,17 +9,16 @@
#include "cc/test/animation_test_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h>
#include "ui/gfx/transform.h"
using namespace WebKitTests;
using WebKit::WebTransformationMatrix;
namespace cc {
namespace {
void expectTranslateX(double translateX, const WebTransformationMatrix& matrix)
void expectTranslateX(double translateX, const gfx::Transform& matrix)
{
EXPECT_FLOAT_EQ(translateX, matrix.m41());
EXPECT_FLOAT_EQ(translateX, matrix.matrix().getDouble(0, 3));
}
scoped_ptr<ActiveAnimation> createActiveAnimation(scoped_ptr<AnimationCurve> curve, int id, ActiveAnimation::TargetProperty property)

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

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

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

@ -8,9 +8,8 @@
#include "cc/layer_tree_host_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h>
#include "ui/gfx/transform.h"
using WebKit::WebTransformationMatrix;
using ::testing::Mock;
using ::testing::_;
using ::testing::AtLeast;

@ -12,10 +12,9 @@
#include "base/logging.h"
#include "cc/math_util.h"
#include "cc/render_surface_impl.h"
#include <public/WebTransformationMatrix.h>
#include "ui/gfx/transform.h"
using namespace std;
using WebKit::WebTransformationMatrix;
namespace cc {
@ -146,7 +145,7 @@ LayerShape::LayerShape()
{
}
LayerShape::LayerShape(float width, float height, const WebTransformationMatrix& drawTransform)
LayerShape::LayerShape(float width, float height, const gfx::Transform& drawTransform)
{
gfx::QuadF layerQuad(gfx::RectF(0, 0, width, height));
@ -230,7 +229,7 @@ void LayerSorter::createGraphNodes(LayerList::iterator first, LayerList::iterato
DVLOG(2) << "Layer " << node.layer->id() << " (" << node.layer->bounds().width() << " x " << node.layer->bounds().height() << ")";
WebTransformationMatrix drawTransform;
gfx::Transform drawTransform;
float layerWidth, layerHeight;
if (renderSurface) {
drawTransform = renderSurface->drawTransform();

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

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

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

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

@ -4,6 +4,8 @@
#include "cc/layer_tree_host_common.h"
#include <algorithm>
#include "cc/layer.h"
#include "cc/layer_impl.h"
#include "cc/layer_iterator.h"
@ -13,10 +15,7 @@
#include "cc/render_surface_impl.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect_conversions.h"
#include <algorithm>
#include <public/WebTransformationMatrix.h>
using WebKit::WebTransformationMatrix;
#include "ui/gfx/transform.h"
namespace cc {
@ -28,7 +27,7 @@ ScrollAndScaleSet::~ScrollAndScaleSet()
{
}
gfx::Rect LayerTreeHostCommon::calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const WebTransformationMatrix& transform)
gfx::Rect LayerTreeHostCommon::calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const gfx::Transform& transform)
{
// Is this layer fully contained within the target surface?
gfx::Rect layerInSurfaceSpace = MathUtil::mapClippedRect(transform, layerBoundRect);
@ -45,7 +44,7 @@ gfx::Rect LayerTreeHostCommon::calculateVisibleRect(const gfx::Rect& targetSurfa
// This bounding rectangle may be larger than it needs to be (being
// axis-aligned), but is a reasonable filter on the space to consider.
// Non-invertible transforms will create an empty rect here.
const WebTransformationMatrix surfaceToLayer = transform.inverse();
const gfx::Transform surfaceToLayer = MathUtil::inverse(transform);
gfx::Rect layerRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(surfaceToLayer, gfx::RectF(minimalSurfaceRect)));
layerRect.Intersect(layerBoundRect);
return layerRect;
@ -86,21 +85,21 @@ static bool isLayerBackFaceVisible(LayerType* layer)
// rendering context by checking if the parent preserves 3d.
if (layerIsInExisting3DRenderingContext(layer))
return layer->drawTransform().isBackFaceVisible();
return MathUtil::isBackFaceVisible(layer->drawTransform());
// In this case, either the layer establishes a new 3d rendering context, or is not in
// a 3d rendering context at all.
return layer->transform().isBackFaceVisible();
return MathUtil::isBackFaceVisible(layer->transform());
}
template<typename LayerType>
static bool isSurfaceBackFaceVisible(LayerType* layer, const WebTransformationMatrix& drawTransform)
static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& drawTransform)
{
if (layerIsInExisting3DRenderingContext(layer))
return drawTransform.isBackFaceVisible();
return MathUtil::isBackFaceVisible(drawTransform);
if (isRootLayerOfNewRenderingContext(layer))
return layer->transform().isBackFaceVisible();
return MathUtil::isBackFaceVisible(layer->transform());
// If the renderSurface is not part of a new or existing rendering context, then the
// layers that contribute to this surface will decide back-face visibility for themselves.
@ -131,7 +130,7 @@ static gfx::Rect calculateVisibleContentRect(LayerType* layer)
// In this case the target surface does clip layers that contribute to it. So, we
// have convert the current surface's clipRect from its ancestor surface space to
// the current surface space.
targetSurfaceClipRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(layer->renderTarget()->renderSurface()->drawTransform().inverse(), layer->renderTarget()->renderSurface()->clipRect()));
targetSurfaceClipRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(MathUtil::inverse(layer->renderTarget()->renderSurface()->drawTransform()), layer->renderTarget()->renderSurface()->clipRect()));
targetSurfaceClipRect.Intersect(layer->drawableContentRect());
}
@ -141,12 +140,12 @@ static gfx::Rect calculateVisibleContentRect(LayerType* layer)
return LayerTreeHostCommon::calculateVisibleRect(targetSurfaceClipRect, gfx::Rect(gfx::Point(), layer->contentBounds()), layer->drawTransform());
}
static bool isScaleOrTranslation(const WebTransformationMatrix& m)
static bool isScaleOrTranslation(const gfx::Transform& m)
{
return !m.m12() && !m.m13() && !m.m14()
&& !m.m21() && !m.m23() && !m.m24()
&& !m.m31() && !m.m32() && !m.m43()
&& m.m44();
return !m.matrix().getDouble(1, 0) && !m.matrix().getDouble(2, 0) && !m.matrix().getDouble(3, 0)
&& !m.matrix().getDouble(0, 1) && !m.matrix().getDouble(2, 1) && !m.matrix().getDouble(3, 1)
&& !m.matrix().getDouble(0, 2) && !m.matrix().getDouble(1, 2) && !m.matrix().getDouble(2, 3)
&& m.matrix().getDouble(3, 3);
}
static inline bool transformToParentIsKnown(LayerImpl*)
@ -265,7 +264,7 @@ static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
return false;
}
WebTransformationMatrix computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer, const WebTransformationMatrix& parentMatrix)
gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer, const gfx::Transform& parentMatrix)
{
// For every layer that has non-zero scrollDelta, we have to compute a transform that can undo the
// scrollDelta translation. In particular, we want this matrix to premultiply a fixed-position layer's
@ -284,23 +283,23 @@ WebTransformationMatrix computeScrollCompensationForThisLayer(LayerImpl* scrolli
// that fixed position layer is fixed onto the same renderTarget as this scrollingLayer.
//
WebTransformationMatrix partialLayerOriginTransform = parentMatrix;
partialLayerOriginTransform.multiply(scrollingLayer->implTransform());
gfx::Transform partialLayerOriginTransform = parentMatrix;
partialLayerOriginTransform.PreconcatTransform(scrollingLayer->implTransform());
WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3
scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // Step 2
scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse()); // Step 1
gfx::Transform scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3
scrollCompensationForThisLayer.Translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // Step 2
scrollCompensationForThisLayer.PreconcatTransform(MathUtil::inverse(partialLayerOriginTransform)); // Step 1
return scrollCompensationForThisLayer;
}
WebTransformationMatrix computeScrollCompensationMatrixForChildren(Layer* currentLayer, const WebTransformationMatrix& currentParentMatrix, const WebTransformationMatrix& currentScrollCompensation)
gfx::Transform computeScrollCompensationMatrixForChildren(Layer* currentLayer, const gfx::Transform& currentParentMatrix, const gfx::Transform& currentScrollCompensation)
{
// The main thread (i.e. Layer) does not need to worry about scroll compensation.
// So we can just return an identity matrix here.
return WebTransformationMatrix();
return gfx::Transform();
}
WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* layer, const WebTransformationMatrix& parentMatrix, const WebTransformationMatrix& currentScrollCompensationMatrix)
gfx::Transform computeScrollCompensationMatrixForChildren(LayerImpl* layer, const gfx::Transform& parentMatrix, const gfx::Transform& currentScrollCompensationMatrix)
{
// "Total scroll compensation" is the transform needed to cancel out all scrollDelta translations that
// occurred since the nearest container layer, even if there are renderSurfaces in-between.
@ -323,7 +322,7 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
return currentScrollCompensationMatrix;
// Start as identity matrix.
WebTransformationMatrix nextScrollCompensationMatrix;
gfx::Transform nextScrollCompensationMatrix;
// If this layer is not a container, then it inherits the existing scroll compensations.
if (!layer->isContainerForFixedPositionLayers())
@ -332,8 +331,8 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
// If the current layer has a non-zero scrollDelta, then we should compute its local scrollCompensation
// and accumulate it to the nextScrollCompensationMatrix.
if (!layer->scrollDelta().IsZero()) {
WebTransformationMatrix scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix);
nextScrollCompensationMatrix.multiply(scrollCompensationForThisLayer);
gfx::Transform scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix);
nextScrollCompensationMatrix.PreconcatTransform(scrollCompensationForThisLayer);
}
// If the layer created its own renderSurface, we have to adjust nextScrollCompensationMatrix.
@ -341,16 +340,16 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
// Step 1 (right-most in the math): transform from the new surface to the original ancestor surface
// Step 2: apply the scroll compensation
// Step 3: transform back to the new surface.
if (layer->renderSurface() && !nextScrollCompensationMatrix.isIdentity())
nextScrollCompensationMatrix = layer->renderSurface()->drawTransform().inverse() * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform();
if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity())
nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()->drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform();
return nextScrollCompensationMatrix;
}
// There is no contentsScale on impl thread.
static inline void updateLayerContentsScale(LayerImpl*, const WebTransformationMatrix&, float, float, bool) { }
static inline void updateLayerContentsScale(LayerImpl*, const gfx::Transform&, float, float, bool) { }
static inline void updateLayerContentsScale(Layer* layer, const WebTransformationMatrix& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatingTransformToScreen)
static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatingTransformToScreen)
{
float rasterScale = layer->rasterScale();
if (!rasterScale) {
@ -387,8 +386,8 @@ static inline void updateLayerContentsScale(Layer* layer, const WebTransformatio
// Recursively walks the layer tree starting at the given node and computes all the
// necessary transformations, clipRects, render surfaces, etc.
template<typename LayerType, typename LayerList, typename RenderSurfaceType, typename LayerSorter>
static void calculateDrawTransformsInternal(LayerType* layer, const WebTransformationMatrix& parentMatrix,
const WebTransformationMatrix& fullHierarchyMatrix, const WebTransformationMatrix& currentScrollCompensationMatrix,
static void calculateDrawTransformsInternal(LayerType* layer, const gfx::Transform& parentMatrix,
const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScrollCompensationMatrix,
const gfx::Rect& clipRectFromAncestor, bool ancestorClipsSubtree,
RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceLayerList, LayerList& layerList,
LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, gfx::Rect& drawableContentRectOfSubtree)
@ -405,7 +404,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// projection applied at draw time flips the Y axis appropriately.
//
// 2. The anchor point, when given as a PointF object, is specified in "unit layer space",
// where the bounds of the layer map to [0, 1]. However, as a WebTransformationMatrix object,
// where the bounds of the layer map to [0, 1]. However, as a Transform object,
// the transform to the anchor point is specified in "layer space", where the bounds
// of the layer map to [bounds.width(), bounds.height()].
//
@ -458,7 +457,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// S is the scale adjustment (to scale up a canonical quad to the layer's size)
//
// When a render surface has a replica layer, that layer's transform is used to draw a second copy of the surface.
// Transforms named here are relative to the surface, unless they specify they are relative to the replica layer.
// gfx::Transforms named here are relative to the surface, unless they specify they are relative to the replica layer.
//
// We will denote a scale by device scale S[deviceScale]
//
@ -503,16 +502,16 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
gfx::PointF anchorPoint = layer->anchorPoint();
gfx::PointF position = layer->position() - layer->scrollDelta();
WebTransformationMatrix layerLocalTransform;
gfx::Transform layerLocalTransform;
// LT = Tr[origin] * Tr[origin2anchor]
layerLocalTransform.translate3d(position.x() + anchorPoint.x() * bounds.width(), position.y() + anchorPoint.y() * bounds.height(), layer->anchorPointZ());
layerLocalTransform.Translate3d(position.x() + anchorPoint.x() * bounds.width(), position.y() + anchorPoint.y() * bounds.height(), layer->anchorPointZ());
// LT = Tr[origin] * Tr[origin2anchor] * M[layer]
layerLocalTransform.multiply(layer->transform());
layerLocalTransform.PreconcatTransform(layer->transform());
// LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin]
layerLocalTransform.translate3d(-anchorPoint.x() * bounds.width(), -anchorPoint.y() * bounds.height(), -layer->anchorPointZ());
layerLocalTransform.Translate3d(-anchorPoint.x() * bounds.width(), -anchorPoint.y() * bounds.height(), -layer->anchorPointZ());
WebTransformationMatrix combinedTransform = parentMatrix;
combinedTransform.multiply(layerLocalTransform);
gfx::Transform combinedTransform = parentMatrix;
combinedTransform.PreconcatTransform(layerLocalTransform);
// The layer's contentsSize is determined from the combinedTransform, which then informs the
// layer's drawTransform.
@ -531,23 +530,23 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// The drawTransform that gets computed below is effectively the layer's drawTransform, unless
// the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms.
WebTransformationMatrix drawTransform = combinedTransform;
gfx::Transform drawTransform = combinedTransform;
// M[draw] = M[parent] * LT * S[layer2content]
drawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
drawTransform.Scale(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
// layerScreenSpaceTransform represents the transform between root layer's "screen space" and local content space.
WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix;
gfx::Transform layerScreenSpaceTransform = fullHierarchyMatrix;
if (!layer->preserves3D())
MathUtil::flattenTransformTo2d(layerScreenSpaceTransform);
layerScreenSpaceTransform.multiply(drawTransform);
layerScreenSpaceTransform.PreconcatTransform(drawTransform);
layer->setScreenSpaceTransform(layerScreenSpaceTransform);
gfx::RectF contentRect(gfx::PointF(), layer->contentBounds());
// fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurfaceImpl's space.
// nextHierarchyMatrix will only change if this layer uses a new RenderSurfaceImpl, otherwise remains the same.
WebTransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix;
WebTransformationMatrix sublayerMatrix;
gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix;
gfx::Transform sublayerMatrix;
gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::computeTransform2dScaleComponents(combinedTransform);
@ -564,21 +563,21 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// The owning layer's draw transform has a scale from content to layer space which we need to undo and
// replace with a scale from the surface's subtree into layer space.
drawTransform.scaleNonUniform(layer->contentsScaleX(), layer->contentsScaleY());
drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
drawTransform.Scale(layer->contentsScaleX(), layer->contentsScaleY());
drawTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
renderSurface->setDrawTransform(drawTransform);
// The origin of the new surface is the upper left corner of the layer.
WebTransformationMatrix layerDrawTransform;
layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
layerDrawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
gfx::Transform layerDrawTransform;
layerDrawTransform.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
layerDrawTransform.Scale(1.0 / layer->contentsScaleX(), 1.0 / layer->contentsScaleY());
layer->setDrawTransform(layerDrawTransform);
// Inside the surface's subtree, we scale everything to the owning layer's scale.
// The sublayer matrix transforms centered layer rects into target
// surface content space.
sublayerMatrix.makeIdentity();
sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
sublayerMatrix.MakeIdentity();
sublayerMatrix.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
// The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity.
renderSurface->setDrawOpacity(drawOpacity);
@ -594,7 +593,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// Update the aggregate hierarchy matrix to include the transform of the
// newly created RenderSurfaceImpl.
nextHierarchyMatrix.multiply(renderSurface->drawTransform());
nextHierarchyMatrix.PreconcatTransform(renderSurface->drawTransform());
// The new renderSurface here will correctly clip the entire subtree. So, we do
// not need to continue propagating the clipping state further down the tree. This
@ -665,9 +664,9 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
MathUtil::flattenTransformTo2d(sublayerMatrix);
// Apply the sublayer transform at the center of the layer.
sublayerMatrix.translate(0.5 * bounds.width(), 0.5 * bounds.height());
sublayerMatrix.multiply(layer->sublayerTransform());
sublayerMatrix.translate(-0.5 * bounds.width(), -0.5 * bounds.height());
sublayerMatrix.Translate(0.5 * bounds.width(), 0.5 * bounds.height());
sublayerMatrix.PreconcatTransform(layer->sublayerTransform());
sublayerMatrix.Translate(-0.5 * bounds.width(), -0.5 * bounds.height());
LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->layerList() : layerList);
@ -677,7 +676,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
if (!layerShouldBeSkipped(layer))
descendants.push_back(layer);
WebTransformationMatrix nextScrollCompensationMatrix = computeScrollCompensationMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);;
gfx::Transform nextScrollCompensationMatrix = computeScrollCompensationMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);;
gfx::Rect accumulatedDrawableContentRectOfChildren;
for (size_t i = 0; i < layer->children().size(); ++i) {
@ -756,26 +755,26 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// The owning layer's screenSpaceTransform has a scale from content to layer space which we need to undo and
// replace with a scale from the surface's subtree into layer space.
WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransform();
screenSpaceTransform.scaleNonUniform(layer->contentsScaleX(), layer->contentsScaleY());
screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
gfx::Transform screenSpaceTransform = layer->screenSpaceTransform();
screenSpaceTransform.Scale(layer->contentsScaleX(), layer->contentsScaleY());
screenSpaceTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
renderSurface->setScreenSpaceTransform(screenSpaceTransform);
if (layer->replicaLayer()) {
WebTransformationMatrix surfaceOriginToReplicaOriginTransform;
surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer()->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(),
gfx::Transform surfaceOriginToReplicaOriginTransform;
surfaceOriginToReplicaOriginTransform.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
surfaceOriginToReplicaOriginTransform.Translate(layer->replicaLayer()->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(),
layer->replicaLayer()->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height());
surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()->transform());
surfaceOriginToReplicaOriginTransform.translate(-layer->replicaLayer()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y() * bounds.height());
surfaceOriginToReplicaOriginTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
surfaceOriginToReplicaOriginTransform.PreconcatTransform(layer->replicaLayer()->transform());
surfaceOriginToReplicaOriginTransform.Translate(-layer->replicaLayer()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y() * bounds.height());
surfaceOriginToReplicaOriginTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y());
// Compute the replica's "originTransform" that maps from the replica's origin space to the target surface origin space.
WebTransformationMatrix replicaOriginTransform = layer->renderSurface()->drawTransform() * surfaceOriginToReplicaOriginTransform;
gfx::Transform replicaOriginTransform = layer->renderSurface()->drawTransform() * surfaceOriginToReplicaOriginTransform;
renderSurface->setReplicaDrawTransform(replicaOriginTransform);
// Compute the replica's "screenSpaceTransform" that maps from the replica's origin space to the screen's origin space.
WebTransformationMatrix replicaScreenSpaceTransform = layer->renderSurface()->screenSpaceTransform() * surfaceOriginToReplicaOriginTransform;
gfx::Transform replicaScreenSpaceTransform = layer->renderSurface()->screenSpaceTransform() * surfaceOriginToReplicaOriginTransform;
renderSurface->setReplicaScreenSpaceTransform(replicaScreenSpaceTransform);
}
@ -819,9 +818,9 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerList)
{
gfx::Rect totalDrawableContentRect;
WebTransformationMatrix identityMatrix;
WebTransformationMatrix deviceScaleTransform;
deviceScaleTransform.scale(deviceScaleFactor);
gfx::Transform identityMatrix;
gfx::Transform deviceScaleTransform;
deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor);
std::vector<scoped_refptr<Layer> > dummyLayerList;
// The root layer's renderSurface should receive the deviceViewport as the initial clipRect.
@ -846,9 +845,9 @@ void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const gfx::S
void LayerTreeHostCommon::calculateDrawTransforms(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, LayerSorter* layerSorter, int maxTextureSize, std::vector<LayerImpl*>& renderSurfaceLayerList)
{
gfx::Rect totalDrawableContentRect;
WebTransformationMatrix identityMatrix;
WebTransformationMatrix deviceScaleTransform;
deviceScaleTransform.scale(deviceScaleFactor);
gfx::Transform identityMatrix;
gfx::Transform deviceScaleTransform;
deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor);
std::vector<LayerImpl*> dummyLayerList;
// The root layer's renderSurface should receive the deviceViewport as the initial clipRect.
@ -870,15 +869,15 @@ void LayerTreeHostCommon::calculateDrawTransforms(LayerImpl* rootLayer, const gf
DCHECK(rootLayer->renderSurface());
}
static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const WebTransformationMatrix& localSpaceToScreenSpaceTransform, gfx::RectF localSpaceRect)
static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const gfx::Transform& localSpaceToScreenSpaceTransform, gfx::RectF localSpaceRect)
{
// If the transform is not invertible, then assume that this point doesn't hit this rect.
if (!localSpaceToScreenSpaceTransform.isInvertible())
if (!localSpaceToScreenSpaceTransform.IsInvertible())
return false;
// Transform the hit test point from screen space to the local space of the given rect.
bool clipped = false;
gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(localSpaceToScreenSpaceTransform.inverse(), screenSpacePoint, clipped);
gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(MathUtil::inverse(localSpaceToScreenSpaceTransform), screenSpacePoint, clipped);
// If projectPoint could not project to a valid value, then we assume that this point doesn't hit this rect.
if (clipped)
@ -887,15 +886,15 @@ static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const WebTransfor
return localSpaceRect.Contains(hitTestPointInLocalSpace);
}
static bool pointHitsRegion(gfx::PointF screenSpacePoint, const WebTransformationMatrix& screenSpaceTransform, const Region& layerSpaceRegion, float layerContentScaleX, float layerContentScaleY)
static bool pointHitsRegion(gfx::PointF screenSpacePoint, const gfx::Transform& screenSpaceTransform, const Region& layerSpaceRegion, float layerContentScaleX, float layerContentScaleY)
{
// If the transform is not invertible, then assume that this point doesn't hit this region.
if (!screenSpaceTransform.isInvertible())
if (!screenSpaceTransform.IsInvertible())
return false;
// Transform the hit test point from screen space to the local space of the given region.
bool clipped = false;
gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(screenSpaceTransform.inverse(), screenSpacePoint, clipped);
gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(MathUtil::inverse(screenSpaceTransform), screenSpacePoint, clipped);
gfx::PointF hitTestPointInLayerSpace = gfx::ScalePoint(hitTestPointInContentSpace, 1 / layerContentScaleX, 1 / layerContentScaleY);
// If projectPoint could not project to a valid value, then we assume that this point doesn't hit this region.

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

File diff suppressed because it is too large Load Diff

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

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

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

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

@ -8,16 +8,16 @@
#include "cc/layer_impl.h"
#include "cc/layer_painter.h"
#include "cc/layer_tree_host.h"
#include "cc/math_util.h"
#include "cc/single_thread_proxy.h"
#include "cc/thread.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/geometry_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h>
#include "ui/gfx/transform.h"
using namespace WebKitTests;
using WebKit::WebTransformationMatrix;
using ::testing::Mock;
using ::testing::_;
using ::testing::AtLeast;
@ -505,8 +505,8 @@ TEST_F(LayerTest, checkPropertyChangeCausesCorrectBehavior)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUseLCDText(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setRenderTarget(0));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(WebTransformationMatrix()));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(WebTransformationMatrix()));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(gfx::Transform()));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(gfx::Transform()));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableContentRect(gfx::Rect(4, 5, 6, 7)));
EXPECT_FALSE(testLayer->needsDisplay());
@ -521,13 +521,13 @@ TEST_F(LayerTest, checkPropertyChangeCausesCorrectBehavior)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsOpaque(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(gfx::PointF(4, 9)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get()));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(MathUtil::createGfxTransform(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOnMainThread(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNonFastScrollableRegion(gfx::Rect(1, 1, 2, 2)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEventHandlers(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollOffset(gfx::Vector2d(10, 10)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(MathUtil::createGfxTransform(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer"));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDrawCheckerboardForMissingTiles(!testLayer->drawCheckerboardForMissingTiles()));

@ -11,10 +11,8 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/rect_f.h"
#include "ui/gfx/transform.h"
#include "ui/gfx/vector2d_f.h"
#include <public/WebTransformationMatrix.h>
using WebKit::WebTransformationMatrix;
namespace cc {
@ -22,39 +20,39 @@ const double MathUtil::PI_DOUBLE = 3.14159265358979323846;
const float MathUtil::PI_FLOAT = 3.14159265358979323846f;
const double MathUtil::EPSILON = 1e-9;
static HomogeneousCoordinate projectHomogeneousPoint(const WebTransformationMatrix& transform, const gfx::PointF& p)
static HomogeneousCoordinate projectHomogeneousPoint(const gfx::Transform& transform, const gfx::PointF& p)
{
// In this case, the layer we are trying to project onto is perpendicular to ray
// (point p and z-axis direction) that we are trying to project. This happens when the
// layer is rotated so that it is infinitesimally thin, or when it is co-planar with
// the camera origin -- i.e. when the layer is invisible anyway.
if (!transform.m33())
if (!transform.matrix().getDouble(2, 2))
return HomogeneousCoordinate(0, 0, 0, 1);
double x = p.x();
double y = p.y();
double z = -(transform.m13() * x + transform.m23() * y + transform.m43()) / transform.m33();
double z = -(transform.matrix().getDouble(2, 0) * x + transform.matrix().getDouble(2, 1) * y + transform.matrix().getDouble(2, 3)) / transform.matrix().getDouble(2, 2);
// implicit definition of w = 1;
double outX = x * transform.m11() + y * transform.m21() + z * transform.m31() + transform.m41();
double outY = x * transform.m12() + y * transform.m22() + z * transform.m32() + transform.m42();
double outZ = x * transform.m13() + y * transform.m23() + z * transform.m33() + transform.m43();
double outW = x * transform.m14() + y * transform.m24() + z * transform.m34() + transform.m44();
double outX = x * transform.matrix().getDouble(0, 0) + y * transform.matrix().getDouble(0, 1) + z * transform.matrix().getDouble(0, 2) + transform.matrix().getDouble(0, 3);
double outY = x * transform.matrix().getDouble(1, 0) + y * transform.matrix().getDouble(1, 1) + z * transform.matrix().getDouble(1, 2) + transform.matrix().getDouble(1, 3);
double outZ = x * transform.matrix().getDouble(2, 0) + y * transform.matrix().getDouble(2, 1) + z * transform.matrix().getDouble(2, 2) + transform.matrix().getDouble(2, 3);
double outW = x * transform.matrix().getDouble(3, 0) + y * transform.matrix().getDouble(3, 1) + z * transform.matrix().getDouble(3, 2) + transform.matrix().getDouble(3, 3);
return HomogeneousCoordinate(outX, outY, outZ, outW);
}
static HomogeneousCoordinate mapHomogeneousPoint(const WebTransformationMatrix& transform, const gfx::Point3F& p)
static HomogeneousCoordinate mapHomogeneousPoint(const gfx::Transform& transform, const gfx::Point3F& p)
{
double x = p.x();
double y = p.y();
double z = p.z();
// implicit definition of w = 1;
double outX = x * transform.m11() + y * transform.m21() + z * transform.m31() + transform.m41();
double outY = x * transform.m12() + y * transform.m22() + z * transform.m32() + transform.m42();
double outZ = x * transform.m13() + y * transform.m23() + z * transform.m33() + transform.m43();
double outW = x * transform.m14() + y * transform.m24() + z * transform.m34() + transform.m44();
double outX = x * transform.matrix().getDouble(0, 0) + y * transform.matrix().getDouble(0, 1) + z * transform.matrix().getDouble(0, 2) + transform.matrix().getDouble(0, 3);
double outY = x * transform.matrix().getDouble(1, 0) + y * transform.matrix().getDouble(1, 1) + z * transform.matrix().getDouble(1, 2) + transform.matrix().getDouble(1, 3);
double outZ = x * transform.matrix().getDouble(2, 0) + y * transform.matrix().getDouble(2, 1) + z * transform.matrix().getDouble(2, 2) + transform.matrix().getDouble(2, 3);
double outW = x * transform.matrix().getDouble(3, 0) + y * transform.matrix().getDouble(3, 1) + z * transform.matrix().getDouble(3, 2) + transform.matrix().getDouble(3, 3);
return HomogeneousCoordinate(outX, outY, outZ, outW);
}
@ -102,15 +100,15 @@ static inline void addVertexToClippedQuad(const gfx::PointF& newVertex, gfx::Poi
numVerticesInClippedQuad++;
}
gfx::Rect MathUtil::mapClippedRect(const WebTransformationMatrix& transform, const gfx::Rect& srcRect)
gfx::Rect MathUtil::mapClippedRect(const gfx::Transform& transform, const gfx::Rect& srcRect)
{
return gfx::ToEnclosingRect(mapClippedRect(transform, gfx::RectF(srcRect)));
}
gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, const gfx::RectF& srcRect)
gfx::RectF MathUtil::mapClippedRect(const gfx::Transform& transform, const gfx::RectF& srcRect)
{
if (transform.isIdentityOrTranslation())
return srcRect + gfx::Vector2dF(static_cast<float>(transform.m41()), static_cast<float>(transform.m42()));
if (MathUtil::isIdentityOrTranslation(transform))
return srcRect + gfx::Vector2dF(static_cast<float>(transform.matrix().getDouble(0, 3)), static_cast<float>(transform.matrix().getDouble(1, 3)));
// Apply the transform, but retain the result in homogeneous coordinates.
gfx::QuadF q = gfx::QuadF(srcRect);
@ -122,10 +120,10 @@ gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, co
return computeEnclosingClippedRect(h1, h2, h3, h4);
}
gfx::RectF MathUtil::projectClippedRect(const WebTransformationMatrix& transform, const gfx::RectF& srcRect)
gfx::RectF MathUtil::projectClippedRect(const gfx::Transform& transform, const gfx::RectF& srcRect)
{
if (transform.isIdentityOrTranslation())
return srcRect + gfx::Vector2dF(static_cast<float>(transform.m41()), static_cast<float>(transform.m42()));
if (MathUtil::isIdentityOrTranslation(transform))
return srcRect + gfx::Vector2dF(static_cast<float>(transform.matrix().getDouble(0, 3)), static_cast<float>(transform.matrix().getDouble(1, 3)));
// Perform the projection, but retain the result in homogeneous coordinates.
gfx::QuadF q = gfx::QuadF(srcRect);
@ -137,7 +135,7 @@ gfx::RectF MathUtil::projectClippedRect(const WebTransformationMatrix& transform
return computeEnclosingClippedRect(h1, h2, h3, h4);
}
void MathUtil::mapClippedQuad(const WebTransformationMatrix& transform, const gfx::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad)
void MathUtil::mapClippedQuad(const gfx::Transform& transform, const gfx::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad)
{
HomogeneousCoordinate h1 = mapHomogeneousPoint(transform, gfx::Point3F(srcQuad.p1()));
HomogeneousCoordinate h2 = mapHomogeneousPoint(transform, gfx::Point3F(srcQuad.p2()));
@ -241,11 +239,11 @@ gfx::RectF MathUtil::computeEnclosingClippedRect(const HomogeneousCoordinate& h1
return gfx::RectF(gfx::PointF(xmin, ymin), gfx::SizeF(xmax - xmin, ymax - ymin));
}
gfx::QuadF MathUtil::mapQuad(const WebTransformationMatrix& transform, const gfx::QuadF& q, bool& clipped)
gfx::QuadF MathUtil::mapQuad(const gfx::Transform& transform, const gfx::QuadF& q, bool& clipped)
{
if (transform.isIdentityOrTranslation()) {
if (MathUtil::isIdentityOrTranslation(transform)) {
gfx::QuadF mappedQuad(q);
mappedQuad += gfx::Vector2dF(static_cast<float>(transform.m41()), static_cast<float>(transform.m42()));
mappedQuad += gfx::Vector2dF(static_cast<float>(transform.matrix().getDouble(0, 3)), static_cast<float>(transform.matrix().getDouble(1, 3)));
clipped = false;
return mappedQuad;
}
@ -261,7 +259,7 @@ gfx::QuadF MathUtil::mapQuad(const WebTransformationMatrix& transform, const gfx
return gfx::QuadF(h1.cartesianPoint2d(), h2.cartesianPoint2d(), h3.cartesianPoint2d(), h4.cartesianPoint2d());
}
gfx::PointF MathUtil::mapPoint(const WebTransformationMatrix& transform, const gfx::PointF& p, bool& clipped)
gfx::PointF MathUtil::mapPoint(const gfx::Transform& transform, const gfx::PointF& p, bool& clipped)
{
HomogeneousCoordinate h = mapHomogeneousPoint(transform, gfx::Point3F(p));
@ -284,7 +282,7 @@ gfx::PointF MathUtil::mapPoint(const WebTransformationMatrix& transform, const g
return h.cartesianPoint2d();
}
gfx::Point3F MathUtil::mapPoint(const WebTransformationMatrix& transform, const gfx::Point3F& p, bool& clipped)
gfx::Point3F MathUtil::mapPoint(const gfx::Transform& transform, const gfx::Point3F& p, bool& clipped)
{
HomogeneousCoordinate h = mapHomogeneousPoint(transform, p);
@ -307,7 +305,7 @@ gfx::Point3F MathUtil::mapPoint(const WebTransformationMatrix& transform, const
return h.cartesianPoint3d();
}
gfx::QuadF MathUtil::projectQuad(const WebTransformationMatrix& transform, const gfx::QuadF& q, bool& clipped)
gfx::QuadF MathUtil::projectQuad(const gfx::Transform& transform, const gfx::QuadF& q, bool& clipped)
{
gfx::QuadF projectedQuad;
bool clippedPoint;
@ -323,7 +321,7 @@ gfx::QuadF MathUtil::projectQuad(const WebTransformationMatrix& transform, const
return projectedQuad;
}
gfx::PointF MathUtil::projectPoint(const WebTransformationMatrix& transform, const gfx::PointF& p, bool& clipped)
gfx::PointF MathUtil::projectPoint(const gfx::Transform& transform, const gfx::PointF& p, bool& clipped)
{
HomogeneousCoordinate h = projectHomogeneousPoint(transform, p);
@ -347,7 +345,7 @@ gfx::PointF MathUtil::projectPoint(const WebTransformationMatrix& transform, con
return h.cartesianPoint2d();
}
void MathUtil::flattenTransformTo2d(WebTransformationMatrix& transform)
void MathUtil::flattenTransformTo2d(gfx::Transform& transform)
{
// Set both the 3rd row and 3rd column to (0, 0, 1, 0).
//
@ -359,13 +357,13 @@ void MathUtil::flattenTransformTo2d(WebTransformationMatrix& transform)
// - Because of linearity of transforms, this flattened transform also preserves the
// effect that any subsequent (post-multiplied) transforms would have on z values.
//
transform.setM13(0);
transform.setM23(0);
transform.setM31(0);
transform.setM32(0);
transform.setM33(1);
transform.setM34(0);
transform.setM43(0);
transform.matrix().setDouble(2, 0, 0);
transform.matrix().setDouble(2, 1, 0);
transform.matrix().setDouble(0, 2, 0);
transform.matrix().setDouble(1, 2, 0);
transform.matrix().setDouble(2, 2, 1);
transform.matrix().setDouble(3, 2, 0);
transform.matrix().setDouble(2, 3, 0);
}
static inline float scaleOnAxis(double a, double b, double c)
@ -373,12 +371,12 @@ static inline float scaleOnAxis(double a, double b, double c)
return std::sqrt(a * a + b * b + c * c);
}
gfx::Vector2dF MathUtil::computeTransform2dScaleComponents(const WebTransformationMatrix& transform)
gfx::Vector2dF MathUtil::computeTransform2dScaleComponents(const gfx::Transform& transform)
{
if (transform.hasPerspective())
if (hasPerspective(transform))
return gfx::Vector2dF(1, 1);
float xScale = scaleOnAxis(transform.m11(), transform.m12(), transform.m13());
float yScale = scaleOnAxis(transform.m21(), transform.m22(), transform.m23());
float xScale = scaleOnAxis(transform.matrix().getDouble(0, 0), transform.matrix().getDouble(1, 0), transform.matrix().getDouble(2, 0));
float yScale = scaleOnAxis(transform.matrix().getDouble(0, 1), transform.matrix().getDouble(1, 1), transform.matrix().getDouble(2, 1));
return gfx::Vector2dF(xScale, yScale);
}
@ -396,23 +394,22 @@ gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF des
return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * destination.y());
}
bool MathUtil::isInvertible(const gfx::Transform& transform)
bool MathUtil::isBackFaceVisible(const gfx::Transform& transform)
{
const SkMatrix44& matrix = transform.matrix();
double determinant = matrix.determinant();
return abs(determinant) > EPSILON;
}
// Compute whether a layer with a forward-facing normal of (0, 0, 1) would
// have its back face visible after applying the transform.
//
// This is done by transforming the normal and seeing if the resulting z
// value is positive or negative. However, note that transforming a normal
// actually requires using the inverse-transpose of the original transform.
bool MathUtil::isBackFaceVisible(const gfx::Transform&)
{
// TODO (shawnsingh): to be implemented in a follow up patch very soon.
NOTREACHED();
return false;
}
// TODO (shawnsingh) make this perform more efficiently - we do not
// actually need to instantiate/invert/transpose any matrices, exploiting the
// fact that we only need to transform (0, 0, 1, 0).
gfx::Transform inverseTransform = MathUtil::inverse(transform);
const SkMatrix44& mInv = inverseTransform.matrix();
bool MathUtil::isIdentity(const gfx::Transform& transform)
{
return transform.matrix().isIdentity();
return mInv.getDouble(2, 2) < 0;
}
bool MathUtil::isIdentityOrTranslation(const gfx::Transform& transform)
@ -438,11 +435,6 @@ bool MathUtil::hasPerspective(const gfx::Transform& transform)
return matrix.getDouble(3, 0) || matrix.getDouble(3, 1) || matrix.getDouble(3, 2) || (matrix.getDouble(3, 3) != 1);
}
void MathUtil::makeIdentity(gfx::Transform* transform)
{
transform->matrix().setIdentity();
}
void MathUtil::rotateEulerAngles(gfx::Transform* transform, double eulerX, double eulerY, double eulerZ)
{
// TODO (shawnsingh): make this implementation faster and more accurate by

@ -11,14 +11,11 @@
#include "ui/gfx/point3_f.h"
#include "ui/gfx/transform.h"
namespace WebKit {
class WebTransformationMatrix;
}
namespace gfx {
class QuadF;
class Rect;
class RectF;
class Transform;
class Vector2dF;
}
@ -78,7 +75,7 @@ public:
static float Deg2Rad(float deg) { return deg * PI_FLOAT / 180; }
static float Rad2Deg(float rad) { return rad * 180 / PI_FLOAT; }
// Background: WebTransformationMatrix code in WebCore does not do the right thing in
// Background: Existing transform code does not do the right thing in
// mapRect / mapQuad / projectQuad when there is a perspective projection that causes
// one of the transformed vertices to go to w < 0. In those cases, it is necessary to
// perform clipping in homogeneous coordinates, after applying the transform, before
@ -86,30 +83,30 @@ public:
//
// These functions return the axis-aligned rect that encloses the correctly clipped,
// transformed polygon.
static gfx::Rect mapClippedRect(const WebKit::WebTransformationMatrix&, const gfx::Rect&);
static gfx::RectF mapClippedRect(const WebKit::WebTransformationMatrix&, const gfx::RectF&);
static gfx::RectF projectClippedRect(const WebKit::WebTransformationMatrix&, const gfx::RectF&);
static gfx::Rect mapClippedRect(const gfx::Transform&, const gfx::Rect&);
static gfx::RectF mapClippedRect(const gfx::Transform&, const gfx::RectF&);
static gfx::RectF projectClippedRect(const gfx::Transform&, const gfx::RectF&);
// Returns an array of vertices that represent the clipped polygon. After returning, indexes from
// 0 to numVerticesInClippedQuad are valid in the clippedQuad array. Note that
// numVerticesInClippedQuad may be zero, which means the entire quad was clipped, and
// none of the vertices in the array are valid.
static void mapClippedQuad(const WebKit::WebTransformationMatrix&, const gfx::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad);
static void mapClippedQuad(const gfx::Transform&, const gfx::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad);
static gfx::RectF computeEnclosingRectOfVertices(gfx::PointF vertices[], int numVertices);
static gfx::RectF computeEnclosingClippedRect(const HomogeneousCoordinate& h1, const HomogeneousCoordinate& h2, const HomogeneousCoordinate& h3, const HomogeneousCoordinate& h4);
// NOTE: These functions do not do correct clipping against w = 0 plane, but they
// correctly detect the clipped condition via the boolean clipped.
static gfx::QuadF mapQuad(const WebKit::WebTransformationMatrix&, const gfx::QuadF&, bool& clipped);
static gfx::PointF mapPoint(const WebKit::WebTransformationMatrix&, const gfx::PointF&, bool& clipped);
static gfx::Point3F mapPoint(const WebKit::WebTransformationMatrix&, const gfx::Point3F&, bool& clipped);
static gfx::QuadF projectQuad(const WebKit::WebTransformationMatrix&, const gfx::QuadF&, bool& clipped);
static gfx::PointF projectPoint(const WebKit::WebTransformationMatrix&, const gfx::PointF&, bool& clipped);
static gfx::QuadF mapQuad(const gfx::Transform&, const gfx::QuadF&, bool& clipped);
static gfx::PointF mapPoint(const gfx::Transform&, const gfx::PointF&, bool& clipped);
static gfx::Point3F mapPoint(const gfx::Transform&, const gfx::Point3F&, bool& clipped);
static gfx::QuadF projectQuad(const gfx::Transform&, const gfx::QuadF&, bool& clipped);
static gfx::PointF projectPoint(const gfx::Transform&, const gfx::PointF&, bool& clipped);
static void flattenTransformTo2d(WebKit::WebTransformationMatrix&);
static void flattenTransformTo2d(gfx::Transform&);
static gfx::Vector2dF computeTransform2dScaleComponents(const WebKit::WebTransformationMatrix&);
static gfx::Vector2dF computeTransform2dScaleComponents(const gfx::Transform&);
// Returns the smallest angle between the given two vectors in degrees. Neither vector is
// assumed to be normalized.
@ -118,17 +115,14 @@ public:
// Projects the |source| vector onto |destination|. Neither vector is assumed to be normalized.
static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF destination);
// Temporary API to ease migration from WebKit::WebTransformationMatrix
// Temporary API to ease migration from gfx::Transform
// to gfx::Transform.
//
// TODO(shawnsingh, vollick) we should phase out as much as possible of
// these temporary functions, putting functionality into gfx::Transform.
static bool isInvertible(const gfx::Transform&);
static bool isBackFaceVisible(const gfx::Transform&);
static bool isIdentity(const gfx::Transform&);
static bool isIdentityOrTranslation(const gfx::Transform&);
static bool hasPerspective(const gfx::Transform&);
static void makeIdentity(gfx::Transform*);
static void rotateEulerAngles(gfx::Transform*, double eulerX, double eulerY, double eulerZ);
static void rotateAxisAngle(gfx::Transform*, double i, double j, double k, double degrees);
static gfx::Transform inverse(const gfx::Transform&);

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

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

@ -14,7 +14,6 @@
#include "ui/gfx/rect_conversions.h"
using namespace std;
using WebKit::WebTransformationMatrix;
namespace cc {
@ -121,7 +120,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::finishedRenderTarget(co
}
template<typename RenderSurfaceType>
static inline Region transformSurfaceOpaqueRegion(const RenderSurfaceType* surface, const Region& region, const WebTransformationMatrix& transform)
static inline Region transformSurfaceOpaqueRegion(const RenderSurfaceType* surface, const Region& region, const gfx::Transform& transform)
{
// Verify that rects within the |surface| will remain rects in its target surface after applying |transform|. If this is true, then
// apply |transform| to each rect within |region| in order to transform the entire Region.
@ -182,7 +181,7 @@ static inline void reduceOcclusion(const gfx::Rect& affectedArea, const gfx::Rec
}
template<typename LayerType>
static void reduceOcclusionBelowSurface(LayerType* contributingLayer, const gfx::Rect& surfaceRect, const WebTransformationMatrix& surfaceTransform, LayerType* renderTarget, Region& occlusionInTarget, Region& occlusionInScreen)
static void reduceOcclusionBelowSurface(LayerType* contributingLayer, const gfx::Rect& surfaceRect, const gfx::Transform& surfaceTransform, LayerType* renderTarget, Region& occlusionInTarget, Region& occlusionInScreen)
{
if (surfaceRect.IsEmpty())
return;
@ -249,7 +248,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::leaveToRenderTarget(con
// FIXME: Remove usePaintTracking when paint tracking is on for paint culling.
template<typename LayerType>
static inline void addOcclusionBehindLayer(Region& region, const LayerType* layer, const WebTransformationMatrix& transform, const Region& opaqueContents, const gfx::Rect& clipRectInTarget, const gfx::Size& minimumTrackingSize, std::vector<gfx::Rect>* occludingScreenSpaceRects, std::vector<gfx::Rect>* nonOccludingScreenSpaceRects)
static inline void addOcclusionBehindLayer(Region& region, const LayerType* layer, const gfx::Transform& transform, const Region& opaqueContents, const gfx::Rect& clipRectInTarget, const gfx::Size& minimumTrackingSize, std::vector<gfx::Rect>* occludingScreenSpaceRects, std::vector<gfx::Rect>* nonOccludingScreenSpaceRects)
{
DCHECK(layer->visibleContentRect().Contains(opaqueContents.bounds()));
@ -309,7 +308,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer
// remain rectilinear, then we don't add any occlusion in screen space.
if (layerTransformsToScreenKnown(layer)) {
WebTransformationMatrix targetToScreenTransform = m_stack.back().target->renderSurface()->screenSpaceTransform();
gfx::Transform targetToScreenTransform = m_stack.back().target->renderSurface()->screenSpaceTransform();
bool clipped;
gfx::QuadF clipQuadInScreen = MathUtil::mapQuad(targetToScreenTransform, gfx::QuadF(clipRectInTarget), clipped);
// FIXME: Find a rect interior to the transformed clip quad.
@ -320,7 +319,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer
}
}
static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const WebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRectInTarget, const Region& occlusion)
static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const gfx::Transform& contentSpaceTransform, const gfx::Rect& clipRectInTarget, const Region& occlusion)
{
gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform, gfx::RectF(contentRect));
// Take the gfx::ToEnclosingRect, as we want to include partial pixels in the test.
@ -329,7 +328,7 @@ static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const W
}
template<typename LayerType, typename RenderSurfaceType>
bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerType* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const
bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerType* renderTarget, const gfx::Rect& contentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const
{
if (hasOcclusionFromOutsideTargetSurface)
*hasOcclusionFromOutsideTargetSurface = false;
@ -368,21 +367,21 @@ static inline gfx::Rect rectSubtractRegion(const gfx::Rect& rect, const Region&
return rectRegion.bounds();
}
static inline gfx::Rect computeUnoccludedContentRect(const gfx::Rect& contentRect, const WebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRectInTarget, const Region& occlusion)
static inline gfx::Rect computeUnoccludedContentRect(const gfx::Rect& contentRect, const gfx::Transform& contentSpaceTransform, const gfx::Rect& clipRectInTarget, const Region& occlusion)
{
if (!contentSpaceTransform.isInvertible())
if (!contentSpaceTransform.IsInvertible())
return contentRect;
// Take the ToEnclosingRect at each step, as we want to contain any unoccluded partial pixels in the resulting Rect.
gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform, gfx::RectF(contentRect));
gfx::Rect shrunkRect = rectSubtractRegion(gfx::IntersectRects(gfx::ToEnclosingRect(transformedRect), clipRectInTarget), occlusion);
gfx::Rect unoccludedRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(contentSpaceTransform.inverse(), gfx::RectF(shrunkRect)));
gfx::Rect unoccludedRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(MathUtil::inverse(contentSpaceTransform), gfx::RectF(shrunkRect)));
// The rect back in content space is a bounding box and may extend outside of the original contentRect, so clamp it to the contentRectBounds.
return gfx::IntersectRects(unoccludedRect, contentRect);
}
template<typename LayerType, typename RenderSurfaceType>
gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentRect(const LayerType* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const
gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentRect(const LayerType* renderTarget, const gfx::Rect& contentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const
{
DCHECK(!m_stack.empty());
if (m_stack.empty())
@ -439,8 +438,8 @@ gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContribu
// found just below the top of the stack (if it exists).
bool hasOcclusion = m_stack.size() > 1;
const WebTransformationMatrix& transformToScreen = forReplica ? surface->replicaScreenSpaceTransform() : surface->screenSpaceTransform();
const WebTransformationMatrix& transformToTarget = forReplica ? surface->replicaDrawTransform() : surface->drawTransform();
const gfx::Transform& transformToScreen = forReplica ? surface->replicaScreenSpaceTransform() : surface->screenSpaceTransform();
const gfx::Transform& transformToTarget = forReplica ? surface->replicaDrawTransform() : surface->drawTransform();
gfx::Rect unoccludedInScreen = contentRect;
if (surfaceTransformsToScreenKnown(surface)) {

@ -35,9 +35,9 @@ public:
void leaveLayer(const LayerIteratorPosition<LayerType>&);
// Returns true if the given rect in content space for a layer is fully occluded in either screen space or the layer's target surface. |renderTarget| is the contributing layer's render target, and |drawTransform|, |transformsToTargetKnown| and |clippedRectInTarget| are relative to that.
bool occluded(const LayerType* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
bool occluded(const LayerType* renderTarget, const gfx::Rect& contentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
// Gives an unoccluded sub-rect of |contentRect| in the content space of a layer. Used when considering occlusion for a layer that paints/draws something. |renderTarget| is the contributing layer's render target, and |drawTransform|, |transformsToTargetKnown| and |clippedRectInTarget| are relative to that.
gfx::Rect unoccludedContentRect(const LayerType* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
gfx::Rect unoccludedContentRect(const LayerType* renderTarget, const gfx::Rect& contentRect, const gfx::Transform& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) const;
// Gives an unoccluded sub-rect of |contentRect| in the content space of the renderTarget owned by the layer.
// Used when considering occlusion for a contributing surface that is rendering into another target.

@ -4,6 +4,9 @@
#include "cc/occlusion_tracker.h"
#include <public/WebFilterOperation.h>
#include <public/WebFilterOperations.h>
#include "cc/layer.h"
#include "cc/layer_animation_controller.h"
#include "cc/layer_impl.h"
@ -16,9 +19,7 @@
#include "cc/test/occlusion_tracker_test_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <public/WebFilterOperation.h>
#include <public/WebFilterOperations.h>
#include <public/WebTransformationMatrix.h>
#include "ui/gfx/transform.h"
using namespace WebKit;
using namespace WebKitTests;
@ -197,7 +198,7 @@ protected:
LayerTreeHost::setNeedsFilterContext(false);
}
typename Types::ContentLayerType* createRoot(const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
typename Types::ContentLayerType* createRoot(const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
typename Types::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get();
@ -208,7 +209,7 @@ protected:
return layerPtr;
}
typename Types::LayerType* createLayer(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
typename Types::LayerType* createLayer(typename Types::LayerType* parent, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
typename Types::LayerPtrType layer(Types::createLayer());
typename Types::LayerType* layerPtr = layer.get();
@ -217,7 +218,7 @@ protected:
return layerPtr;
}
typename Types::LayerType* createSurface(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
typename Types::LayerType* createSurface(typename Types::LayerType* parent, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
typename Types::LayerType* layer = createLayer(parent, transform, position, bounds);
WebFilterOperations filters;
@ -226,7 +227,7 @@ protected:
return layer;
}
typename Types::ContentLayerType* createDrawingLayer(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
typename Types::ContentLayerType* createDrawingLayer(typename Types::LayerType* parent, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
{
typename Types::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get();
@ -246,7 +247,7 @@ protected:
return layerPtr;
}
typename Types::LayerType* createReplicaLayer(typename Types::LayerType* owningLayer, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
typename Types::LayerType* createReplicaLayer(typename Types::LayerType* owningLayer, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
typename Types::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get();
@ -264,7 +265,7 @@ protected:
return layerPtr;
}
typename Types::ContentLayerType* createDrawingSurface(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
typename Types::ContentLayerType* createDrawingSurface(typename Types::LayerType* parent, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
{
typename Types::ContentLayerType* layer = createDrawingLayer(parent, transform, position, bounds, opaque);
WebFilterOperations filters;
@ -349,24 +350,24 @@ protected:
m_layerIterator = m_layerIteratorBegin;
}
const WebTransformationMatrix identityMatrix;
const gfx::Transform identityMatrix;
private:
void setBaseProperties(typename Types::LayerType* layer, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
void setBaseProperties(typename Types::LayerType* layer, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
layer->setTransform(transform);
layer->setSublayerTransform(WebTransformationMatrix());
layer->setSublayerTransform(gfx::Transform());
layer->setAnchorPoint(gfx::PointF(0, 0));
layer->setPosition(position);
layer->setBounds(bounds);
}
void setProperties(Layer* layer, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
void setProperties(Layer* layer, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
setBaseProperties(layer, transform, position, bounds);
}
void setProperties(LayerImpl* layer, const WebTransformationMatrix& transform, const gfx::PointF& position, const gfx::Size& bounds)
void setProperties(LayerImpl* layer, const gfx::Transform& transform, const gfx::PointF& position, const gfx::Size& bounds)
{
setBaseProperties(layer, transform, position, bounds);
@ -503,8 +504,8 @@ protected:
OcclusionTrackerTestQuadsMismatchLayer(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix layerTransform;
layerTransform.translate(10, 10);
gfx::Transform layerTransform;
layerTransform.Translate(10, 10);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::Point(0, 0), gfx::Size(100, 100));
typename Types::ContentLayerType* layer1 = this->createDrawingLayer(parent, layerTransform, gfx::PointF(0, 0), gfx::Size(90, 90), true);
@ -523,8 +524,8 @@ protected:
// layers, e.g. in terms of transforms or clip rect. This is typical for
// DelegatedRendererLayer.
WebTransformationMatrix quadTransform;
quadTransform.translate(30, 30);
gfx::Transform quadTransform;
quadTransform.Translate(30, 30);
gfx::Rect clipRectInTarget(0, 0, 100, 100);
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, gfx::Rect(0, 0, 10, 10), quadTransform, false, clipRectInTarget).IsEmpty());
@ -543,10 +544,10 @@ protected:
OcclusionTrackerTestRotatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix layerTransform;
layerTransform.translate(250, 250);
layerTransform.rotate(90);
layerTransform.translate(-250, -250);
gfx::Transform layerTransform;
layerTransform.Translate(250, 250);
layerTransform.Rotate(90);
layerTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, layerTransform, gfx::PointF(30, 30), gfx::Size(500, 500), true);
@ -595,8 +596,8 @@ protected:
OcclusionTrackerTestTranslatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix layerTransform;
layerTransform.translate(20, 20);
gfx::Transform layerTransform;
layerTransform.Translate(20, 20);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, layerTransform, gfx::PointF(30, 30), gfx::Size(500, 500), true);
@ -657,10 +658,10 @@ protected:
OcclusionTrackerTestChildInRotatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
gfx::Transform childTransform;
childTransform.Translate(250, 250);
childTransform.Rotate(90);
childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@ -737,13 +738,13 @@ protected:
{
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(200, 200));
WebTransformationMatrix layer1Matrix;
layer1Matrix.scale(2);
gfx::Transform layer1Matrix;
layer1Matrix.Scale(2, 2);
typename Types::ContentLayerType* layer1 = this->createDrawingLayer(parent, layer1Matrix, gfx::PointF(0, 0), gfx::Size(100, 100), true);
layer1->setForceRenderSurface(true);
WebTransformationMatrix layer2Matrix;
layer2Matrix.translate(25, 25);
gfx::Transform layer2Matrix;
layer2Matrix.Translate(25, 25);
typename Types::ContentLayerType* layer2 = this->createDrawingLayer(layer1, layer2Matrix, gfx::PointF(0, 0), gfx::Size(50, 50), true);
typename Types::ContentLayerType* occluder = this->createDrawingLayer(parent, this->identityMatrix, gfx::PointF(100, 100), gfx::Size(500, 500), true);
this->calcDrawEtc(parent);
@ -771,10 +772,10 @@ protected:
OcclusionTrackerTestVisitTargetTwoTimes(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
gfx::Transform childTransform;
childTransform.Translate(250, 250);
childTransform.Rotate(90);
childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@ -876,13 +877,13 @@ protected:
OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(95);
childTransform.translate(-250, -250);
gfx::Transform childTransform;
childTransform.Translate(250, 250);
childTransform.Rotate(95);
childTransform.Translate(-250, -250);
WebTransformationMatrix layerTransform;
layerTransform.translate(10, 10);
gfx::Transform layerTransform;
layerTransform.Translate(10, 10);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
typename Types::LayerType* child = this->createLayer(parent, childTransform, gfx::PointF(30, 30), gfx::Size(500, 500));
@ -939,10 +940,10 @@ protected:
OcclusionTrackerTestSurfaceWithTwoOpaqueChildren(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
gfx::Transform childTransform;
childTransform.Translate(250, 250);
childTransform.Rotate(90);
childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@ -1025,10 +1026,10 @@ protected:
OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
gfx::Transform childTransform;
childTransform.Translate(250, 250);
childTransform.Rotate(90);
childTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@ -1130,15 +1131,15 @@ protected:
OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix child1Transform;
child1Transform.translate(250, 250);
child1Transform.rotate(-90);
child1Transform.translate(-250, -250);
gfx::Transform child1Transform;
child1Transform.Translate(250, 250);
child1Transform.Rotate(-90);
child1Transform.Translate(-250, -250);
WebTransformationMatrix child2Transform;
child2Transform.translate(250, 250);
child2Transform.rotate(90);
child2Transform.translate(-250, -250);
gfx::Transform child2Transform;
child2Transform.Translate(250, 250);
child2Transform.Rotate(90);
child2Transform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@ -1233,10 +1234,10 @@ protected:
OcclusionTrackerTestFilters(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix layerTransform;
layerTransform.translate(250, 250);
layerTransform.rotate(90);
layerTransform.translate(-250, -250);
gfx::Transform layerTransform;
layerTransform.Translate(250, 250);
layerTransform.Rotate(90);
layerTransform.Translate(-250, -250);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@ -1867,8 +1868,8 @@ protected:
OcclusionTrackerTest3dTransform(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix transform;
transform.rotate3d(0, 30, 0);
gfx::Transform transform;
MathUtil::rotateEulerAngles(&transform, 0, 30, 0);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
@ -1898,10 +1899,10 @@ protected:
// behavior is that a 3d layer simply does not add any occlusion to the occlusion
// tracker.
WebTransformationMatrix translationToFront;
translationToFront.translate3d(0, 0, -10);
WebTransformationMatrix translationToBack;
translationToFront.translate3d(0, 0, -100);
gfx::Transform translationToFront;
translationToFront.Translate3d(0, 0, -10);
gfx::Transform translationToBack;
translationToFront.Translate3d(0, 0, -100);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
typename Types::ContentLayerType* child1 = this->createDrawingLayer(parent, translationToBack, gfx::PointF(0, 0), gfx::Size(100, 100), true);
@ -1930,11 +1931,11 @@ protected:
OcclusionTrackerTestPerspectiveTransform(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix transform;
transform.translate(150, 150);
transform.applyPerspective(400);
transform.rotate3d(1, 0, 0, -30);
transform.translate(-150, -150);
gfx::Transform transform;
transform.Translate(150, 150);
transform.ApplyPerspectiveDepth(400);
MathUtil::rotateAxisAngle(&transform, 1, 0, 0, -30);
transform.Translate(-150, -150);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
@ -1960,13 +1961,13 @@ protected:
void runMyTest()
{
// This test is based on the platform/chromium/compositing/3d-corners.html layout test.
WebTransformationMatrix transform;
transform.translate(250, 50);
transform.applyPerspective(10);
transform.translate(-250, -50);
transform.translate(250, 50);
transform.rotate3d(1, 0, 0, -167);
transform.translate(-250, -50);
gfx::Transform transform;
transform.Translate(250, 50);
transform.ApplyPerspectiveDepth(10);
transform.Translate(-250, -50);
transform.Translate(250, 50);
MathUtil::rotateAxisAngle(&transform, 1, 0, 0, -167);
transform.Translate(-250, -50);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 100));
typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 500));
@ -1993,11 +1994,11 @@ protected:
OcclusionTrackerTestLayerBehindCameraDoesNotOcclude(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix transform;
transform.translate(50, 50);
transform.applyPerspective(100);
transform.translate3d(0, 0, 110);
transform.translate(-50, -50);
gfx::Transform transform;
transform.Translate(50, 50);
transform.ApplyPerspectiveDepth(100);
transform.Translate3d(0, 0, 110);
transform.Translate(-50, -50);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, transform, gfx::PointF(0, 0), gfx::Size(100, 100), true);
@ -2024,11 +2025,11 @@ protected:
OcclusionTrackerTestLargePixelsOccludeInsideClipRect(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix transform;
transform.translate(50, 50);
transform.applyPerspective(100);
transform.translate3d(0, 0, 99);
transform.translate(-50, -50);
gfx::Transform transform;
transform.Translate(50, 50);
transform.ApplyPerspectiveDepth(100);
transform.Translate3d(0, 0, 99);
transform.Translate(-50, -50);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
parent->setMasksToBounds(true);
@ -2249,10 +2250,10 @@ protected:
OcclusionTrackerTestSurfaceOcclusionTranslatesToParent(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix surfaceTransform;
surfaceTransform.translate(300, 300);
surfaceTransform.scale(2);
surfaceTransform.translate(-150, -150);
gfx::Transform surfaceTransform;
surfaceTransform.Translate(300, 300);
surfaceTransform.Scale(2, 2);
surfaceTransform.Translate(-150, -150);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 500));
typename Types::ContentLayerType* surface = this->createDrawingSurface(parent, surfaceTransform, gfx::PointF(0, 0), gfx::Size(300, 300), false);
@ -2563,8 +2564,8 @@ protected:
OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
gfx::Transform scaleByHalf;
scaleByHalf.Scale(0.5, 0.5);
// Make a surface and its replica, each 50x50, that are completely surrounded by opaque layers which are above them in the z-order.
// The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface
@ -2694,8 +2695,8 @@ protected:
OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
gfx::Transform scaleByHalf;
scaleByHalf.Scale(0.5, 0.5);
// Makes two surfaces that completely cover |parent|. The occlusion both above and below the filters will be reduced by each of them.
typename Types::ContentLayerType* root = this->createRoot(this->identityMatrix, gfx::PointF(0, 0), gfx::Size(75, 75));
@ -2879,8 +2880,8 @@ protected:
OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
gfx::Transform scaleByHalf;
scaleByHalf.Scale(0.5, 0.5);
// Make a surface and its replica, each 50x50, with a smaller 30x30 layer centered below each.
// The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface
@ -2927,8 +2928,8 @@ protected:
OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
gfx::Transform scaleByHalf;
scaleByHalf.Scale(0.5, 0.5);
// Make a surface and its replica, each 50x50, that are completely occluded by opaque layers which are above them in the z-order.
// The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface
@ -2974,8 +2975,8 @@ protected:
OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
void runMyTest()
{
WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
gfx::Transform scaleByHalf;
scaleByHalf.Scale(0.5, 0.5);
// Make a surface and its replica, each 50x50, that are partially occluded by opaque layers which are above them in the z-order.
// The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface

@ -11,9 +11,7 @@
#include "cc/math_util.h"
#include "ui/gfx/quad_f.h"
#include "ui/gfx/rect.h"
#include <public/WebTransformationMatrix.h>
using WebKit::WebTransformationMatrix;
#include "ui/gfx/transform.h"
namespace cc {
@ -49,7 +47,7 @@ static inline float polygonArea(const gfx::PointF points[8], int numPoints)
}
// Takes a given quad, maps it by the given transformation, and gives the area of the resulting polygon.
static inline float areaOfMappedQuad(const WebTransformationMatrix& transform, const gfx::QuadF& quad)
static inline float areaOfMappedQuad(const gfx::Transform& transform, const gfx::QuadF& quad)
{
gfx::PointF clippedQuad[8];
int numVerticesInClippedQuad = 0;
@ -71,7 +69,7 @@ void OverdrawMetrics::didCullTilesForUpload(int count)
m_tilesCulledForUpload += count;
}
void OverdrawMetrics::didUpload(const WebTransformationMatrix& transformToTarget, const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect)
void OverdrawMetrics::didUpload(const gfx::Transform& transformToTarget, const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect)
{
if (!m_recordMetricsForFrame)
return;
@ -99,7 +97,7 @@ void OverdrawMetrics::didUseRenderSurfaceTextureMemoryBytes(size_t renderSurface
m_renderSurfaceTextureUseBytes += renderSurfaceUseBytes;
}
void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transformToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect)
void OverdrawMetrics::didCullForDrawing(const gfx::Transform& transformToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect)
{
if (!m_recordMetricsForFrame)
return;
@ -110,7 +108,7 @@ void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transform
m_pixelsCulledForDrawing += beforeCullArea - afterCullArea;
}
void OverdrawMetrics::didDraw(const WebTransformationMatrix& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect)
void OverdrawMetrics::didDraw(const gfx::Transform& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect)
{
if (!m_recordMetricsForFrame)
return;

@ -9,10 +9,7 @@
namespace gfx {
class Rect;
}
namespace WebKit {
class WebTransformationMatrix;
class Transform;
}
namespace cc {
@ -31,7 +28,7 @@ public:
// Records that an invalid tile was culled and did not need to be painted/uploaded, and did not contribute to other tiles needing to be painted.
void didCullTilesForUpload(int count);
// Records pixels that were uploaded to texture memory.
void didUpload(const WebKit::WebTransformationMatrix& transformToTarget, const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect);
void didUpload(const gfx::Transform& transformToTarget, const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect);
// Record contents texture(s) behind present using the given number of bytes.
void didUseContentsTextureMemoryBytes(size_t contentsTextureUseBytes);
// Record RenderSurfaceImpl texture(s) being present using the given number of bytes.
@ -40,9 +37,9 @@ public:
// These methods are used for saving metrics during draw.
// Record pixels that were not drawn to screen.
void didCullForDrawing(const WebKit::WebTransformationMatrix& transformToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect);
void didCullForDrawing(const gfx::Transform& transformToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect);
// Record pixels that were drawn to screen.
void didDraw(const WebKit::WebTransformationMatrix& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect);
void didDraw(const gfx::Transform& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect);
void recordMetrics(const LayerTreeHost*) const;
void recordMetrics(const LayerTreeHostImpl*) const;

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

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

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

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

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

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

@ -6,13 +6,14 @@
#ifndef CC_RENDER_SURFACE_H_
#define CC_RENDER_SURFACE_H_
#include <vector>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "cc/cc_export.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h"
#include <public/WebTransformationMatrix.h>
#include <vector>
#include "cc/cc_export.h"
#include "ui/gfx/transform.h"
namespace cc {
@ -37,17 +38,17 @@ public:
// This goes from content space with the origin in the center of the rect being transformed to the target space with the origin in the top left of the
// rect being transformed. Position the rect so that the origin is in the center of it before applying this transform.
const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; }
void setDrawTransform(const WebKit::WebTransformationMatrix& drawTransform) { m_drawTransform = drawTransform; }
const gfx::Transform& drawTransform() const { return m_drawTransform; }
void setDrawTransform(const gfx::Transform& drawTransform) { m_drawTransform = drawTransform; }
const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; }
void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; }
const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
void setScreenSpaceTransform(const gfx::Transform& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; }
const WebKit::WebTransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; }
void setReplicaDrawTransform(const WebKit::WebTransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
const gfx::Transform& replicaDrawTransform() const { return m_replicaDrawTransform; }
void setReplicaDrawTransform(const gfx::Transform& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; }
void setReplicaScreenSpaceTransform(const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; }
const gfx::Transform& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; }
void setReplicaScreenSpaceTransform(const gfx::Transform& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; }
bool targetSurfaceTransformsAreAnimating() const { return m_targetSurfaceTransformsAreAnimating; }
void setTargetSurfaceTransformsAreAnimating(bool animating) { m_targetSurfaceTransformsAreAnimating = animating; }
@ -80,10 +81,10 @@ private:
float m_drawOpacity;
bool m_drawOpacityIsAnimating;
WebKit::WebTransformationMatrix m_drawTransform;
WebKit::WebTransformationMatrix m_screenSpaceTransform;
WebKit::WebTransformationMatrix m_replicaDrawTransform;
WebKit::WebTransformationMatrix m_replicaScreenSpaceTransform;
gfx::Transform m_drawTransform;
gfx::Transform m_screenSpaceTransform;
gfx::Transform m_replicaDrawTransform;
gfx::Transform m_replicaScreenSpaceTransform;
bool m_targetSurfaceTransformsAreAnimating;
bool m_screenSpaceTransformsAreAnimating;

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

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

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

@ -19,7 +19,7 @@ scoped_ptr<SharedQuadState> SharedQuadState::Copy() const {
}
void SharedQuadState::SetAll(
const WebKit::WebTransformationMatrix& content_to_target_transform,
const gfx::Transform& content_to_target_transform,
const gfx::Rect& visible_content_rect,
const gfx::Rect& clipped_rect_in_target,
const gfx::Rect& clip_rect,

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

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

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

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

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

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

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

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

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

@ -4,11 +4,17 @@
#include "cc/test/geometry_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformationMatrix.h>
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/transform.h"
namespace WebKitTests {
// NOTE: even though transform data types use double precision, we only check
// for equality within single-precision error bounds because many transforms
// originate from single-precision data types such as quads/rects/etc.
void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expected,
const WebKit::WebTransformationMatrix& actual)
{
@ -30,4 +36,25 @@ void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expecte
EXPECT_FLOAT_EQ((expected).m44(), (actual).m44());
}
void ExpectTransformationMatrixEq(const gfx::Transform& expected,
const gfx::Transform& actual)
{
EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 0), (actual).matrix().getDouble(0, 0));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 0), (actual).matrix().getDouble(1, 0));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 0), (actual).matrix().getDouble(2, 0));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 0), (actual).matrix().getDouble(3, 0));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 1), (actual).matrix().getDouble(0, 1));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 1), (actual).matrix().getDouble(1, 1));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 1), (actual).matrix().getDouble(2, 1));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 1), (actual).matrix().getDouble(3, 1));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 2), (actual).matrix().getDouble(0, 2));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 2), (actual).matrix().getDouble(1, 2));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 2), (actual).matrix().getDouble(2, 2));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 2), (actual).matrix().getDouble(3, 2));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 3), (actual).matrix().getDouble(0, 3));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 3), (actual).matrix().getDouble(1, 3));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 3), (actual).matrix().getDouble(2, 3));
EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 3), (actual).matrix().getDouble(3, 3));
}
} // namespace WebKitTests

@ -5,6 +5,10 @@
#ifndef CC_TEST_GEOMETRY_TEST_UTILS_H_
#define CC_TEST_GEOMETRY_TEST_UTILS_H_
namespace gfx {
class Transform;
}
namespace WebKit {
class WebTransformationMatrix;
}
@ -50,6 +54,9 @@ do { \
// in bulk, it causes a significant slow-down in compilation time. This problem
// exists with both gcc and clang, and bugs have been filed at
// http://llvm.org/bugs/show_bug.cgi?id=13651 and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54337
void ExpectTransformationMatrixEq(const gfx::Transform& expected,
const gfx::Transform& actual);
void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expected,
const WebKit::WebTransformationMatrix& actual);

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

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

@ -14,7 +14,6 @@
#include "ui/gfx/rect_conversions.h"
using namespace std;
using WebKit::WebTransformationMatrix;
namespace cc {
@ -484,7 +483,7 @@ void TiledLayer::updateTileTextures(const gfx::Rect& paintRect, int left, int to
tile->updaterResource()->update(queue, sourceRect, destOffset, tile->partialUpdate, stats);
if (occlusion)
occlusion->overdrawMetrics().didUpload(WebTransformationMatrix(), sourceRect, tile->opaqueRect());
occlusion->overdrawMetrics().didUpload(gfx::Transform(), sourceRect, tile->opaqueRect());
}
}

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

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

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

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

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

@ -7,7 +7,7 @@
#include "content/public/common/common_param_traits.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebData.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
#include "ui/gfx/transform.h"
namespace IPC {
@ -208,104 +208,108 @@ void ParamTraits<WebKit::WebFilterOperations>::Log(
l->append(")");
}
void ParamTraits<WebKit::WebTransformationMatrix>::Write(
void ParamTraits<gfx::Transform>::Write(
Message* m, const param_type& p) {
WriteParam(m, p.m11());
WriteParam(m, p.m12());
WriteParam(m, p.m13());
WriteParam(m, p.m14());
WriteParam(m, p.m21());
WriteParam(m, p.m22());
WriteParam(m, p.m23());
WriteParam(m, p.m24());
WriteParam(m, p.m31());
WriteParam(m, p.m32());
WriteParam(m, p.m33());
WriteParam(m, p.m34());
WriteParam(m, p.m41());
WriteParam(m, p.m42());
WriteParam(m, p.m43());
WriteParam(m, p.m44());
WriteParam(m, p.matrix().getDouble(0, 0));
WriteParam(m, p.matrix().getDouble(1, 0));
WriteParam(m, p.matrix().getDouble(2, 0));
WriteParam(m, p.matrix().getDouble(3, 0));
WriteParam(m, p.matrix().getDouble(0, 1));
WriteParam(m, p.matrix().getDouble(1, 1));
WriteParam(m, p.matrix().getDouble(2, 1));
WriteParam(m, p.matrix().getDouble(3, 1));
WriteParam(m, p.matrix().getDouble(0, 2));
WriteParam(m, p.matrix().getDouble(1, 2));
WriteParam(m, p.matrix().getDouble(2, 2));
WriteParam(m, p.matrix().getDouble(3, 2));
WriteParam(m, p.matrix().getDouble(0, 3));
WriteParam(m, p.matrix().getDouble(1, 3));
WriteParam(m, p.matrix().getDouble(2, 3));
WriteParam(m, p.matrix().getDouble(3, 3));
}
bool ParamTraits<WebKit::WebTransformationMatrix>::Read(
bool ParamTraits<gfx::Transform>::Read(
const Message* m, PickleIterator* iter, param_type* r) {
// Note: In this function, "m12" means 1st row, 2nd column of the matrix.
// This is consistent with Skia's row-column notation, but backwards from
// WebCore's column-row notation.
double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34,
m41, m42, m43, m44;
bool success =
ReadParam(m, iter, &m11) &&
ReadParam(m, iter, &m12) &&
ReadParam(m, iter, &m13) &&
ReadParam(m, iter, &m14) &&
ReadParam(m, iter, &m21) &&
ReadParam(m, iter, &m22) &&
ReadParam(m, iter, &m23) &&
ReadParam(m, iter, &m24) &&
ReadParam(m, iter, &m31) &&
ReadParam(m, iter, &m32) &&
ReadParam(m, iter, &m33) &&
ReadParam(m, iter, &m34) &&
ReadParam(m, iter, &m41) &&
ReadParam(m, iter, &m12) &&
ReadParam(m, iter, &m22) &&
ReadParam(m, iter, &m32) &&
ReadParam(m, iter, &m42) &&
ReadParam(m, iter, &m13) &&
ReadParam(m, iter, &m23) &&
ReadParam(m, iter, &m33) &&
ReadParam(m, iter, &m43) &&
ReadParam(m, iter, &m14) &&
ReadParam(m, iter, &m24) &&
ReadParam(m, iter, &m34) &&
ReadParam(m, iter, &m44);
if (success) {
r->setM11(m11);
r->setM12(m12);
r->setM13(m13);
r->setM14(m14);
r->setM21(m21);
r->setM22(m22);
r->setM23(m23);
r->setM24(m24);
r->setM31(m31);
r->setM32(m32);
r->setM33(m33);
r->setM34(m34);
r->setM41(m41);
r->setM42(m42);
r->setM43(m43);
r->setM44(m44);
r->matrix().setDouble(0, 0, m11);
r->matrix().setDouble(1, 0, m21);
r->matrix().setDouble(2, 0, m31);
r->matrix().setDouble(3, 0, m41);
r->matrix().setDouble(0, 1, m12);
r->matrix().setDouble(1, 1, m22);
r->matrix().setDouble(2, 1, m32);
r->matrix().setDouble(3, 1, m42);
r->matrix().setDouble(0, 2, m13);
r->matrix().setDouble(1, 2, m23);
r->matrix().setDouble(2, 2, m33);
r->matrix().setDouble(3, 2, m43);
r->matrix().setDouble(0, 3, m14);
r->matrix().setDouble(1, 3, m24);
r->matrix().setDouble(2, 3, m34);
r->matrix().setDouble(3, 3, m44);
}
return success;
}
void ParamTraits<WebKit::WebTransformationMatrix>::Log(
void ParamTraits<gfx::Transform>::Log(
const param_type& p, std::string* l) {
l->append("(");
LogParam(p.m11(), l);
LogParam(p.matrix().getDouble(0, 0), l);
l->append(", ");
LogParam(p.m12(), l);
LogParam(p.matrix().getDouble(1, 0), l);
l->append(", ");
LogParam(p.m13(), l);
LogParam(p.matrix().getDouble(2, 0), l);
l->append(", ");
LogParam(p.m14(), l);
LogParam(p.matrix().getDouble(3, 0), l);
l->append(", ");
LogParam(p.m21(), l);
LogParam(p.matrix().getDouble(0, 1), l);
l->append(", ");
LogParam(p.m22(), l);
LogParam(p.matrix().getDouble(1, 1), l);
l->append(", ");
LogParam(p.m23(), l);
LogParam(p.matrix().getDouble(2, 1), l);
l->append(", ");
LogParam(p.m24(), l);
LogParam(p.matrix().getDouble(3, 1), l);
l->append(", ");
LogParam(p.m31(), l);
LogParam(p.matrix().getDouble(0, 2), l);
l->append(", ");
LogParam(p.m32(), l);
LogParam(p.matrix().getDouble(1, 2), l);
l->append(", ");
LogParam(p.m33(), l);
LogParam(p.matrix().getDouble(2, 2), l);
l->append(", ");
LogParam(p.m34(), l);
LogParam(p.matrix().getDouble(3, 2), l);
l->append(", ");
LogParam(p.m41(), l);
LogParam(p.matrix().getDouble(0, 3), l);
l->append(", ");
LogParam(p.m42(), l);
LogParam(p.matrix().getDouble(1, 3), l);
l->append(", ");
LogParam(p.m43(), l);
LogParam(p.matrix().getDouble(2, 3), l);
l->append(", ");
LogParam(p.m44(), l);
LogParam(p.matrix().getDouble(3, 3), l);
l->append(") ");
}
@ -406,7 +410,7 @@ bool ParamTraits<cc::RenderPass>::Read(
cc::RenderPass::Id id(-1, -1);
gfx::Rect output_rect;
gfx::RectF damage_rect;
WebKit::WebTransformationMatrix transform_to_root_target;
gfx::Transform transform_to_root_target;
bool has_transparent_background;
bool has_occlusion_from_outside_target_surface;
WebKit::WebFilterOperations filters;

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

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

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

@ -23,42 +23,6 @@ using cc::Layer;
namespace WebKit {
namespace {
WebTransformationMatrix transformationMatrixFromSkMatrix44(const SkMatrix44& matrix)
{
double data[16];
matrix.asColMajord(data);
return WebTransformationMatrix(data[0], data[1], data[2], data[3],
data[4], data[5], data[6], data[7],
data[8], data[9], data[10], data[11],
data[12], data[13], data[14], data[15]);
}
SkMatrix44 skMatrix44FromTransformationMatrix(const WebTransformationMatrix& matrix)
{
SkMatrix44 skMatrix;
skMatrix.set(0, 0, SkDoubleToMScalar(matrix.m11()));
skMatrix.set(1, 0, SkDoubleToMScalar(matrix.m12()));
skMatrix.set(2, 0, SkDoubleToMScalar(matrix.m13()));
skMatrix.set(3, 0, SkDoubleToMScalar(matrix.m14()));
skMatrix.set(0, 1, SkDoubleToMScalar(matrix.m21()));
skMatrix.set(1, 1, SkDoubleToMScalar(matrix.m22()));
skMatrix.set(2, 1, SkDoubleToMScalar(matrix.m23()));
skMatrix.set(3, 1, SkDoubleToMScalar(matrix.m24()));
skMatrix.set(0, 2, SkDoubleToMScalar(matrix.m31()));
skMatrix.set(1, 2, SkDoubleToMScalar(matrix.m32()));
skMatrix.set(2, 2, SkDoubleToMScalar(matrix.m33()));
skMatrix.set(3, 2, SkDoubleToMScalar(matrix.m34()));
skMatrix.set(0, 3, SkDoubleToMScalar(matrix.m41()));
skMatrix.set(1, 3, SkDoubleToMScalar(matrix.m42()));
skMatrix.set(2, 3, SkDoubleToMScalar(matrix.m43()));
skMatrix.set(3, 3, SkDoubleToMScalar(matrix.m44()));
return skMatrix;
}
}
WebLayer* WebLayer::create()
{
return new WebLayerImpl();
@ -203,32 +167,36 @@ WebFloatPoint WebLayerImpl::position() const
void WebLayerImpl::setSublayerTransform(const SkMatrix44& matrix)
{
m_layer->setSublayerTransform(transformationMatrixFromSkMatrix44(matrix));
gfx::Transform subLayerTransform;
subLayerTransform.matrix() = matrix;
m_layer->setSublayerTransform(subLayerTransform);
}
void WebLayerImpl::setSublayerTransform(const WebTransformationMatrix& matrix)
{
m_layer->setSublayerTransform(matrix);
m_layer->setSublayerTransform(matrix.toTransform());
}
SkMatrix44 WebLayerImpl::sublayerTransform() const
{
return skMatrix44FromTransformationMatrix(m_layer->sublayerTransform());
return m_layer->sublayerTransform().matrix();
}
void WebLayerImpl::setTransform(const SkMatrix44& matrix)
{
m_layer->setTransform(transformationMatrixFromSkMatrix44(matrix));
gfx::Transform transform;
transform.matrix() = matrix;
m_layer->setTransform(transform);
}
void WebLayerImpl::setTransform(const WebTransformationMatrix& matrix)
{
m_layer->setTransform(matrix);
m_layer->setTransform(matrix.toTransform());
}
SkMatrix44 WebLayerImpl::transform() const
{
return skMatrix44FromTransformationMatrix(m_layer->transform());
return m_layer->transform().matrix();
}
void WebLayerImpl::setDrawsContent(bool drawsContent)