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/test/fake_output_surface.h" | 5 #include "cc/test/fake_output_surface.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "cc/output/compositor_frame_ack.h" | 9 #include "cc/output/compositor_frame_ack.h" |
10 #include "cc/output/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
11 #include "cc/resources/returned_resource.h" | 11 #include "cc/resources/returned_resource.h" |
12 #include "cc/test/begin_frame_args_test.h" | 12 #include "cc/test/begin_frame_args_test.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 | 16 |
17 FakeOutputSurface::FakeOutputSurface( | 17 FakeOutputSurface::FakeOutputSurface( |
18 scoped_refptr<ContextProvider> context_provider, | 18 scoped_refptr<ContextProvider> context_provider, |
19 scoped_refptr<ContextProvider> worker_context_provider, | 19 scoped_refptr<ContextProvider> worker_context_provider, |
20 bool delegated_rendering) | 20 bool delegated_rendering) |
21 : OutputSurface(context_provider, worker_context_provider), | 21 : OutputSurface(context_provider, worker_context_provider), |
22 client_(NULL), | 22 client_(NULL), |
23 num_sent_frames_(0), | 23 num_sent_frames_(0), |
24 has_external_stencil_test_(false), | 24 has_external_stencil_test_(false), |
25 suspended_for_recycle_(false), | 25 suspended_for_recycle_(false), |
26 framebuffer_(0), | 26 framebuffer_(0), |
27 overlay_candidate_validator_(nullptr) { | 27 overlay_candidate_validator_(nullptr) { |
28 if (delegated_rendering) { | 28 capabilities_.delegated_rendering = delegated_rendering; |
29 capabilities_.delegated_rendering = true; | |
30 capabilities_.max_frames_pending = 1; | |
31 } | |
32 } | 29 } |
33 | 30 |
34 FakeOutputSurface::FakeOutputSurface( | 31 FakeOutputSurface::FakeOutputSurface( |
35 scoped_refptr<ContextProvider> context_provider, | 32 scoped_refptr<ContextProvider> context_provider, |
36 bool delegated_rendering) | 33 bool delegated_rendering) |
37 : OutputSurface(context_provider), | 34 : OutputSurface(context_provider), |
38 client_(NULL), | 35 client_(NULL), |
39 num_sent_frames_(0), | 36 num_sent_frames_(0), |
40 has_external_stencil_test_(false), | 37 has_external_stencil_test_(false), |
41 suspended_for_recycle_(false), | 38 suspended_for_recycle_(false), |
42 framebuffer_(0), | 39 framebuffer_(0), |
43 overlay_candidate_validator_(nullptr) { | 40 overlay_candidate_validator_(nullptr) { |
44 if (delegated_rendering) { | 41 capabilities_.delegated_rendering = delegated_rendering; |
45 capabilities_.delegated_rendering = true; | |
46 capabilities_.max_frames_pending = 1; | |
47 } | |
48 } | 42 } |
49 | 43 |
50 FakeOutputSurface::FakeOutputSurface( | 44 FakeOutputSurface::FakeOutputSurface( |
51 scoped_ptr<SoftwareOutputDevice> software_device, | 45 scoped_ptr<SoftwareOutputDevice> software_device, |
52 bool delegated_rendering) | 46 bool delegated_rendering) |
53 : OutputSurface(software_device.Pass()), | 47 : OutputSurface(software_device.Pass()), |
54 client_(NULL), | 48 client_(NULL), |
55 num_sent_frames_(0), | 49 num_sent_frames_(0), |
56 has_external_stencil_test_(false), | 50 has_external_stencil_test_(false), |
57 suspended_for_recycle_(false), | 51 suspended_for_recycle_(false), |
58 framebuffer_(0), | 52 framebuffer_(0), |
59 overlay_candidate_validator_(nullptr) { | 53 overlay_candidate_validator_(nullptr) { |
60 if (delegated_rendering) { | 54 capabilities_.delegated_rendering = delegated_rendering; |
61 capabilities_.delegated_rendering = true; | |
62 capabilities_.max_frames_pending = 1; | |
63 } | |
64 } | 55 } |
65 | 56 |
66 FakeOutputSurface::FakeOutputSurface( | 57 FakeOutputSurface::FakeOutputSurface( |
67 scoped_refptr<ContextProvider> context_provider, | 58 scoped_refptr<ContextProvider> context_provider, |
68 scoped_ptr<SoftwareOutputDevice> software_device, | 59 scoped_ptr<SoftwareOutputDevice> software_device, |
69 bool delegated_rendering) | 60 bool delegated_rendering) |
70 : OutputSurface(context_provider, software_device.Pass()), | 61 : OutputSurface(context_provider, software_device.Pass()), |
71 client_(NULL), | 62 client_(NULL), |
72 num_sent_frames_(0), | 63 num_sent_frames_(0), |
73 has_external_stencil_test_(false), | 64 has_external_stencil_test_(false), |
74 suspended_for_recycle_(false), | 65 suspended_for_recycle_(false), |
75 framebuffer_(0), | 66 framebuffer_(0), |
76 overlay_candidate_validator_(nullptr) { | 67 overlay_candidate_validator_(nullptr) { |
77 if (delegated_rendering) { | 68 capabilities_.delegated_rendering = delegated_rendering; |
78 capabilities_.delegated_rendering = true; | |
79 capabilities_.max_frames_pending = 1; | |
80 } | |
81 } | 69 } |
82 | 70 |
83 FakeOutputSurface::~FakeOutputSurface() {} | 71 FakeOutputSurface::~FakeOutputSurface() {} |
84 | 72 |
85 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) { | 73 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) { |
86 if (frame->delegated_frame_data || !context_provider()) { | 74 if (frame->delegated_frame_data || !context_provider()) { |
87 frame->AssignTo(&last_sent_frame_); | 75 frame->AssignTo(&last_sent_frame_); |
88 | 76 |
89 if (last_sent_frame_.delegated_frame_data) { | 77 if (last_sent_frame_.delegated_frame_data) { |
90 resources_held_by_parent_.insert( | 78 resources_held_by_parent_.insert( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 const { | 143 const { |
156 return overlay_candidate_validator_; | 144 return overlay_candidate_validator_; |
157 } | 145 } |
158 | 146 |
159 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( | 147 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( |
160 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { | 148 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { |
161 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); | 149 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); |
162 } | 150 } |
163 | 151 |
164 } // namespace cc | 152 } // namespace cc |
OLD | NEW |