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

Unified Diff: ui/compositor/layer_unittest.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: rebase Created 4 years 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 | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer_unittest.cc
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index 9a55e398ff6f907067826ff789e893e7eced2631..0f75a97ef08609048c33021980e429259c879af9 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -26,6 +26,7 @@
#include "cc/layers/layer.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
+#include "cc/surfaces/sequence_surface_reference_factory.h"
#include "cc/surfaces/surface_id.h"
#include "cc/surfaces/surface_sequence.h"
#include "cc/test/pixel_test_utils.h"
@@ -1814,9 +1815,20 @@ TEST_F(LayerWithDelegateTest, SetBoundsWhenInvisible) {
namespace {
-void FakeSatisfyCallback(const cc::SurfaceSequence&) {}
+class TestSurfaceReferenceFactory : public cc::SequenceSurfaceReferenceFactory {
+ public:
+ TestSurfaceReferenceFactory() = default;
+
+ private:
+ ~TestSurfaceReferenceFactory() override = default;
-void FakeRequireCallback(const cc::SurfaceId&, const cc::SurfaceSequence&) {}
+ // cc::SequenceSurfaceReferenceFactory implementation:
+ void SatisfySequence(const cc::SurfaceSequence& seq) const override {}
+ void RequireSequence(const cc::SurfaceId& id,
+ const cc::SurfaceSequence& seq) const override {}
+
+ DISALLOW_COPY_AND_ASSIGN(TestSurfaceReferenceFactory);
+};
} // namespace
@@ -1838,9 +1850,9 @@ TEST_F(LayerWithDelegateTest, ExternalContent) {
// Showing surface content changes the underlying cc layer.
before = child->cc_layer_for_testing();
- child->SetShowSurface(cc::SurfaceId(), base::Bind(&FakeSatisfyCallback),
- base::Bind(&FakeRequireCallback), gfx::Size(10, 10),
- 1.0);
+ child->SetShowSurface(
+ cc::SurfaceInfo(cc::SurfaceId(), 1.0, gfx::Size(10, 10)),
+ new TestSurfaceReferenceFactory());
EXPECT_TRUE(child->cc_layer_for_testing());
EXPECT_NE(before.get(), child->cc_layer_for_testing());
@@ -1854,55 +1866,43 @@ TEST_F(LayerWithDelegateTest, ExternalContent) {
TEST_F(LayerWithDelegateTest, ExternalContentMirroring) {
std::unique_ptr<Layer> layer(CreateLayer(LAYER_SOLID_COLOR));
- const auto satisfy_callback = base::Bind(&FakeSatisfyCallback);
- const auto require_callback = base::Bind(&FakeRequireCallback);
-
cc::SurfaceId surface_id(
cc::FrameSinkId(0, 1),
cc::LocalFrameId(2, base::UnguessableToken::Create()));
- layer->SetShowSurface(surface_id, satisfy_callback, require_callback,
- gfx::Size(10, 10), 1.0f);
+ cc::SurfaceInfo surface_info(surface_id, 1.0f, gfx::Size(10, 10));
+ layer->SetShowSurface(surface_info, new TestSurfaceReferenceFactory());
const auto mirror = layer->Mirror();
auto* const cc_layer = mirror->cc_layer_for_testing();
const auto* surface = static_cast<cc::SurfaceLayer*>(cc_layer);
// Mirroring preserves surface state.
- EXPECT_EQ(surface_id, surface->surface_id());
- EXPECT_TRUE(satisfy_callback.Equals(surface->satisfy_callback()));
- EXPECT_TRUE(require_callback.Equals(surface->require_callback()));
- EXPECT_EQ(gfx::Size(10, 10), surface->surface_size());
- EXPECT_EQ(1.0f, surface->surface_scale());
+ EXPECT_EQ(surface_info, surface->surface_info());
surface_id =
cc::SurfaceId(cc::FrameSinkId(1, 2),
cc::LocalFrameId(3, base::UnguessableToken::Create()));
- layer->SetShowSurface(surface_id, satisfy_callback, require_callback,
- gfx::Size(20, 20), 2.0f);
+ cc::SurfaceInfo surface_info_2(surface_id, 2.0f, gfx::Size(20, 20));
+ layer->SetShowSurface(surface_info_2, new TestSurfaceReferenceFactory());
// A new cc::Layer should be created for the mirror.
EXPECT_NE(cc_layer, mirror->cc_layer_for_testing());
surface = static_cast<cc::SurfaceLayer*>(mirror->cc_layer_for_testing());
// Surface updates propagate to the mirror.
- EXPECT_EQ(surface_id, surface->surface_id());
- EXPECT_EQ(gfx::Size(20, 20), surface->surface_size());
- EXPECT_EQ(2.0f, surface->surface_scale());
+ EXPECT_EQ(surface_info_2, surface->surface_info());
}
// Test if frame size in dip is properly calculated in SetShowSurface
TEST_F(LayerWithDelegateTest, FrameSizeInDip) {
std::unique_ptr<Layer> layer(CreateLayer(LAYER_SOLID_COLOR));
- const auto satisfy_callback = base::Bind(&FakeSatisfyCallback);
- const auto require_callback = base::Bind(&FakeRequireCallback);
-
cc::SurfaceId surface_id(
cc::FrameSinkId(0, 1),
cc::LocalFrameId(2, base::UnguessableToken::Create()));
- layer->SetShowSurface(surface_id, satisfy_callback, require_callback,
- gfx::Size(30, 40), 2.0f);
+ layer->SetShowSurface(cc::SurfaceInfo(surface_id, 2.0f, gfx::Size(30, 40)),
+ new TestSurfaceReferenceFactory());
EXPECT_EQ(layer->frame_size_in_dip_for_testing(), gfx::Size(15, 20));
}
@@ -1921,9 +1921,9 @@ TEST_F(LayerWithDelegateTest, LayerFiltersSurvival) {
// Showing surface content changes the underlying cc layer.
scoped_refptr<cc::Layer> before = layer->cc_layer_for_testing();
- layer->SetShowSurface(cc::SurfaceId(), base::Bind(&FakeSatisfyCallback),
- base::Bind(&FakeRequireCallback), gfx::Size(10, 10),
- 1.0);
+ layer->SetShowSurface(
+ cc::SurfaceInfo(cc::SurfaceId(), 1.0, gfx::Size(10, 10)),
+ new TestSurfaceReferenceFactory());
EXPECT_EQ(layer->layer_grayscale(), 0.5f);
EXPECT_TRUE(layer->cc_layer_for_testing());
EXPECT_NE(before.get(), layer->cc_layer_for_testing());
@@ -2244,9 +2244,9 @@ TEST(LayerDelegateTest, DelegatedFrameDamage) {
FrameDamageCheckingDelegate delegate;
layer->set_delegate(&delegate);
- layer->SetShowSurface(cc::SurfaceId(), base::Bind(&FakeSatisfyCallback),
- base::Bind(&FakeRequireCallback), gfx::Size(10, 10),
- 1.0);
+ layer->SetShowSurface(
+ cc::SurfaceInfo(cc::SurfaceId(), 1.0, gfx::Size(10, 10)),
+ new TestSurfaceReferenceFactory());
EXPECT_FALSE(delegate.delegated_frame_damage_called());
layer->OnDelegatedFrameDamage(damage_rect);
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698