Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Side by Side Diff: cc/output/output_surface.cc

Issue 640023004: cc: Make OutputSurface::SwapBuffers pure virtual (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@latinfo
Patch Set: and rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "cc/output/compositor_frame.h"
20 #include "cc/output/compositor_frame_ack.h"
21 #include "cc/output/managed_memory_policy.h" 19 #include "cc/output/managed_memory_policy.h"
22 #include "cc/output/output_surface_client.h" 20 #include "cc/output/output_surface_client.h"
23 #include "cc/scheduler/delay_based_time_source.h" 21 #include "cc/scheduler/delay_based_time_source.h"
24 #include "gpu/GLES2/gl2extchromium.h" 22 #include "gpu/GLES2/gl2extchromium.h"
25 #include "gpu/command_buffer/client/context_support.h" 23 #include "gpu/command_buffer/client/context_support.h"
26 #include "gpu/command_buffer/client/gles2_interface.h" 24 #include "gpu/command_buffer/client/gles2_interface.h"
27 #include "ui/gfx/frame_time.h" 25 #include "ui/gfx/frame_time.h"
28 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
29 #include "ui/gfx/geometry/size.h" 27 #include "ui/gfx/geometry/size.h"
30 28
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 213
216 gfx::Size OutputSurface::SurfaceSize() const { 214 gfx::Size OutputSurface::SurfaceSize() const {
217 return surface_size_; 215 return surface_size_;
218 } 216 }
219 217
220 void OutputSurface::BindFramebuffer() { 218 void OutputSurface::BindFramebuffer() {
221 DCHECK(context_provider_.get()); 219 DCHECK(context_provider_.get());
222 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); 220 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0);
223 } 221 }
224 222
225 void OutputSurface::SwapBuffers(CompositorFrame* frame) {
226 // TODO(sievers): Make OutputSurface::SwapBuffers() pure virtual.
227 // The implementation here is used for tests only.
228 if (frame->software_frame_data) {
229 PostSwapBuffersComplete();
230 client_->DidSwapBuffers();
231 return;
232 }
233
234 DCHECK(context_provider_.get());
235 DCHECK(frame->gl_frame_data);
236
237 if (frame->gl_frame_data->sub_buffer_rect ==
238 gfx::Rect(frame->gl_frame_data->size)) {
239 context_provider_->ContextSupport()->Swap();
240 } else {
241 context_provider_->ContextSupport()->PartialSwapBuffers(
242 frame->gl_frame_data->sub_buffer_rect);
243 }
244 uint32_t sync_point =
245 context_provider_->ContextGL()->InsertSyncPointCHROMIUM();
246 context_provider_->ContextSupport()->SignalSyncPoint(
247 sync_point,
248 base::Bind(&OutputSurface::OnSwapBuffersComplete,
249 weak_ptr_factory_.GetWeakPtr()));
250
251 client_->DidSwapBuffers();
252 }
253
254 void OutputSurface::PostSwapBuffersComplete() { 223 void OutputSurface::PostSwapBuffersComplete() {
255 base::MessageLoop::current()->PostTask( 224 base::MessageLoop::current()->PostTask(
256 FROM_HERE, 225 FROM_HERE,
257 base::Bind(&OutputSurface::OnSwapBuffersComplete, 226 base::Bind(&OutputSurface::OnSwapBuffersComplete,
258 weak_ptr_factory_.GetWeakPtr())); 227 weak_ptr_factory_.GetWeakPtr()));
259 } 228 }
260 229
261 // We don't post tasks bound to the client directly since they might run 230 // We don't post tasks bound to the client directly since they might run
262 // after the OutputSurface has been destroyed. 231 // after the OutputSurface has been destroyed.
263 void OutputSurface::OnSwapBuffersComplete() { 232 void OutputSurface::OnSwapBuffersComplete() {
264 client_->DidSwapBuffersComplete(); 233 client_->DidSwapBuffersComplete();
265 } 234 }
266 235
267 void OutputSurface::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { 236 void OutputSurface::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
268 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", 237 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy",
269 "bytes_limit_when_visible", policy.bytes_limit_when_visible); 238 "bytes_limit_when_visible", policy.bytes_limit_when_visible);
270 // Just ignore the memory manager when it says to set the limit to zero 239 // Just ignore the memory manager when it says to set the limit to zero
271 // bytes. This will happen when the memory manager thinks that the renderer 240 // bytes. This will happen when the memory manager thinks that the renderer
272 // is not visible (which the renderer knows better). 241 // is not visible (which the renderer knows better).
273 if (policy.bytes_limit_when_visible) 242 if (policy.bytes_limit_when_visible)
274 client_->SetMemoryPolicy(policy); 243 client_->SetMemoryPolicy(policy);
275 } 244 }
276 245
277 } // namespace cc 246 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698