OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/public/test/test_synchronous_compositor_android.h" | 5 #include "content/public/test/test_synchronous_compositor_android.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 TestSynchronousCompositor::TestSynchronousCompositor() : client_(NULL) { | 13 TestSynchronousCompositor::TestSynchronousCompositor() : client_(NULL) { |
14 } | 14 } |
15 | 15 |
16 TestSynchronousCompositor::~TestSynchronousCompositor() { | 16 TestSynchronousCompositor::~TestSynchronousCompositor() { |
17 SetClient(NULL); | 17 SetClient(NULL); |
18 } | 18 } |
19 | 19 |
20 void TestSynchronousCompositor::SetClient(SynchronousCompositorClient* client) { | 20 void TestSynchronousCompositor::SetClient(SynchronousCompositorClient* client) { |
21 if (client_) | 21 if (client_) |
22 client_->DidDestroyCompositor(this); | 22 client_->DidDestroyCompositor(this); |
23 client_ = client; | 23 client_ = client; |
24 if (client_) { | 24 if (client_) { |
25 client_->DidInitializeCompositor(this); | 25 client_->DidInitializeCompositor(this); |
26 client_->DidBecomeCurrent(this); | 26 client_->DidBecomeCurrent(this); |
27 } | 27 } |
28 } | 28 } |
29 | 29 |
30 scoped_ptr<cc::CompositorFrame> TestSynchronousCompositor::DemandDrawHw( | 30 SynchronousCompositor::Frame TestSynchronousCompositor::DemandDrawHw( |
31 const gfx::Size& surface_size, | 31 const gfx::Size& surface_size, |
32 const gfx::Transform& transform, | 32 const gfx::Transform& transform, |
33 const gfx::Rect& viewport, | 33 const gfx::Rect& viewport, |
34 const gfx::Rect& clip, | 34 const gfx::Rect& clip, |
35 const gfx::Rect& viewport_rect_for_tile_priority, | 35 const gfx::Rect& viewport_rect_for_tile_priority, |
36 const gfx::Transform& transform_for_tile_priority) { | 36 const gfx::Transform& transform_for_tile_priority) { |
37 return std::move(hardware_frame_); | 37 return std::move(hardware_frame_); |
38 } | 38 } |
39 | 39 |
| 40 void TestSynchronousCompositor::ReturnResources( |
| 41 uint32_t output_surface_id, |
| 42 const cc::CompositorFrameAck& frame_ack) { |
| 43 ReturnedResources returned_resources; |
| 44 returned_resources.output_surface_id = output_surface_id; |
| 45 returned_resources.resources = frame_ack.resources; |
| 46 frame_ack_array_.push_back(returned_resources); |
| 47 } |
| 48 |
| 49 void TestSynchronousCompositor::SwapReturnedResources(FrameAckArray* array) { |
| 50 DCHECK(array); |
| 51 frame_ack_array_.swap(*array); |
| 52 } |
| 53 |
40 bool TestSynchronousCompositor::DemandDrawSw(SkCanvas* canvas) { | 54 bool TestSynchronousCompositor::DemandDrawSw(SkCanvas* canvas) { |
41 DCHECK(canvas); | 55 DCHECK(canvas); |
42 return true; | 56 return true; |
43 } | 57 } |
44 | 58 |
45 void TestSynchronousCompositor::SetHardwareFrame( | 59 void TestSynchronousCompositor::SetHardwareFrame( |
| 60 uint32_t output_surface_id, |
46 scoped_ptr<cc::CompositorFrame> frame) { | 61 scoped_ptr<cc::CompositorFrame> frame) { |
47 hardware_frame_ = std::move(frame); | 62 hardware_frame_.output_surface_id = output_surface_id; |
| 63 hardware_frame_.frame = std::move(frame); |
48 } | 64 } |
49 | 65 |
| 66 TestSynchronousCompositor::ReturnedResources::ReturnedResources() |
| 67 : output_surface_id(0u) {} |
| 68 |
| 69 TestSynchronousCompositor::ReturnedResources::~ReturnedResources() {} |
| 70 |
50 } // namespace content | 71 } // namespace content |
OLD | NEW |