diff options
author | kloveless@chromium.org <kloveless@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 01:27:29 +0000 |
---|---|---|
committer | kloveless@chromium.org <kloveless@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 01:27:29 +0000 |
commit | 4bad8b6c1fc0c250b77578343f396d136955a881 (patch) | |
tree | ca1c08a17363ce6084886e6842a4bf31f1fb6d1a /cc/layers/texture_layer_unittest.cc | |
parent | 60b3ee87c91829366a589740131186ac0bce420e (diff) | |
download | chromium_src-4bad8b6c1fc0c250b77578343f396d136955a881.zip chromium_src-4bad8b6c1fc0c250b77578343f396d136955a881.tar.gz chromium_src-4bad8b6c1fc0c250b77578343f396d136955a881.tar.bz2 |
Remove the extra, unneeded commits that TextureLayer::Update does.
BUG=
Review URL: https://codereview.chromium.org/32193013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers/texture_layer_unittest.cc')
-rw-r--r-- | cc/layers/texture_layer_unittest.cc | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index c576341..63cf132 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -1695,6 +1695,109 @@ class TextureLayerChangeInvisibleTest // delegating renderer. SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerChangeInvisibleTest); +// Checks that TextureLayer::Update does not cause an extra commit when setting +// the texture mailbox. +class TextureLayerNoExtraCommitForMailboxTest + : public LayerTreeTest, + public TextureLayerClient { + public: + TextureLayerNoExtraCommitForMailboxTest() + : prepare_mailbox_count_(0) {} + + // TextureLayerClient implementation. + virtual unsigned PrepareTexture() OVERRIDE { + NOTREACHED(); + return 0; + } + + // TextureLayerClient implementation. + virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { + NOTREACHED(); + return NULL; + } + + virtual bool PrepareTextureMailbox( + cc::TextureMailbox* mailbox, + scoped_ptr<SingleReleaseCallback>* release_callback, + bool use_shared_memory) OVERRIDE { + prepare_mailbox_count_++; + // Alternate between two mailboxes to ensure that the TextureLayer updates + // and commits. + if (prepare_mailbox_count_ % 2 == 0) + *mailbox = MakeMailbox('1'); + else + *mailbox = MakeMailbox('2'); + + // Non-zero mailboxes need a callback. + *release_callback = SingleReleaseCallback::Create( + base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, + base::Unretained(this))); + // If the test fails, this would cause an infinite number of commits. + return true; + } + + TextureMailbox MakeMailbox(char name) { + return TextureMailbox(std::string(64, name)); + } + + void MailboxReleased(unsigned sync_point, bool lost_resource) { + } + + virtual void SetupTree() OVERRIDE { + scoped_refptr<Layer> root = Layer::Create(); + root->SetBounds(gfx::Size(10, 10)); + root->SetAnchorPoint(gfx::PointF()); + root->SetIsDrawable(true); + + solid_layer_ = SolidColorLayer::Create(); + solid_layer_->SetBounds(gfx::Size(10, 10)); + solid_layer_->SetIsDrawable(true); + solid_layer_->SetBackgroundColor(SK_ColorWHITE); + root->AddChild(solid_layer_); + + parent_layer_ = Layer::Create(); + parent_layer_->SetBounds(gfx::Size(10, 10)); + parent_layer_->SetIsDrawable(true); + root->AddChild(parent_layer_); + + texture_layer_ = TextureLayer::CreateForMailbox(this); + texture_layer_->SetBounds(gfx::Size(10, 10)); + texture_layer_->SetAnchorPoint(gfx::PointF()); + texture_layer_->SetIsDrawable(true); + parent_layer_->AddChild(texture_layer_); + + layer_tree_host()->SetRootLayer(root); + LayerTreeTest::SetupTree(); + } + + virtual void BeginTest() OVERRIDE { + PostSetNeedsCommitToMainThread(); + } + + + virtual void DidCommit() OVERRIDE { + switch (layer_tree_host()->source_frame_number()) { + case 1: + EndTest(); + break; + default: + NOTREACHED(); + break; + } + } + + virtual void AfterTest() OVERRIDE {} + + private: + scoped_refptr<SolidColorLayer> solid_layer_; + scoped_refptr<Layer> parent_layer_; + scoped_refptr<TextureLayer> texture_layer_; + + int prepare_mailbox_count_; +}; + +SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerNoExtraCommitForMailboxTest); + // Checks that changing a mailbox in the client for a TextureLayer that's // invisible correctly works and uses the new mailbox as soon as the layer // becomes visible (and returns the old one). |