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 namespace cc { | 7 namespace cc { |
8 | 8 |
9 FakeOutputSurface::FakeOutputSurface( | 9 FakeOutputSurface::FakeOutputSurface( |
10 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent) { | 10 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent) |
| 11 : num_sent_frames_(0) { |
11 context3d_ = context3d.Pass(); | 12 context3d_ = context3d.Pass(); |
12 capabilities_.has_parent_compositor = has_parent; | 13 capabilities_.has_parent_compositor = has_parent; |
13 } | 14 } |
14 | 15 |
15 FakeOutputSurface::FakeOutputSurface( | 16 FakeOutputSurface::FakeOutputSurface( |
16 scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent) { | 17 scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent) |
| 18 : num_sent_frames_(0) { |
17 software_device_ = software_device.Pass(); | 19 software_device_ = software_device.Pass(); |
18 capabilities_.has_parent_compositor = has_parent; | 20 capabilities_.has_parent_compositor = has_parent; |
19 } | 21 } |
20 | 22 |
21 FakeOutputSurface::~FakeOutputSurface() {} | 23 FakeOutputSurface::~FakeOutputSurface() {} |
22 | 24 |
23 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { | 25 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { |
24 if (!context3d_) | 26 if (!context3d_) |
25 return true; | 27 return true; |
26 DCHECK(client); | 28 DCHECK(client); |
27 if (!context3d_->makeContextCurrent()) | 29 if (!context3d_->makeContextCurrent()) |
28 return false; | 30 return false; |
29 client_ = client; | 31 client_ = client; |
30 return true; | 32 return true; |
31 } | 33 } |
32 | 34 |
33 const struct OutputSurface::Capabilities& FakeOutputSurface::Capabilities() | 35 const struct OutputSurface::Capabilities& FakeOutputSurface::Capabilities() |
34 const { | 36 const { |
35 return capabilities_; | 37 return capabilities_; |
36 } | 38 } |
37 | 39 |
38 WebKit::WebGraphicsContext3D* FakeOutputSurface::Context3D() const { | 40 WebKit::WebGraphicsContext3D* FakeOutputSurface::Context3D() const { |
39 return context3d_.get(); | 41 return context3d_.get(); |
40 } | 42 } |
41 | 43 |
42 SoftwareOutputDevice* FakeOutputSurface::SoftwareDevice() const { | 44 SoftwareOutputDevice* FakeOutputSurface::SoftwareDevice() const { |
43 return software_device_.get(); | 45 return software_device_.get(); |
44 } | 46 } |
45 | 47 |
46 void FakeOutputSurface::SendFrameToParentCompositor(const CompositorFrame&) {} | 48 void FakeOutputSurface::SendFrameToParentCompositor( |
| 49 CompositorFrame* frame) { |
| 50 frame->AssignTo(&last_sent_frame_); |
| 51 ++num_sent_frames_; |
| 52 } |
47 | 53 |
48 } // namespace cc | 54 } // namespace cc |
OLD | NEW |