| 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/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "cc/output/begin_frame_args.h" | 9 #include "cc/output/begin_frame_args.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| 11 #include "cc/output/output_surface.h" | 11 #include "cc/output/output_surface.h" |
| 12 #include "cc/output/software_output_device.h" | 12 #include "cc/output/software_output_device.h" |
| 13 #include "cc/test/test_web_graphics_context_3d.h" | 13 #include "cc/test/test_web_graphics_context_3d.h" |
| 14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 class FakeOutputSurface : public OutputSurface { | 18 class FakeOutputSurface : public OutputSurface { |
| 19 public: | 19 public: |
| 20 virtual ~FakeOutputSurface(); | 20 virtual ~FakeOutputSurface(); |
| 21 | 21 |
| 22 static scoped_ptr<FakeOutputSurface> Create3d( | 22 static scoped_ptr<FakeOutputSurface> Create3d( |
| 23 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { | 23 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { |
| 24 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); | 24 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); |
| 25 } | 25 } |
| 26 | 26 |
| 27 static scoped_ptr<FakeOutputSurface> Create3d() { | 27 static scoped_ptr<FakeOutputSurface> Create3d() { |
| 28 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = | 28 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = |
| 29 TestWebGraphicsContext3D::Create( | 29 TestWebGraphicsContext3D::Create() |
| 30 WebKit::WebGraphicsContext3D::Attributes()) | |
| 31 .PassAs<WebKit::WebGraphicsContext3D>(); | 30 .PassAs<WebKit::WebGraphicsContext3D>(); |
| 32 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); | 31 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); |
| 33 } | 32 } |
| 34 | 33 |
| 35 static scoped_ptr<FakeOutputSurface> CreateSoftware( | 34 static scoped_ptr<FakeOutputSurface> CreateSoftware( |
| 36 scoped_ptr<SoftwareOutputDevice> software_device) { | 35 scoped_ptr<SoftwareOutputDevice> software_device) { |
| 37 return make_scoped_ptr( | 36 return make_scoped_ptr( |
| 38 new FakeOutputSurface(software_device.Pass(), false)); | 37 new FakeOutputSurface(software_device.Pass(), false)); |
| 39 } | 38 } |
| 40 | 39 |
| 41 static scoped_ptr<FakeOutputSurface> CreateDelegating3d( | 40 static scoped_ptr<FakeOutputSurface> CreateDelegating3d( |
| 42 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { | 41 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { |
| 43 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); | 42 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); |
| 44 } | 43 } |
| 45 | 44 |
| 46 static scoped_ptr<FakeOutputSurface> CreateDelegating3d() { | 45 static scoped_ptr<FakeOutputSurface> CreateDelegating3d() { |
| 47 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = | 46 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = |
| 48 TestWebGraphicsContext3D::Create( | 47 TestWebGraphicsContext3D::Create() |
| 49 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 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 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 void OnBeginFrame(); | 100 void OnBeginFrame(); |
| 103 | 101 |
| 104 CompositorFrame last_sent_frame_; | 102 CompositorFrame last_sent_frame_; |
| 105 size_t num_sent_frames_; | 103 size_t num_sent_frames_; |
| 106 bool needs_begin_frame_; | 104 bool needs_begin_frame_; |
| 107 bool forced_draw_to_software_device_; | 105 bool forced_draw_to_software_device_; |
| 108 base::WeakPtrFactory<FakeOutputSurface> fake_weak_ptr_factory_; | 106 base::WeakPtrFactory<FakeOutputSurface> fake_weak_ptr_factory_; |
| 109 }; | 107 }; |
| 110 | 108 |
| 111 static inline scoped_ptr<cc::OutputSurface> CreateFakeOutputSurface() { | 109 static inline scoped_ptr<cc::OutputSurface> CreateFakeOutputSurface() { |
| 112 return FakeOutputSurface::Create3d( | 110 return FakeOutputSurface::Create3d().PassAs<cc::OutputSurface>(); |
| 113 TestWebGraphicsContext3D::Create( | |
| 114 WebKit::WebGraphicsContext3D::Attributes()) | |
| 115 .PassAs<WebKit::WebGraphicsContext3D>()).PassAs<cc::OutputSurface>(); | |
| 116 } | 111 } |
| 117 | 112 |
| 118 } // namespace cc | 113 } // namespace cc |
| 119 | 114 |
| 120 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ | 115 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ |
| OLD | NEW |