Commit 3fc44d83 authored by vmpstr's avatar vmpstr Committed by Commit bot

cc_blink: Fix a leak in web layer impl fixed bounds test.

This patch cleans up the web layer impl fixed bounds test a bit to
use less pointers (some of which were leaked).

R=danakj
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel

Review-Url: https://codereview.chromium.org/2347343002
Cr-Commit-Position: refs/heads/master@{#419575}
parent 688c0c0c
...@@ -45,18 +45,18 @@ class Layer; ...@@ -45,18 +45,18 @@ class Layer;
namespace cc_blink { namespace cc_blink {
class WebLayerImpl : public blink::WebLayer { class CC_BLINK_EXPORT WebLayerImpl : public NON_EXPORTED_BASE(blink::WebLayer) {
public: public:
CC_BLINK_EXPORT WebLayerImpl(); WebLayerImpl();
CC_BLINK_EXPORT explicit WebLayerImpl(scoped_refptr<cc::Layer>); explicit WebLayerImpl(scoped_refptr<cc::Layer>);
~WebLayerImpl() override; ~WebLayerImpl() override;
CC_BLINK_EXPORT cc::Layer* layer() const; cc::Layer* layer() const;
// If set to true, content opaqueness cannot be changed using setOpaque. // If set to true, content opaqueness cannot be changed using setOpaque.
// However, it can still be modified using SetContentsOpaque on the // However, it can still be modified using SetContentsOpaque on the
// cc::Layer. // cc::Layer.
CC_BLINK_EXPORT void SetContentsOpaqueIsFixed(bool fixed); void SetContentsOpaqueIsFixed(bool fixed);
// WebLayer implementation. // WebLayer implementation.
int id() const override; int id() const override;
...@@ -80,7 +80,7 @@ class WebLayerImpl : public blink::WebLayer { ...@@ -80,7 +80,7 @@ class WebLayerImpl : public blink::WebLayer {
blink::WebBlendMode blendMode() const override; blink::WebBlendMode blendMode() const override;
void setIsRootForIsolatedGroup(bool root) override; void setIsRootForIsolatedGroup(bool root) override;
bool isRootForIsolatedGroup() override; bool isRootForIsolatedGroup() override;
CC_BLINK_EXPORT void setOpaque(bool opaque) override; void setOpaque(bool opaque) override;
bool opaque() const override; bool opaque() const override;
void setPosition(const blink::WebFloatPoint& position) override; void setPosition(const blink::WebFloatPoint& position) override;
blink::WebFloatPoint position() const override; blink::WebFloatPoint position() const override;
......
...@@ -17,11 +17,10 @@ namespace cc_blink { ...@@ -17,11 +17,10 @@ namespace cc_blink {
// can efficiently handle the bounds change of such layers if the bounds // can efficiently handle the bounds change of such layers if the bounds
// is fixed to a given value and the change of bounds are converted to // is fixed to a given value and the change of bounds are converted to
// transformation scales. // transformation scales.
class WebLayerImplFixedBounds : public WebLayerImpl { class CC_BLINK_EXPORT WebLayerImplFixedBounds : public WebLayerImpl {
public: public:
CC_BLINK_EXPORT WebLayerImplFixedBounds(); WebLayerImplFixedBounds();
CC_BLINK_EXPORT explicit WebLayerImplFixedBounds( explicit WebLayerImplFixedBounds(scoped_refptr<cc::Layer> layer);
scoped_refptr<cc::Layer> layer);
~WebLayerImplFixedBounds() override; ~WebLayerImplFixedBounds() override;
// WebLayerImpl overrides. // WebLayerImpl overrides.
...@@ -33,7 +32,7 @@ class WebLayerImplFixedBounds : public WebLayerImpl { ...@@ -33,7 +32,7 @@ class WebLayerImplFixedBounds : public WebLayerImpl {
void setTransform(const SkMatrix44& transform) override; void setTransform(const SkMatrix44& transform) override;
SkMatrix44 transform() const override; SkMatrix44 transform() const override;
CC_BLINK_EXPORT void SetFixedBounds(gfx::Size bounds); void SetFixedBounds(gfx::Size bounds);
protected: protected:
void SetTransformInternal(const gfx::Transform& transform); void SetTransformInternal(const gfx::Transform& transform);
......
...@@ -22,12 +22,12 @@ namespace cc_blink { ...@@ -22,12 +22,12 @@ namespace cc_blink {
namespace { namespace {
TEST(WebLayerImplFixedBoundsTest, IdentityBounds) { TEST(WebLayerImplFixedBoundsTest, IdentityBounds) {
std::unique_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds()); WebLayerImplFixedBounds layer;
layer->SetFixedBounds(gfx::Size(100, 100)); layer.SetFixedBounds(gfx::Size(100, 100));
layer->setBounds(WebSize(100, 100)); layer.setBounds(WebSize(100, 100));
EXPECT_EQ(WebSize(100, 100), layer->bounds()); EXPECT_EQ(WebSize(100, 100), layer.bounds());
EXPECT_EQ(gfx::Size(100, 100), layer->layer()->bounds()); EXPECT_EQ(gfx::Size(100, 100), layer.layer()->bounds());
EXPECT_EQ(gfx::Transform(), layer->layer()->transform()); EXPECT_EQ(gfx::Transform(), layer.layer()->transform());
} }
gfx::Point3F TransformPoint(const gfx::Transform& transform, gfx::Point3F TransformPoint(const gfx::Transform& transform,
...@@ -59,12 +59,12 @@ void CheckBoundsScaleSimple(WebLayerImplFixedBounds* layer, ...@@ -59,12 +59,12 @@ void CheckBoundsScaleSimple(WebLayerImplFixedBounds* layer,
} }
TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) { TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) {
std::unique_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds()); WebLayerImplFixedBounds layer;
CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250)); CheckBoundsScaleSimple(&layer, WebSize(100, 200), gfx::Size(150, 250));
// Change fixed_bounds. // Change fixed_bounds.
CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100)); CheckBoundsScaleSimple(&layer, WebSize(100, 200), gfx::Size(75, 100));
// Change bounds. // Change bounds.
CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100)); CheckBoundsScaleSimple(&layer, WebSize(300, 100), gfx::Size(75, 100));
} }
void ExpectEqualLayerRectsInTarget(cc::Layer* layer1, cc::Layer* layer2) { void ExpectEqualLayerRectsInTarget(cc::Layer* layer1, cc::Layer* layer2) {
...@@ -87,56 +87,54 @@ void CompareFixedBoundsLayerAndNormalLayer(const WebFloatPoint& anchor_point, ...@@ -87,56 +87,54 @@ void CompareFixedBoundsLayerAndNormalLayer(const WebFloatPoint& anchor_point,
WebFloatPoint position(20, 30); WebFloatPoint position(20, 30);
gfx::Size fixed_bounds(160, 70); gfx::Size fixed_bounds(160, 70);
std::unique_ptr<WebLayerImplFixedBounds> root_layer( WebLayerImplFixedBounds root_layer;
new WebLayerImplFixedBounds());
WebLayerImplFixedBounds* fixed_bounds_layer = WebLayerImplFixedBounds fixed_bounds_layer(cc::PictureImageLayer::Create());
new WebLayerImplFixedBounds(cc::PictureImageLayer::Create()); fixed_bounds_layer.setBounds(bounds);
fixed_bounds_layer->setBounds(bounds); fixed_bounds_layer.SetFixedBounds(fixed_bounds);
fixed_bounds_layer->SetFixedBounds(fixed_bounds); fixed_bounds_layer.setTransform(transform.matrix());
fixed_bounds_layer->setTransform(transform.matrix()); fixed_bounds_layer.setPosition(position);
fixed_bounds_layer->setPosition(position); root_layer.addChild(&fixed_bounds_layer);
root_layer->addChild(fixed_bounds_layer);
WebLayerImpl* normal_layer(new WebLayerImpl(cc::PictureImageLayer::Create())); WebLayerImpl normal_layer(cc::PictureImageLayer::Create());
normal_layer->setBounds(bounds); normal_layer.setBounds(bounds);
normal_layer->setTransform(transform.matrix()); normal_layer.setTransform(transform.matrix());
normal_layer->setPosition(position); normal_layer.setPosition(position);
root_layer->addChild(normal_layer); root_layer.addChild(&normal_layer);
cc::FakeLayerTreeHostClient client; cc::FakeLayerTreeHostClient client;
cc::TestTaskGraphRunner task_graph_runner; cc::TestTaskGraphRunner task_graph_runner;
std::unique_ptr<cc::FakeLayerTreeHost> host = std::unique_ptr<cc::FakeLayerTreeHost> host =
cc::FakeLayerTreeHost::Create(&client, &task_graph_runner); cc::FakeLayerTreeHost::Create(&client, &task_graph_runner);
host->SetRootLayer(root_layer->layer()); host->SetRootLayer(root_layer.layer());
{ {
cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
root_layer->layer(), kDeviceViewportSize); root_layer.layer(), kDeviceViewportSize);
inputs.device_scale_factor = kDeviceScaleFactor; inputs.device_scale_factor = kDeviceScaleFactor;
inputs.page_scale_factor = kPageScaleFactor; inputs.page_scale_factor = kPageScaleFactor;
inputs.page_scale_layer = root_layer->layer(), inputs.page_scale_layer = root_layer.layer(),
cc::LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); cc::LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
ExpectEqualLayerRectsInTarget(normal_layer->layer(), ExpectEqualLayerRectsInTarget(normal_layer.layer(),
fixed_bounds_layer->layer()); fixed_bounds_layer.layer());
} }
// Change of fixed bounds should not affect the target geometries. // Change of fixed bounds should not affect the target geometries.
fixed_bounds_layer->SetFixedBounds( fixed_bounds_layer.SetFixedBounds(
gfx::Size(fixed_bounds.width() / 2, fixed_bounds.height() * 2)); gfx::Size(fixed_bounds.width() / 2, fixed_bounds.height() * 2));
{ {
cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
root_layer->layer(), kDeviceViewportSize); root_layer.layer(), kDeviceViewportSize);
inputs.device_scale_factor = kDeviceScaleFactor; inputs.device_scale_factor = kDeviceScaleFactor;
inputs.page_scale_factor = kPageScaleFactor; inputs.page_scale_factor = kPageScaleFactor;
inputs.page_scale_layer = root_layer->layer(), inputs.page_scale_layer = root_layer.layer(),
cc::LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); cc::LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
ExpectEqualLayerRectsInTarget(normal_layer->layer(), ExpectEqualLayerRectsInTarget(normal_layer.layer(),
fixed_bounds_layer->layer()); fixed_bounds_layer.layer());
} }
} }
......
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