Chromium Code Reviews| 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 #ifndef CC_TEST_FAKE_OUTPUT_SURFACE_H_ | 5 #ifndef CC_TEST_FAKE_OUTPUT_SURFACE_H_ |
| 6 #define CC_TEST_FAKE_OUTPUT_SURFACE_H_ | 6 #define CC_TEST_FAKE_OUTPUT_SURFACE_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "cc/compositor_frame.h" | 8 #include "cc/compositor_frame.h" |
| 11 #include "cc/output_surface.h" | 9 #include "cc/output_surface.h" |
| 12 #include "cc/test/fake_software_output_device.h" | 10 #include "cc/test/fake_software_output_device.h" |
| 13 #include "cc/test/fake_web_graphics_context_3d.h" | 11 #include "cc/test/fake_web_graphics_context_3d.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" |
| 15 | 13 |
| 16 namespace cc { | 14 namespace cc { |
| 17 | 15 |
| 18 class FakeOutputSurface : public OutputSurface { | 16 class FakeOutputSurface : public OutputSurface { |
| 19 public: | 17 public: |
| 20 virtual ~FakeOutputSurface(); | 18 virtual ~FakeOutputSurface(); |
| 21 | 19 |
| 22 static inline scoped_ptr<FakeOutputSurface> Create3d( | 20 static scoped_ptr<FakeOutputSurface> Create3d( |
| 23 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { | 21 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { |
| 24 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); | 22 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); |
| 25 } | 23 } |
| 26 | 24 |
| 27 static inline scoped_ptr<FakeOutputSurface> Create3d() { | 25 static scoped_ptr<FakeOutputSurface> Create3d() { |
| 28 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = | 26 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = |
| 29 FakeWebGraphicsContext3D::Create( | 27 FakeWebGraphicsContext3D::Create( |
| 30 WebKit::WebGraphicsContext3D::Attributes()) | 28 WebKit::WebGraphicsContext3D::Attributes()) |
| 31 .PassAs<WebKit::WebGraphicsContext3D>(); | 29 .PassAs<WebKit::WebGraphicsContext3D>(); |
| 32 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); | 30 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); |
| 33 } | 31 } |
| 34 | 32 |
| 35 static inline scoped_ptr<FakeOutputSurface> CreateSoftware( | 33 static scoped_ptr<FakeOutputSurface> CreateSoftware( |
| 36 scoped_ptr<SoftwareOutputDevice> software_device) { | 34 scoped_ptr<SoftwareOutputDevice> software_device) { |
| 37 return make_scoped_ptr( | 35 return make_scoped_ptr( |
| 38 new FakeOutputSurface(software_device.Pass(), false)); | 36 new FakeOutputSurface(software_device.Pass(), false)); |
| 39 } | 37 } |
| 40 | 38 |
| 41 static inline scoped_ptr<FakeOutputSurface> CreateDelegating3d( | 39 static scoped_ptr<FakeOutputSurface> CreateDelegating3d( |
| 42 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { | 40 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { |
| 43 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); | 41 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); |
| 44 } | 42 } |
| 45 | 43 |
| 46 static inline scoped_ptr<FakeOutputSurface> CreateDelegating3d() { | 44 static scoped_ptr<FakeOutputSurface> CreateDelegating3d() { |
| 47 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = | 45 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = |
| 48 FakeWebGraphicsContext3D::Create( | 46 FakeWebGraphicsContext3D::Create( |
| 49 WebKit::WebGraphicsContext3D::Attributes()) | 47 WebKit::WebGraphicsContext3D::Attributes()) |
| 50 .PassAs<WebKit::WebGraphicsContext3D>(); | 48 .PassAs<WebKit::WebGraphicsContext3D>(); |
| 51 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); | 49 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); |
| 52 } | 50 } |
| 53 | 51 |
| 54 static inline scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware( | 52 static scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware( |
| 55 scoped_ptr<SoftwareOutputDevice> software_device) { | 53 scoped_ptr<SoftwareOutputDevice> software_device) { |
| 56 return make_scoped_ptr( | 54 return make_scoped_ptr( |
| 57 new FakeOutputSurface(software_device.Pass(), true)); | 55 new FakeOutputSurface(software_device.Pass(), true)); |
| 58 } | 56 } |
| 59 | 57 |
| 60 virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE; | |
| 61 | |
| 62 virtual const struct Capabilities& Capabilities() const OVERRIDE; | |
| 63 | |
| 64 virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE; | |
| 65 virtual SoftwareOutputDevice* SoftwareDevice() const OVERRIDE; | |
| 66 | |
| 67 virtual void SendFrameToParentCompositor(CompositorFrame*) OVERRIDE; | 58 virtual void SendFrameToParentCompositor(CompositorFrame*) OVERRIDE; |
| 68 | 59 |
| 69 CompositorFrame& last_sent_frame() { return last_sent_frame_; } | 60 CompositorFrame& last_sent_frame() { return last_sent_frame_; } |
| 70 size_t num_sent_frames() { return num_sent_frames_; } | 61 size_t num_sent_frames() { return num_sent_frames_; } |
| 71 | 62 |
| 72 private: | 63 private: |
| 73 explicit FakeOutputSurface( | 64 FakeOutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
|
danakj
2013/01/24 02:03:06
nit: line wrap at the ( please
| |
| 74 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent); | 65 bool has_parent); |
| 75 explicit FakeOutputSurface( | |
| 76 scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent); | |
| 77 | 66 |
| 78 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; | 67 FakeOutputSurface(scoped_ptr<SoftwareOutputDevice> software_device, |
|
danakj
2013/01/24 02:03:06
same
| |
| 79 scoped_ptr<SoftwareOutputDevice> software_device_; | 68 bool has_parent); |
| 80 struct Capabilities capabilities_; | 69 |
| 81 OutputSurfaceClient* client_; | |
| 82 CompositorFrame last_sent_frame_; | 70 CompositorFrame last_sent_frame_; |
| 83 size_t num_sent_frames_; | 71 size_t num_sent_frames_; |
| 84 }; | 72 }; |
| 85 | 73 |
| 86 static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface() | 74 static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface() { |
| 87 { | 75 return FakeOutputSurface::Create3d( |
| 88 return FakeOutputSurface::Create3d( | 76 FakeWebGraphicsContext3D::Create( |
| 89 FakeWebGraphicsContext3D::Create( | 77 WebKit::WebGraphicsContext3D::Attributes()) |
| 90 WebKit::WebGraphicsContext3D::Attributes()) | 78 .PassAs<WebKit::WebGraphicsContext3D>()) |
| 91 .PassAs<WebKit::WebGraphicsContext3D>()) | 79 .PassAs<cc::OutputSurface>(); |
| 92 .PassAs<cc::OutputSurface>(); | |
| 93 } | 80 } |
| 94 | 81 |
| 95 } // namespace cc | 82 } // namespace cc |
| 96 | 83 |
| 97 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ | 84 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ |
| OLD | NEW |