OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/texture_layer.h" | 5 #include "cc/layers/texture_layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); | 228 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); |
229 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); | 229 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); |
230 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( | 230 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( |
231 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); | 231 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); |
232 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( | 232 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( |
233 0.5f, 0.5f, 0.5f, 0.5f)); | 233 0.5f, 0.5f, 0.5f, 0.5f)); |
234 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); | 234 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); |
235 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); | 235 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); |
236 } | 236 } |
237 | 237 |
238 TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { | |
239 const gfx::Size layer_bounds(100, 100); | |
240 const gfx::Rect layer_rect(layer_bounds); | |
241 const Region layer_region(layer_rect); | |
242 | |
243 scoped_refptr<TextureLayer> layer = | |
244 TextureLayer::CreateForMailbox(layer_settings_, nullptr); | |
245 layer->SetBounds(layer_bounds); | |
246 layer->draw_properties().visible_content_rect = layer_rect; | |
247 layer->SetBlendBackgroundColor(true); | |
248 | |
249 // Verify initial conditions. | |
250 EXPECT_FALSE(layer->contents_opaque()); | |
251 EXPECT_EQ(0u, layer->background_color()); | |
252 EXPECT_EQ(Region().ToString(), | |
253 layer->VisibleContentOpaqueRegion().ToString()); | |
254 | |
255 // Opaque background. | |
256 layer->SetBackgroundColor(SK_ColorWHITE); | |
257 EXPECT_EQ(layer_region.ToString(), | |
258 layer->VisibleContentOpaqueRegion().ToString()); | |
259 | |
260 // Transparent background. | |
261 layer->SetBackgroundColor(SkColorSetARGB(100, 255, 255, 255)); | |
262 EXPECT_EQ(Region().ToString(), | |
263 layer->VisibleContentOpaqueRegion().ToString()); | |
264 } | |
265 | |
266 TEST_F(TextureLayerTest, RateLimiter) { | 238 TEST_F(TextureLayerTest, RateLimiter) { |
267 FakeTextureLayerClient client; | 239 FakeTextureLayerClient client; |
268 scoped_refptr<TextureLayer> test_layer = | 240 scoped_refptr<TextureLayer> test_layer = |
269 TextureLayer::CreateForMailbox(layer_settings_, &client); | 241 TextureLayer::CreateForMailbox(layer_settings_, &client); |
270 test_layer->SetIsDrawable(true); | 242 test_layer->SetIsDrawable(true); |
271 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 243 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
272 layer_tree_host_->SetRootLayer(test_layer); | 244 layer_tree_host_->SetRootLayer(test_layer); |
273 | 245 |
274 // Don't rate limit until we invalidate. | 246 // Don't rate limit until we invalidate. |
275 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); | 247 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 int callback_count_; | 1512 int callback_count_; |
1541 scoped_refptr<Layer> root_; | 1513 scoped_refptr<Layer> root_; |
1542 scoped_refptr<TextureLayer> layer_; | 1514 scoped_refptr<TextureLayer> layer_; |
1543 }; | 1515 }; |
1544 | 1516 |
1545 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1517 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1546 TextureLayerWithMailboxImplThreadDeleted); | 1518 TextureLayerWithMailboxImplThreadDeleted); |
1547 | 1519 |
1548 } // namespace | 1520 } // namespace |
1549 } // namespace cc | 1521 } // namespace cc |
OLD | NEW |