Commit 3f1f5e6a authored by vollick@chromium.org's avatar vollick@chromium.org

A fix for LayerNoTextureSetFillsBoundsOpaquely.

Adds some omitted calls.

BUG=None
TEST=compositor_unittests

Review URL: http://codereview.chromium.org/8515006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109630 0039d316-1c4b-4281-b951-d872f2087c98
parent 94dde890
...@@ -118,7 +118,7 @@ class COMPOSITOR_EXPORT Layer : ...@@ -118,7 +118,7 @@ class COMPOSITOR_EXPORT Layer :
float opacity() const { return opacity_; } float opacity() const { return opacity_; }
void SetOpacity(float opacity); void SetOpacity(float opacity);
// Return the target opacity if animator is running, or the current bounds // Return the target opacity if animator is running, or the current opacity
// otherwise. // otherwise.
float GetTargetOpacity() const; float GetTargetOpacity() const;
......
...@@ -465,37 +465,53 @@ class LayerWithNullDelegateTest : public LayerWithDelegateTest { ...@@ -465,37 +465,53 @@ class LayerWithNullDelegateTest : public LayerWithDelegateTest {
return layer; return layer;
} }
void RunPendingMessages() {
MessageLoopForUI::current()->RunAllPending();
}
private: private:
scoped_ptr<NullLayerDelegate> default_layer_delegate_; scoped_ptr<NullLayerDelegate> default_layer_delegate_;
DISALLOW_COPY_AND_ASSIGN(LayerWithNullDelegateTest); DISALLOW_COPY_AND_ASSIGN(LayerWithNullDelegateTest);
}; };
// With the webkit compositor, we don't explicitly textures for layers, making
// tests that check that we do fail.
#if defined(USE_WEBKIT_COMPOSITOR)
#define NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(X) DISABLED_ ## X
#else
#define NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(X) X
#endif
// Verifies that a layer which is set never to have a texture does not // Verifies that a layer which is set never to have a texture does not
// get a texture when SetFillsBoundsOpaquely is called. // get a texture when SetFillsBoundsOpaquely is called.
TEST_F(LayerWithNullDelegateTest, LayerNoTextureSetFillsBoundsOpaquely) { TEST_F(LayerWithNullDelegateTest,
NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(
LayerNoTextureSetFillsBoundsOpaquely)) {
scoped_ptr<Layer> parent(CreateNoTextureLayer(gfx::Rect(0, 0, 400, 400))); scoped_ptr<Layer> parent(CreateNoTextureLayer(gfx::Rect(0, 0, 400, 400)));
scoped_ptr<Layer> child(CreateNoTextureLayer(gfx::Rect(50, 50, 100, 100))); scoped_ptr<Layer> child(CreateNoTextureLayer(gfx::Rect(50, 50, 100, 100)));
parent->Add(child.get()); parent->Add(child.get());
compositor()->SetRootLayer(parent.get()); compositor()->SetRootLayer(parent.get());
parent->SetFillsBoundsOpaquely(true);
child->SetFillsBoundsOpaquely(true);
Draw(); Draw();
RunPendingMessages();
EXPECT_TRUE(child->texture() == NULL); EXPECT_TRUE(child->texture() == NULL);
EXPECT_TRUE(parent->texture() == NULL); EXPECT_TRUE(parent->texture() == NULL);
}
// With the webkit compositor, we don't explicitly textures for layers, making parent->SetFillsBoundsOpaquely(false);
// tests that check that we do fail. child->SetFillsBoundsOpaquely(false);
#if defined(USE_WEBKIT_COMPOSITOR) Draw();
#define WEBKIT_COMPOSITOR_FAILS(X) FAILS_ ## X RunPendingMessages();
#else EXPECT_TRUE(child->texture() == NULL);
#define WEBKIT_COMPOSITOR_FAILS(X) X EXPECT_TRUE(parent->texture() == NULL);
#endif }
// Verifies that a layer does not have a texture when the hole is the size // Verifies that a layer does not have a texture when the hole is the size
// of the parent layer. // of the parent layer.
TEST_F(LayerWithNullDelegateTest, TEST_F(LayerWithNullDelegateTest,
WEBKIT_COMPOSITOR_FAILS(LayerNoTextureHoleSizeOfLayer)) { NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(LayerNoTextureHoleSizeOfLayer)) {
scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400)));
scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100)));
parent->Add(child.get()); parent->Add(child.get());
...@@ -511,7 +527,7 @@ TEST_F(LayerWithNullDelegateTest, ...@@ -511,7 +527,7 @@ TEST_F(LayerWithNullDelegateTest,
// Verifies that a layer which has opacity == 0 does not have a texture. // Verifies that a layer which has opacity == 0 does not have a texture.
TEST_F(LayerWithNullDelegateTest, TEST_F(LayerWithNullDelegateTest,
WEBKIT_COMPOSITOR_FAILS(LayerNoTextureTransparent)) { NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(LayerNoTextureTransparent)) {
scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400))); scoped_ptr<Layer> parent(CreateTextureRootLayer(gfx::Rect(0, 0, 400, 400)));
scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100)));
parent->Add(child.get()); parent->Add(child.get());
...@@ -535,7 +551,7 @@ TEST_F(LayerWithNullDelegateTest, ...@@ -535,7 +551,7 @@ TEST_F(LayerWithNullDelegateTest,
// Verifies that no texture is created for a layer with empty bounds. // Verifies that no texture is created for a layer with empty bounds.
TEST_F(LayerWithNullDelegateTest, TEST_F(LayerWithNullDelegateTest,
WEBKIT_COMPOSITOR_FAILS(LayerTextureNonEmptySchedulePaint)) { NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(LayerTextureNonEmptySchedulePaint)) {
scoped_ptr<Layer> layer(CreateTextureRootLayer(gfx::Rect(0, 0, 0, 0))); scoped_ptr<Layer> layer(CreateTextureRootLayer(gfx::Rect(0, 0, 0, 0)));
Draw(); Draw();
EXPECT_TRUE(layer->texture() == NULL); EXPECT_TRUE(layer->texture() == NULL);
...@@ -620,7 +636,8 @@ TEST_F(LayerWithNullDelegateTest, HoleWithNinetyDegreeTransforms) { ...@@ -620,7 +636,8 @@ TEST_F(LayerWithNullDelegateTest, HoleWithNinetyDegreeTransforms) {
// +- L12 (no texture) (added after L1 is already set as root-layer) // +- L12 (no texture) (added after L1 is already set as root-layer)
// +- L121 (texture) // +- L121 (texture)
// +- L122 (texture) // +- L122 (texture)
TEST_F(LayerWithNullDelegateTest, WEBKIT_COMPOSITOR_FAILS(NoCompositor)) { TEST_F(LayerWithNullDelegateTest,
NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(NoCompositor)) {
scoped_ptr<Layer> l1(CreateLayer(Layer::LAYER_HAS_NO_TEXTURE)); scoped_ptr<Layer> l1(CreateLayer(Layer::LAYER_HAS_NO_TEXTURE));
scoped_ptr<Layer> l11(CreateLayer(Layer::LAYER_HAS_TEXTURE)); scoped_ptr<Layer> l11(CreateLayer(Layer::LAYER_HAS_TEXTURE));
scoped_ptr<Layer> l12(CreateLayer(Layer::LAYER_HAS_NO_TEXTURE)); scoped_ptr<Layer> l12(CreateLayer(Layer::LAYER_HAS_NO_TEXTURE));
...@@ -726,26 +743,45 @@ TEST_F(LayerWithNullDelegateTest, Visibility) { ...@@ -726,26 +743,45 @@ TEST_F(LayerWithNullDelegateTest, Visibility) {
#endif #endif
} }
// Checks that the invalid rect assumes correct values when setting bounds.
// TODO(vollick): for USE_WEBKIT_COMPOSITOR, use WebKit's dirty rect.
TEST_F(LayerWithNullDelegateTest,
NOT_APPLICABLE_TO_WEBKIT_COMPOSITOR(SetBoundsInvalidRect)) {
scoped_ptr<Layer> l1(CreateTextureLayer(gfx::Rect(0, 0, 200, 200)));
compositor()->SetRootLayer(l1.get());
// After a draw the invalid rect should be empty.
Draw();
EXPECT_TRUE(l1->invalid_rect().IsEmpty());
// After a move the invalid rect should be empty.
l1->SetBounds(gfx::Rect(5, 5, 200, 200));
EXPECT_TRUE(l1->invalid_rect().IsEmpty());
// Bounds change should trigger both the invalid rect to update as well as
// CompositorDelegate being told to draw.
l1->SetBounds(gfx::Rect(5, 5, 100, 100));
EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
l1->invalid_rect().ToString());
}
// Verifies SetBounds triggers the appropriate painting/drawing. // Verifies SetBounds triggers the appropriate painting/drawing.
TEST_F(LayerWithNullDelegateTest, SetBoundsSchedulesPaint) { TEST_F(LayerWithNullDelegateTest, SetBoundsSchedulesPaint) {
scoped_ptr<Layer> l1(CreateTextureLayer(gfx::Rect(0, 0, 200, 200))); scoped_ptr<Layer> l1(CreateTextureLayer(gfx::Rect(0, 0, 200, 200)));
compositor()->SetRootLayer(l1.get()); compositor()->SetRootLayer(l1.get());
Draw(); Draw();
schedule_draw_invoked_ = false; schedule_draw_invoked_ = false;
// After a draw the invalid rect should be empty.
EXPECT_TRUE(l1->invalid_rect().IsEmpty());
l1->SetBounds(gfx::Rect(5, 5, 200, 200)); l1->SetBounds(gfx::Rect(5, 5, 200, 200));
// After a move the invalid rect should be empty.
EXPECT_TRUE(l1->invalid_rect().IsEmpty()); // The CompositorDelegate (us) should have been told to draw for a move.
// But the CompositorDelegate (us) should have been told to draw.
EXPECT_TRUE(schedule_draw_invoked_); EXPECT_TRUE(schedule_draw_invoked_);
schedule_draw_invoked_ = false; schedule_draw_invoked_ = false;
l1->SetBounds(gfx::Rect(5, 5, 100, 100)); l1->SetBounds(gfx::Rect(5, 5, 100, 100));
// Bounds change should trigger both the invalid rect to update as well as
// CompositorDelegate being told to draw. // The CompositorDelegate (us) should have been told to draw for a resize.
EXPECT_EQ(gfx::Rect(0, 0, 100, 100), l1->invalid_rect());
EXPECT_TRUE(schedule_draw_invoked_); EXPECT_TRUE(schedule_draw_invoked_);
} }
......
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