| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui_resource_layer.h" | 5 #include "cc/layers/ui_resource_layer.h" |
| 6 | 6 |
| 7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "cc/resources/resource_provider.h" | 8 #include "cc/resources/resource_provider.h" |
| 9 #include "cc/resources/scoped_ui_resource.h" | 9 #include "cc/resources/scoped_ui_resource.h" |
| 10 #include "cc/test/fake_layer_tree_host.h" | 10 #include "cc/test/fake_layer_tree_host.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; | 64 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 TEST_F(UIResourceLayerTest, SetBitmap) { | 67 TEST_F(UIResourceLayerTest, SetBitmap) { |
| 68 scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create(); | 68 scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create(); |
| 69 ASSERT_TRUE(test_layer.get()); | 69 ASSERT_TRUE(test_layer.get()); |
| 70 test_layer->SetBounds(gfx::Size(100, 100)); | 70 test_layer->SetBounds(gfx::Size(100, 100)); |
| 71 | 71 |
| 72 layer_tree_host_->SetRootLayer(test_layer); | 72 layer_tree_host_->SetRootLayer(test_layer); |
| 73 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 73 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 74 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get()); | 74 EXPECT_EQ(test_layer->GetLayerTreeHostForTesting(), layer_tree_host_.get()); |
| 75 | 75 |
| 76 test_layer->SavePaintProperties(); | 76 test_layer->SavePaintProperties(); |
| 77 test_layer->Update(); | 77 test_layer->Update(); |
| 78 | 78 |
| 79 EXPECT_FALSE(test_layer->DrawsContent()); | 79 EXPECT_FALSE(test_layer->DrawsContent()); |
| 80 | 80 |
| 81 SkBitmap bitmap; | 81 SkBitmap bitmap; |
| 82 bitmap.allocN32Pixels(10, 10); | 82 bitmap.allocN32Pixels(10, 10); |
| 83 bitmap.setImmutable(); | 83 bitmap.setImmutable(); |
| 84 | 84 |
| 85 test_layer->SetBitmap(bitmap); | 85 test_layer->SetBitmap(bitmap); |
| 86 test_layer->Update(); | 86 test_layer->Update(); |
| 87 | 87 |
| 88 EXPECT_TRUE(test_layer->DrawsContent()); | 88 EXPECT_TRUE(test_layer->DrawsContent()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(UIResourceLayerTest, SetUIResourceId) { | 91 TEST_F(UIResourceLayerTest, SetUIResourceId) { |
| 92 scoped_refptr<TestUIResourceLayer> test_layer = TestUIResourceLayer::Create(); | 92 scoped_refptr<TestUIResourceLayer> test_layer = TestUIResourceLayer::Create(); |
| 93 ASSERT_TRUE(test_layer.get()); | 93 ASSERT_TRUE(test_layer.get()); |
| 94 test_layer->SetBounds(gfx::Size(100, 100)); | 94 test_layer->SetBounds(gfx::Size(100, 100)); |
| 95 | 95 |
| 96 layer_tree_host_->SetRootLayer(test_layer); | 96 layer_tree_host_->SetRootLayer(test_layer); |
| 97 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 97 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 98 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get()); | 98 EXPECT_EQ(test_layer->GetLayerTreeHostForTesting(), layer_tree_host_.get()); |
| 99 | 99 |
| 100 test_layer->SavePaintProperties(); | 100 test_layer->SavePaintProperties(); |
| 101 test_layer->Update(); | 101 test_layer->Update(); |
| 102 | 102 |
| 103 EXPECT_FALSE(test_layer->DrawsContent()); | 103 EXPECT_FALSE(test_layer->DrawsContent()); |
| 104 | 104 |
| 105 bool is_opaque = false; | 105 bool is_opaque = false; |
| 106 std::unique_ptr<ScopedUIResource> resource = | 106 std::unique_ptr<ScopedUIResource> resource = |
| 107 ScopedUIResource::Create(layer_tree_host_->GetUIResourceManager(), | 107 ScopedUIResource::Create(layer_tree_host_->GetUIResourceManager(), |
| 108 UIResourceBitmap(gfx::Size(10, 10), is_opaque)); | 108 UIResourceBitmap(gfx::Size(10, 10), is_opaque)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 135 | 135 |
| 136 test_layer->SetBitmap(bitmap); | 136 test_layer->SetBitmap(bitmap); |
| 137 ASSERT_FALSE(bitmap.pixelRef()->unique()); | 137 ASSERT_FALSE(bitmap.pixelRef()->unique()); |
| 138 | 138 |
| 139 test_layer->SetUIResourceId(0); | 139 test_layer->SetUIResourceId(0); |
| 140 EXPECT_TRUE(bitmap.pixelRef()->unique()); | 140 EXPECT_TRUE(bitmap.pixelRef()->unique()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace | 143 } // namespace |
| 144 } // namespace cc | 144 } // namespace cc |
| OLD | NEW |