Commit 4894e1bc authored by danakj's avatar danakj Committed by Commit Bot

Replace SkMatrix44 with gfx::Transform in WebLayer APIs.

gfx::Transform is the ultimate type we want to use for cc, so avoid the
intermediate conversions thru WebLayer APIs.

R=jbroman@chromium.org, pdr@chromium.org

Bug: 838693, 738465
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I4774a4ccc8d5cab11712433a6f0933f1dd3719a9
Reviewed-on: https://chromium-review.googlesource.com/1038604
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555422}
parent e051a6ce
......@@ -155,9 +155,7 @@ WebFloatPoint WebLayerImpl::GetPosition() const {
return layer_->position();
}
void WebLayerImpl::SetTransform(const SkMatrix44& matrix) {
gfx::Transform transform;
transform.matrix() = matrix;
void WebLayerImpl::SetTransform(const gfx::Transform& transform) {
layer_->SetTransform(transform);
}
......@@ -170,8 +168,8 @@ blink::WebFloatPoint3D WebLayerImpl::TransformOrigin() const {
return layer_->transform_origin();
}
SkMatrix44 WebLayerImpl::Transform() const {
return layer_->transform().matrix();
const gfx::Transform& WebLayerImpl::Transform() const {
return layer_->transform();
}
void WebLayerImpl::SetDrawsContent(bool draws_content) {
......
......@@ -63,10 +63,10 @@ class CC_BLINK_EXPORT WebLayerImpl : public blink::WebLayer {
bool Opaque() const override;
void SetPosition(const blink::WebFloatPoint& position) override;
blink::WebFloatPoint GetPosition() const override;
void SetTransform(const SkMatrix44& transform) override;
void SetTransform(const gfx::Transform& transform) override;
void SetTransformOrigin(const blink::WebFloatPoint3D& point) override;
blink::WebFloatPoint3D TransformOrigin() const override;
SkMatrix44 Transform() const override;
const gfx::Transform& Transform() const override;
void SetDrawsContent(bool draws_content) override;
bool DrawsContent() const override;
void SetDoubleSided(bool double_sided) override;
......
......@@ -7,7 +7,6 @@
#include "cc/layers/layer.h"
#include "third_party/blink/public/platform/web_float_point.h"
#include "third_party/blink/public/platform/web_size.h"
#include "third_party/skia/include/core/SkMatrix44.h"
using cc::Layer;
......@@ -46,14 +45,12 @@ blink::WebSize WebLayerImplFixedBounds::Bounds() const {
return original_bounds_;
}
void WebLayerImplFixedBounds::SetTransform(const SkMatrix44& matrix) {
gfx::Transform transform;
transform.matrix() = matrix;
void WebLayerImplFixedBounds::SetTransform(const gfx::Transform& transform) {
SetTransformInternal(transform);
}
SkMatrix44 WebLayerImplFixedBounds::Transform() const {
return original_transform_.matrix();
const gfx::Transform& WebLayerImplFixedBounds::Transform() const {
return original_transform_;
}
void WebLayerImplFixedBounds::SetFixedBounds(gfx::Size fixed_bounds) {
......
......@@ -29,8 +29,8 @@ class CC_BLINK_EXPORT WebLayerImplFixedBounds : public WebLayerImpl {
const blink::WebFloatPoint3D& transform_origin) override;
void SetBounds(const blink::WebSize& bounds) override;
blink::WebSize Bounds() const override;
void SetTransform(const SkMatrix44& transform) override;
SkMatrix44 Transform() const override;
void SetTransform(const gfx::Transform& transform) override;
const gfx::Transform& Transform() const override;
void SetFixedBounds(gfx::Size bounds);
......
......@@ -13,8 +13,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/web_float_point.h"
#include "third_party/blink/public/platform/web_size.h"
#include "third_party/skia/include/core/SkMatrix44.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/transform.h"
using blink::WebFloatPoint;
using blink::WebSize;
......@@ -46,7 +46,7 @@ void CheckBoundsScaleSimple(WebLayerImplFixedBounds* layer,
EXPECT_EQ(bounds, layer->Bounds());
EXPECT_EQ(fixed_bounds, layer->layer()->bounds());
EXPECT_TRUE(layer->Transform().isIdentity());
EXPECT_TRUE(layer->Transform().IsIdentity());
// An arbitrary point to check the scale and transforms.
gfx::Point3F original_point(10, 20, 1);
......@@ -93,14 +93,14 @@ void CompareFixedBoundsLayerAndNormalLayer(const WebFloatPoint& anchor_point,
WebLayerImplFixedBounds fixed_bounds_layer(cc::PictureImageLayer::Create());
fixed_bounds_layer.SetBounds(bounds);
fixed_bounds_layer.SetFixedBounds(fixed_bounds);
fixed_bounds_layer.SetTransform(transform.matrix());
fixed_bounds_layer.SetTransform(transform);
fixed_bounds_layer.SetPosition(position);
root_layer.AddChild(&fixed_bounds_layer);
WebLayerImpl normal_layer(cc::PictureImageLayer::Create());
normal_layer.SetBounds(bounds);
normal_layer.SetTransform(transform.matrix());
normal_layer.SetTransform(transform);
normal_layer.SetPosition(position);
root_layer.AddChild(&normal_layer);
......
......@@ -41,8 +41,6 @@
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/skia/include/core/SkColor.h"
class SkMatrix44;
namespace cc {
class FilterOperations;
class Layer;
......@@ -54,6 +52,7 @@ struct ElementId;
namespace gfx {
class Rect;
class Transform;
}
namespace blink {
......@@ -116,8 +115,8 @@ class WebLayer {
virtual void SetPosition(const WebFloatPoint&) = 0;
virtual WebFloatPoint GetPosition() const = 0;
virtual void SetTransform(const SkMatrix44&) = 0;
virtual SkMatrix44 Transform() const = 0;
virtual void SetTransform(const gfx::Transform&) = 0;
virtual const gfx::Transform& Transform() const = 0;
virtual void SetTransformOrigin(const WebFloatPoint3D&) {}
virtual WebFloatPoint3D TransformOrigin() const { return WebFloatPoint3D(); }
......
......@@ -146,7 +146,7 @@ void LinkHighlightImpl::AttachLinkHighlightToCompositingLayer(
if (!new_graphics_layer)
return;
clip_layer_->SetTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor));
clip_layer_->SetTransform(gfx::Transform());
if (current_graphics_layer_ != new_graphics_layer) {
if (current_graphics_layer_)
......
......@@ -1013,7 +1013,7 @@ void GraphicsLayer::SetSize(const FloatSize& size) {
void GraphicsLayer::SetTransform(const TransformationMatrix& transform) {
transform_ = transform;
PlatformLayer()->SetTransform(TransformationMatrix::ToSkMatrix44(transform_));
PlatformLayer()->SetTransform(TransformationMatrix::ToTransform(transform));
}
void GraphicsLayer::SetTransformOrigin(const FloatPoint3D& transform_origin) {
......
......@@ -41,6 +41,7 @@
#include "third_party/blink/renderer/platform/wtf/cpu.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "ui/gfx/transform.h"
#if defined(ARCH_CPU_X86_64)
#include <emmintrin.h>
......@@ -1881,6 +1882,11 @@ SkMatrix44 TransformationMatrix::ToSkMatrix44(
return ret;
}
gfx::Transform TransformationMatrix::ToTransform(
const TransformationMatrix& matrix) {
return gfx::Transform(TransformationMatrix::ToSkMatrix44(matrix));
}
String TransformationMatrix::ToString(bool as_matrix) const {
if (as_matrix) {
// Return as a matrix in row-major order.
......
......@@ -35,6 +35,10 @@
#include "third_party/blink/renderer/platform/wtf/alignment.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace gfx {
class Transform;
}
namespace blink {
class AffineTransform;
......@@ -466,6 +470,7 @@ class PLATFORM_EXPORT TransformationMatrix {
void ToColumnMajorFloatArray(FloatMatrix4& result) const;
static SkMatrix44 ToSkMatrix44(const TransformationMatrix&);
static gfx::Transform ToTransform(const TransformationMatrix&);
// If |asMatrix|, return the matrix in row-major order. Otherwise, return
// the transform's decomposition which shows the translation, scale, etc.
......
......@@ -79,6 +79,7 @@ _CONFIG = [
# Chromium geometry types.
'gfx::Rect',
'gfx::Transform',
# Wrapper of SkRegion used in Chromium.
'cc::Region',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment