Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: cc/layers/texture_layer_unittest.cc

Issue 2193293004: cc: Make LayerTreeTests use a DelegatingRenderer and Display. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: display-layertreetest: withperftestsfix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/surface_layer_unittest.cc ('k') | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/texture_layer_unittest.cc
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index 15d2131b3f8cd8c76051707e2d842475ee2e8352..39cad043c488d0089a20d1bbc245583e1c98c13e 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -34,6 +34,7 @@
#include "cc/test/layer_test_common.h"
#include "cc/test/layer_tree_test.h"
#include "cc/test/stub_layer_tree_host_single_thread_client.h"
+#include "cc/test/test_delegating_output_surface.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/trees/blocking_task_runner.h"
@@ -631,12 +632,29 @@ TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) {
class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
public:
- TextureLayerImplWithMailboxThreadedCallback()
- : callback_count_(0),
- commit_count_(0) {}
+ TextureLayerImplWithMailboxThreadedCallback() = default;
+
+ std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface(
+ scoped_refptr<ContextProvider> compositor_context_provider,
+ scoped_refptr<ContextProvider> worker_context_provider) override {
+ bool synchronous_composite =
+ !HasImplThread() &&
+ !layer_tree_host()->settings().single_thread_proxy_scheduler;
+ // Allow relaim resources for this test so that mailboxes in the display
+ // will be returned inside the commit that replaces them.
+ bool force_disable_reclaim_resources = false;
+ return base::MakeUnique<TestDelegatingOutputSurface>(
+ compositor_context_provider, std::move(worker_context_provider),
+ CreateDisplayOutputSurface(compositor_context_provider),
+ shared_bitmap_manager(), gpu_memory_buffer_manager(),
+ layer_tree_host()->settings().renderer_settings, ImplThreadTaskRunner(),
+ synchronous_composite, force_disable_reclaim_resources);
+ }
// Make sure callback is received on main and doesn't block the impl thread.
- void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
+ void ReleaseCallback(char mailbox_char,
+ const gpu::SyncToken& sync_token,
+ bool lost_resource) {
EXPECT_EQ(true, main_thread_.CalledOnValidThread());
EXPECT_FALSE(lost_resource);
++callback_count_;
@@ -647,12 +665,15 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
std::unique_ptr<SingleReleaseCallback> callback =
SingleReleaseCallback::Create(base::Bind(
&TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback,
- base::Unretained(this)));
+ base::Unretained(this), mailbox_char));
layer_->SetTextureMailbox(
TextureMailbox(MailboxFromChar(mailbox_char),
SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
GL_TEXTURE_2D),
std::move(callback));
+ // Damage the layer so we send a new frame with the new mailbox to the
+ // Display compositor.
+ layer_->SetNeedsDisplay();
}
void BeginTest() override {
@@ -703,32 +724,17 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
layer_->SetTextureMailbox(TextureMailbox(), nullptr);
break;
case 4:
- // With impl painting, the texture mailbox will still be on the impl
- // thread when the commit finishes, because the layer is not drawble
- // when it has no texture mailbox, and thus does not block the commit
- // on activation. So, we wait for activation.
- // TODO(danakj): fix this. crbug.com/277953
- layer_tree_host()->SetNeedsCommit();
- break;
- case 5:
EXPECT_EQ(4, callback_count_);
// Restore a mailbox for the next step.
SetMailbox('5');
break;
- case 6:
+ case 5:
// Case #5: remove layer from tree. Callback should *not* be called, the
// mailbox is returned to the main thread.
EXPECT_EQ(4, callback_count_);
layer_->RemoveFromParent();
break;
- case 7:
- // With impl painting, the texture mailbox will still be on the impl
- // thread when the commit finishes, because the layer is not around to
- // block the commit on activation anymore. So, we wait for activation.
- // TODO(danakj): fix this. crbug.com/277953
- layer_tree_host()->SetNeedsCommit();
- break;
- case 8:
+ case 6:
EXPECT_EQ(4, callback_count_);
// Resetting the mailbox will call the callback now.
layer_->SetTextureMailbox(TextureMailbox(), nullptr);
@@ -745,8 +751,8 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
private:
base::ThreadChecker main_thread_;
- int callback_count_;
- int commit_count_;
+ int callback_count_ = 0;
+ int commit_count_ = 0;
scoped_refptr<Layer> root_;
scoped_refptr<TextureLayer> layer_;
};
« no previous file with comments | « cc/layers/surface_layer_unittest.cc ('k') | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698