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

Side by Side Diff: cc/test/fake_output_surface.cc

Issue 16304003: Unified OutputSurface::SwapBuffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to 205473 Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « cc/test/fake_output_surface.h ('k') | cc/test/layer_tree_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 8 #include "base/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 11
12 namespace cc { 12 namespace cc {
13 13
14 FakeOutputSurface::FakeOutputSurface( 14 FakeOutputSurface::FakeOutputSurface(
15 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent) 15 scoped_ptr<WebKit::WebGraphicsContext3D> context3d,
16 bool delegated_rendering)
16 : OutputSurface(context3d.Pass()), 17 : OutputSurface(context3d.Pass()),
17 num_sent_frames_(0), 18 num_sent_frames_(0),
18 needs_begin_frame_(false), 19 needs_begin_frame_(false),
19 forced_draw_to_software_device_(false), 20 forced_draw_to_software_device_(false) {
20 weak_ptr_factory_(this) { 21 if (delegated_rendering) {
21 capabilities_.has_parent_compositor = has_parent; 22 capabilities_.delegated_rendering = true;
23 capabilities_.max_frames_pending = 1;
24 }
22 } 25 }
23 26
24 FakeOutputSurface::FakeOutputSurface( 27 FakeOutputSurface::FakeOutputSurface(
25 scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent) 28 scoped_ptr<SoftwareOutputDevice> software_device, bool delegated_rendering)
26 : OutputSurface(software_device.Pass()), 29 : OutputSurface(software_device.Pass()),
27 num_sent_frames_(0), 30 num_sent_frames_(0),
28 forced_draw_to_software_device_(false), 31 forced_draw_to_software_device_(false) {
29 weak_ptr_factory_(this) { 32 if (delegated_rendering) {
30 capabilities_.has_parent_compositor = has_parent; 33 capabilities_.delegated_rendering = true;
34 capabilities_.max_frames_pending = 1;
35 }
31 } 36 }
32 37
33 FakeOutputSurface::FakeOutputSurface( 38 FakeOutputSurface::FakeOutputSurface(
34 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, 39 scoped_ptr<WebKit::WebGraphicsContext3D> context3d,
35 scoped_ptr<SoftwareOutputDevice> software_device, 40 scoped_ptr<SoftwareOutputDevice> software_device,
36 bool has_parent) 41 bool delegated_rendering)
37 : OutputSurface(context3d.Pass(), software_device.Pass()), 42 : OutputSurface(context3d.Pass(), software_device.Pass()),
38 num_sent_frames_(0), 43 num_sent_frames_(0),
39 forced_draw_to_software_device_(false), 44 forced_draw_to_software_device_(false) {
40 weak_ptr_factory_(this) { 45 if (delegated_rendering) {
41 capabilities_.has_parent_compositor = has_parent; 46 capabilities_.delegated_rendering = true;
47 capabilities_.max_frames_pending = 1;
48 }
42 } 49 }
43 50
44 FakeOutputSurface::~FakeOutputSurface() {} 51 FakeOutputSurface::~FakeOutputSurface() {}
45 52
46 void FakeOutputSurface::SendFrameToParentCompositor( 53 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) {
47 CompositorFrame* frame) { 54 if (frame->software_frame_data || frame->delegated_frame_data ||
48 frame->AssignTo(&last_sent_frame_); 55 !context3d()) {
49 ++num_sent_frames_; 56 frame->AssignTo(&last_sent_frame_);
50 base::MessageLoop::current()->PostTask( 57 ++num_sent_frames_;
51 FROM_HERE, base::Bind(&FakeOutputSurface::SendFrameAck, 58 PostSwapBuffersComplete();
52 weak_ptr_factory_.GetWeakPtr())); 59 } else {
60 OutputSurface::SwapBuffers(frame);
61 frame->AssignTo(&last_sent_frame_);
62 ++num_sent_frames_;
63 }
53 } 64 }
54 65
55 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) { 66 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) {
56 needs_begin_frame_ = enable; 67 needs_begin_frame_ = enable;
57 } 68 }
58 69
59 void FakeOutputSurface::BeginFrame(base::TimeTicks frame_time) { 70 void FakeOutputSurface::BeginFrame(base::TimeTicks frame_time) {
60 client_->BeginFrame(frame_time); 71 client_->BeginFrame(frame_time);
61 } 72 }
62 73
63 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { 74 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const {
64 return forced_draw_to_software_device_; 75 return forced_draw_to_software_device_;
65 } 76 }
66 77
67 void FakeOutputSurface::SendFrameAck() {
68 CompositorFrameAck ack;
69 client_->OnSendFrameToParentCompositorAck(ack);
70 }
71
72 } // namespace cc 78 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_output_surface.h ('k') | cc/test/layer_tree_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698