OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/compositor/layer.h" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
6 #include "base/bind.h" | 10 #include "base/bind.h" |
7 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
8 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
10 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
11 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
13 #include "base/path_service.h" | 17 #include "base/path_service.h" |
14 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
16 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
17 #include "cc/layers/delegated_frame_provider.h" | 21 #include "cc/layers/delegated_frame_provider.h" |
18 #include "cc/layers/delegated_frame_resource_collection.h" | 22 #include "cc/layers/delegated_frame_resource_collection.h" |
19 #include "cc/layers/layer.h" | 23 #include "cc/layers/layer.h" |
20 #include "cc/output/copy_output_request.h" | 24 #include "cc/output/copy_output_request.h" |
21 #include "cc/output/copy_output_result.h" | 25 #include "cc/output/copy_output_result.h" |
22 #include "cc/output/delegated_frame_data.h" | 26 #include "cc/output/delegated_frame_data.h" |
23 #include "cc/test/pixel_test_utils.h" | 27 #include "cc/test/pixel_test_utils.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "ui/compositor/compositor_observer.h" | 29 #include "ui/compositor/compositor_observer.h" |
26 #include "ui/compositor/dip_util.h" | 30 #include "ui/compositor/dip_util.h" |
27 #include "ui/compositor/layer.h" | |
28 #include "ui/compositor/layer_animation_sequence.h" | 31 #include "ui/compositor/layer_animation_sequence.h" |
29 #include "ui/compositor/layer_animator.h" | 32 #include "ui/compositor/layer_animator.h" |
30 #include "ui/compositor/paint_context.h" | 33 #include "ui/compositor/paint_context.h" |
31 #include "ui/compositor/paint_recorder.h" | 34 #include "ui/compositor/paint_recorder.h" |
32 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
33 #include "ui/compositor/scoped_layer_animation_settings.h" | 36 #include "ui/compositor/scoped_layer_animation_settings.h" |
34 #include "ui/compositor/test/context_factories_for_test.h" | 37 #include "ui/compositor/test/context_factories_for_test.h" |
35 #include "ui/compositor/test/draw_waiter_for_test.h" | 38 #include "ui/compositor/test/draw_waiter_for_test.h" |
36 #include "ui/compositor/test/test_compositor_host.h" | 39 #include "ui/compositor/test/test_compositor_host.h" |
37 #include "ui/compositor/test/test_layers.h" | 40 #include "ui/compositor/test/test_layers.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ReadPixels(bitmap, gfx::Rect(GetCompositor()->size())); | 146 ReadPixels(bitmap, gfx::Rect(GetCompositor()->size())); |
144 } | 147 } |
145 | 148 |
146 void ReadPixels(SkBitmap* bitmap, gfx::Rect source_rect) { | 149 void ReadPixels(SkBitmap* bitmap, gfx::Rect source_rect) { |
147 scoped_refptr<ReadbackHolder> holder(new ReadbackHolder); | 150 scoped_refptr<ReadbackHolder> holder(new ReadbackHolder); |
148 scoped_ptr<cc::CopyOutputRequest> request = | 151 scoped_ptr<cc::CopyOutputRequest> request = |
149 cc::CopyOutputRequest::CreateBitmapRequest( | 152 cc::CopyOutputRequest::CreateBitmapRequest( |
150 base::Bind(&ReadbackHolder::OutputRequestCallback, holder)); | 153 base::Bind(&ReadbackHolder::OutputRequestCallback, holder)); |
151 request->set_area(source_rect); | 154 request->set_area(source_rect); |
152 | 155 |
153 GetCompositor()->root_layer()->RequestCopyOfOutput(request.Pass()); | 156 GetCompositor()->root_layer()->RequestCopyOfOutput(std::move(request)); |
154 | 157 |
155 // Wait for copy response. This needs to wait as the compositor could | 158 // Wait for copy response. This needs to wait as the compositor could |
156 // be in the middle of a draw right now, and the commit with the | 159 // be in the middle of a draw right now, and the commit with the |
157 // copy output request may not be done on the first draw. | 160 // copy output request may not be done on the first draw. |
158 for (int i = 0; i < 2; i++) { | 161 for (int i = 0; i < 2; i++) { |
159 GetCompositor()->ScheduleFullRedraw(); | 162 GetCompositor()->ScheduleFullRedraw(); |
160 WaitForDraw(); | 163 WaitForDraw(); |
161 } | 164 } |
162 | 165 |
163 // Waits for the callback to finish run and return result. | 166 // Waits for the callback to finish run and return result. |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 child->SetVisible(true); | 1468 child->SetVisible(true); |
1466 DrawTree(root.get()); | 1469 DrawTree(root.get()); |
1467 EXPECT_TRUE(delegate.painted()); | 1470 EXPECT_TRUE(delegate.painted()); |
1468 } | 1471 } |
1469 | 1472 |
1470 static scoped_ptr<cc::DelegatedFrameData> MakeFrameData(gfx::Size size) { | 1473 static scoped_ptr<cc::DelegatedFrameData> MakeFrameData(gfx::Size size) { |
1471 scoped_ptr<cc::DelegatedFrameData> frame_data(new cc::DelegatedFrameData); | 1474 scoped_ptr<cc::DelegatedFrameData> frame_data(new cc::DelegatedFrameData); |
1472 scoped_ptr<cc::RenderPass> render_pass(cc::RenderPass::Create()); | 1475 scoped_ptr<cc::RenderPass> render_pass(cc::RenderPass::Create()); |
1473 render_pass->SetNew( | 1476 render_pass->SetNew( |
1474 cc::RenderPassId(1, 1), gfx::Rect(size), gfx::Rect(), gfx::Transform()); | 1477 cc::RenderPassId(1, 1), gfx::Rect(size), gfx::Rect(), gfx::Transform()); |
1475 frame_data->render_pass_list.push_back(render_pass.Pass()); | 1478 frame_data->render_pass_list.push_back(std::move(render_pass)); |
1476 return frame_data.Pass(); | 1479 return frame_data; |
1477 } | 1480 } |
1478 | 1481 |
1479 TEST_F(LayerWithDelegateTest, DelegatedLayer) { | 1482 TEST_F(LayerWithDelegateTest, DelegatedLayer) { |
1480 scoped_ptr<Layer> root(CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000))); | 1483 scoped_ptr<Layer> root(CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000))); |
1481 | 1484 |
1482 scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED)); | 1485 scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED)); |
1483 | 1486 |
1484 child->SetBounds(gfx::Rect(0, 0, 10, 10)); | 1487 child->SetBounds(gfx::Rect(0, 0, 10, 10)); |
1485 child->SetVisible(true); | 1488 child->SetVisible(true); |
1486 root->Add(child.get()); | 1489 root->Add(child.get()); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 root->SetOpacity(0.5f); | 1876 root->SetOpacity(0.5f); |
1874 WaitForSwap(); | 1877 WaitForSwap(); |
1875 EXPECT_EQ(1u, animation_observer.animation_step_count()); | 1878 EXPECT_EQ(1u, animation_observer.animation_step_count()); |
1876 | 1879 |
1877 EXPECT_FALSE(animation_observer.shutdown()); | 1880 EXPECT_FALSE(animation_observer.shutdown()); |
1878 ResetCompositor(); | 1881 ResetCompositor(); |
1879 EXPECT_TRUE(animation_observer.shutdown()); | 1882 EXPECT_TRUE(animation_observer.shutdown()); |
1880 } | 1883 } |
1881 | 1884 |
1882 } // namespace ui | 1885 } // namespace ui |
OLD | NEW |