OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "third_party/khronos/GLES2/gl2ext.h" | 23 #include "third_party/khronos/GLES2/gl2ext.h" |
24 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
25 #include "ui/gfx/size.h" | 25 #include "ui/gfx/size.h" |
26 | 26 |
27 using std::set; | 27 using std::set; |
28 using std::string; | 28 using std::string; |
29 using std::vector; | 29 using std::vector; |
30 | 30 |
31 namespace cc { | 31 namespace cc { |
32 | 32 |
33 OutputSurface::OutputSurface( | 33 OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider) |
34 scoped_refptr<ContextProvider> context_provider) | |
35 : context_provider_(context_provider), | 34 : context_provider_(context_provider), |
36 has_gl_discard_backbuffer_(false), | 35 has_gl_discard_backbuffer_(false), |
37 has_swap_buffers_complete_callback_(false), | 36 has_swap_buffers_complete_callback_(false), |
38 device_scale_factor_(-1), | 37 device_scale_factor_(-1), |
39 weak_ptr_factory_(this), | 38 weak_ptr_factory_(this), |
40 max_frames_pending_(0), | 39 max_frames_pending_(0), |
41 pending_swap_buffers_(0), | 40 pending_swap_buffers_(0), |
42 needs_begin_frame_(false), | 41 needs_begin_frame_(false), |
43 begin_frame_pending_(false), | 42 begin_frame_pending_(false), |
44 client_(NULL), | 43 client_(NULL), |
45 check_for_retroactive_begin_frame_pending_(false) { | 44 check_for_retroactive_begin_frame_pending_(false), |
46 } | 45 external_stencil_test_enabled_(false) {} |
47 | 46 |
48 OutputSurface::OutputSurface( | 47 OutputSurface::OutputSurface( |
49 scoped_ptr<cc::SoftwareOutputDevice> software_device) | 48 scoped_ptr<cc::SoftwareOutputDevice> software_device) |
50 : software_device_(software_device.Pass()), | 49 : software_device_(software_device.Pass()), |
51 has_gl_discard_backbuffer_(false), | 50 has_gl_discard_backbuffer_(false), |
52 has_swap_buffers_complete_callback_(false), | 51 has_swap_buffers_complete_callback_(false), |
53 device_scale_factor_(-1), | 52 device_scale_factor_(-1), |
54 weak_ptr_factory_(this), | 53 weak_ptr_factory_(this), |
55 max_frames_pending_(0), | 54 max_frames_pending_(0), |
56 pending_swap_buffers_(0), | 55 pending_swap_buffers_(0), |
57 needs_begin_frame_(false), | 56 needs_begin_frame_(false), |
58 begin_frame_pending_(false), | 57 begin_frame_pending_(false), |
59 client_(NULL), | 58 client_(NULL), |
60 check_for_retroactive_begin_frame_pending_(false) { | 59 check_for_retroactive_begin_frame_pending_(false), |
61 } | 60 external_stencil_test_enabled_(false) {} |
62 | 61 |
63 OutputSurface::OutputSurface( | 62 OutputSurface::OutputSurface( |
64 scoped_refptr<ContextProvider> context_provider, | 63 scoped_refptr<ContextProvider> context_provider, |
65 scoped_ptr<cc::SoftwareOutputDevice> software_device) | 64 scoped_ptr<cc::SoftwareOutputDevice> software_device) |
66 : context_provider_(context_provider), | 65 : context_provider_(context_provider), |
67 software_device_(software_device.Pass()), | 66 software_device_(software_device.Pass()), |
68 has_gl_discard_backbuffer_(false), | 67 has_gl_discard_backbuffer_(false), |
69 has_swap_buffers_complete_callback_(false), | 68 has_swap_buffers_complete_callback_(false), |
70 device_scale_factor_(-1), | 69 device_scale_factor_(-1), |
71 weak_ptr_factory_(this), | 70 weak_ptr_factory_(this), |
72 max_frames_pending_(0), | 71 max_frames_pending_(0), |
73 pending_swap_buffers_(0), | 72 pending_swap_buffers_(0), |
74 needs_begin_frame_(false), | 73 needs_begin_frame_(false), |
75 begin_frame_pending_(false), | 74 begin_frame_pending_(false), |
76 client_(NULL), | 75 client_(NULL), |
77 check_for_retroactive_begin_frame_pending_(false) { | 76 check_for_retroactive_begin_frame_pending_(false), |
78 } | 77 external_stencil_test_enabled_(false) {} |
79 | 78 |
80 void OutputSurface::InitializeBeginFrameEmulation( | 79 void OutputSurface::InitializeBeginFrameEmulation( |
81 base::SingleThreadTaskRunner* task_runner, | 80 base::SingleThreadTaskRunner* task_runner, |
82 bool throttle_frame_production, | 81 bool throttle_frame_production, |
83 base::TimeDelta interval) { | 82 base::TimeDelta interval) { |
84 if (throttle_frame_production) { | 83 if (throttle_frame_production) { |
85 frame_rate_controller_.reset( | 84 frame_rate_controller_.reset( |
86 new FrameRateController( | 85 new FrameRateController( |
87 DelayBasedTimeSource::Create(interval, task_runner))); | 86 DelayBasedTimeSource::Create(interval, task_runner))); |
88 } else { | 87 } else { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 212 } |
214 | 213 |
215 void OutputSurface::DidLoseOutputSurface() { | 214 void OutputSurface::DidLoseOutputSurface() { |
216 TRACE_EVENT0("cc", "OutputSurface::DidLoseOutputSurface"); | 215 TRACE_EVENT0("cc", "OutputSurface::DidLoseOutputSurface"); |
217 begin_frame_pending_ = false; | 216 begin_frame_pending_ = false; |
218 pending_swap_buffers_ = 0; | 217 pending_swap_buffers_ = 0; |
219 client_->DidLoseOutputSurface(); | 218 client_->DidLoseOutputSurface(); |
220 } | 219 } |
221 | 220 |
222 void OutputSurface::SetExternalStencilTest(bool enabled) { | 221 void OutputSurface::SetExternalStencilTest(bool enabled) { |
223 client_->SetExternalStencilTest(enabled); | 222 external_stencil_test_enabled_ = enabled; |
224 } | 223 } |
225 | 224 |
226 void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform, | 225 void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform, |
227 gfx::Rect viewport, | 226 gfx::Rect viewport, |
228 gfx::Rect clip, | 227 gfx::Rect clip, |
229 bool valid_for_tile_management) { | 228 bool valid_for_tile_management) { |
230 client_->SetExternalDrawConstraints( | 229 client_->SetExternalDrawConstraints( |
231 transform, viewport, clip, valid_for_tile_management); | 230 transform, viewport, clip, valid_for_tile_management); |
232 } | 231 } |
233 | 232 |
234 OutputSurface::~OutputSurface() { | 233 OutputSurface::~OutputSurface() { |
235 if (frame_rate_controller_) | 234 if (frame_rate_controller_) |
236 frame_rate_controller_->SetActive(false); | 235 frame_rate_controller_->SetActive(false); |
237 ResetContext3d(); | 236 ResetContext3d(); |
238 } | 237 } |
239 | 238 |
240 bool OutputSurface::ForcedDrawToSoftwareDevice() const { | 239 bool OutputSurface::HasExternalStencilTest() const { |
241 return false; | 240 return external_stencil_test_enabled_; |
242 } | 241 } |
243 | 242 |
| 243 bool OutputSurface::ForcedDrawToSoftwareDevice() const { return false; } |
| 244 |
244 bool OutputSurface::BindToClient(cc::OutputSurfaceClient* client) { | 245 bool OutputSurface::BindToClient(cc::OutputSurfaceClient* client) { |
245 DCHECK(client); | 246 DCHECK(client); |
246 client_ = client; | 247 client_ = client; |
247 bool success = true; | 248 bool success = true; |
248 | 249 |
249 if (context_provider_) { | 250 if (context_provider_) { |
250 success = context_provider_->BindToCurrentThread(); | 251 success = context_provider_->BindToCurrentThread(); |
251 if (success) | 252 if (success) |
252 SetUpContext3d(); | 253 SetUpContext3d(); |
253 } | 254 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 "discard_backbuffer", discard_backbuffer); | 399 "discard_backbuffer", discard_backbuffer); |
399 // Just ignore the memory manager when it says to set the limit to zero | 400 // Just ignore the memory manager when it says to set the limit to zero |
400 // bytes. This will happen when the memory manager thinks that the renderer | 401 // bytes. This will happen when the memory manager thinks that the renderer |
401 // is not visible (which the renderer knows better). | 402 // is not visible (which the renderer knows better). |
402 if (policy.bytes_limit_when_visible) | 403 if (policy.bytes_limit_when_visible) |
403 client_->SetMemoryPolicy(policy); | 404 client_->SetMemoryPolicy(policy); |
404 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer); | 405 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer); |
405 } | 406 } |
406 | 407 |
407 } // namespace cc | 408 } // namespace cc |
OLD | NEW |