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.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" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 FakeOutputSurface::FakeOutputSurface( | 24 FakeOutputSurface::FakeOutputSurface( |
25 scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent) | 25 scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent) |
26 : OutputSurface(software_device.Pass()), | 26 : OutputSurface(software_device.Pass()), |
27 num_sent_frames_(0), | 27 num_sent_frames_(0), |
28 forced_draw_to_software_device_(false), | 28 forced_draw_to_software_device_(false), |
29 weak_ptr_factory_(this) { | 29 weak_ptr_factory_(this) { |
30 capabilities_.has_parent_compositor = has_parent; | 30 capabilities_.has_parent_compositor = has_parent; |
31 } | 31 } |
32 | 32 |
| 33 FakeOutputSurface::FakeOutputSurface( |
| 34 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
| 35 scoped_ptr<SoftwareOutputDevice> software_device, |
| 36 bool has_parent) |
| 37 : OutputSurface(context3d.Pass(), software_device.Pass()), |
| 38 num_sent_frames_(0), |
| 39 forced_draw_to_software_device_(false), |
| 40 weak_ptr_factory_(this) { |
| 41 capabilities_.has_parent_compositor = has_parent; |
| 42 } |
| 43 |
33 FakeOutputSurface::~FakeOutputSurface() {} | 44 FakeOutputSurface::~FakeOutputSurface() {} |
34 | 45 |
35 void FakeOutputSurface::SendFrameToParentCompositor( | 46 void FakeOutputSurface::SendFrameToParentCompositor( |
36 CompositorFrame* frame) { | 47 CompositorFrame* frame) { |
37 frame->AssignTo(&last_sent_frame_); | 48 frame->AssignTo(&last_sent_frame_); |
38 ++num_sent_frames_; | 49 ++num_sent_frames_; |
39 base::MessageLoop::current()->PostTask( | 50 base::MessageLoop::current()->PostTask( |
40 FROM_HERE, base::Bind(&FakeOutputSurface::SendFrameAck, | 51 FROM_HERE, base::Bind(&FakeOutputSurface::SendFrameAck, |
41 weak_ptr_factory_.GetWeakPtr())); | 52 weak_ptr_factory_.GetWeakPtr())); |
42 } | 53 } |
43 | 54 |
44 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) { | 55 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) { |
45 needs_begin_frame_ = enable; | 56 needs_begin_frame_ = enable; |
46 } | 57 } |
47 | 58 |
48 void FakeOutputSurface::BeginFrame(base::TimeTicks frame_time) { | 59 void FakeOutputSurface::BeginFrame(base::TimeTicks frame_time) { |
49 client_->BeginFrame(frame_time); | 60 client_->BeginFrame(frame_time); |
50 } | 61 } |
51 | 62 |
52 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { | 63 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { |
53 return forced_draw_to_software_device_; | 64 return forced_draw_to_software_device_; |
54 } | 65 } |
55 | 66 |
56 void FakeOutputSurface::SendFrameAck() { | 67 void FakeOutputSurface::SendFrameAck() { |
57 CompositorFrameAck ack; | 68 CompositorFrameAck ack; |
58 client_->OnSendFrameToParentCompositorAck(ack); | 69 client_->OnSendFrameToParentCompositorAck(ack); |
59 } | 70 } |
60 | 71 |
61 } // namespace cc | 72 } // namespace cc |
OLD | NEW |