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/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); | 51 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); |
52 } | 52 } |
53 | 53 |
54 static scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware( | 54 static scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware( |
55 scoped_ptr<SoftwareOutputDevice> software_device) { | 55 scoped_ptr<SoftwareOutputDevice> software_device) { |
56 return make_scoped_ptr( | 56 return make_scoped_ptr( |
57 new FakeOutputSurface(software_device.Pass(), true)); | 57 new FakeOutputSurface(software_device.Pass(), true)); |
58 } | 58 } |
59 | 59 |
60 static scoped_ptr<FakeOutputSurface> CreateDeferredGL( | 60 static scoped_ptr<FakeOutputSurface> CreateDeferredGL( |
| 61 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
61 scoped_ptr<SoftwareOutputDevice> software_device) { | 62 scoped_ptr<SoftwareOutputDevice> software_device) { |
62 scoped_ptr<FakeOutputSurface> result( | 63 scoped_ptr<FakeOutputSurface> result( |
63 new FakeOutputSurface(software_device.Pass(), false)); | 64 new FakeOutputSurface(context3d.Pass(), software_device.Pass(), false)); |
64 result->capabilities_.deferred_gl_initialization = true; | 65 result->capabilities_.deferred_gl_initialization = true; |
65 return result.Pass(); | 66 return result.Pass(); |
66 } | 67 } |
67 | 68 |
68 virtual void SendFrameToParentCompositor(CompositorFrame* frame) OVERRIDE; | 69 virtual void SendFrameToParentCompositor(CompositorFrame* frame) OVERRIDE; |
69 | 70 |
70 CompositorFrame& last_sent_frame() { return last_sent_frame_; } | 71 CompositorFrame& last_sent_frame() { return last_sent_frame_; } |
71 size_t num_sent_frames() { return num_sent_frames_; } | 72 size_t num_sent_frames() { return num_sent_frames_; } |
72 | 73 |
73 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; | 74 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; |
74 bool needs_begin_frame() const { | 75 bool needs_begin_frame() const { |
75 return needs_begin_frame_; | 76 return needs_begin_frame_; |
76 } | 77 } |
77 void BeginFrame(base::TimeTicks frame_time); | 78 void BeginFrame(base::TimeTicks frame_time); |
78 | 79 |
79 void set_forced_draw_to_software_device(bool forced) { | 80 void set_forced_draw_to_software_device(bool forced) { |
80 forced_draw_to_software_device_ = forced; | 81 forced_draw_to_software_device_ = forced; |
81 } | 82 } |
82 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; | 83 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; |
83 | 84 |
84 protected: | 85 protected: |
85 FakeOutputSurface( | 86 FakeOutputSurface( |
86 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, | 87 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
87 bool has_parent); | 88 bool has_parent); |
88 | 89 |
89 FakeOutputSurface( | 90 FakeOutputSurface( |
90 scoped_ptr<SoftwareOutputDevice> software_device, | 91 scoped_ptr<SoftwareOutputDevice> software_device, |
91 bool has_parent); | 92 bool has_parent); |
92 | 93 |
| 94 FakeOutputSurface( |
| 95 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
| 96 scoped_ptr<SoftwareOutputDevice> software_device, |
| 97 bool has_parent); |
| 98 |
93 void SendFrameAck(); | 99 void SendFrameAck(); |
94 | 100 |
95 CompositorFrame last_sent_frame_; | 101 CompositorFrame last_sent_frame_; |
96 size_t num_sent_frames_; | 102 size_t num_sent_frames_; |
97 bool needs_begin_frame_; | 103 bool needs_begin_frame_; |
98 bool forced_draw_to_software_device_; | 104 bool forced_draw_to_software_device_; |
99 base::WeakPtrFactory<FakeOutputSurface> weak_ptr_factory_; | 105 base::WeakPtrFactory<FakeOutputSurface> weak_ptr_factory_; |
100 }; | 106 }; |
101 | 107 |
102 static inline scoped_ptr<cc::OutputSurface> CreateFakeOutputSurface() { | 108 static inline scoped_ptr<cc::OutputSurface> CreateFakeOutputSurface() { |
103 return FakeOutputSurface::Create3d( | 109 return FakeOutputSurface::Create3d( |
104 TestWebGraphicsContext3D::Create( | 110 TestWebGraphicsContext3D::Create( |
105 WebKit::WebGraphicsContext3D::Attributes()) | 111 WebKit::WebGraphicsContext3D::Attributes()) |
106 .PassAs<WebKit::WebGraphicsContext3D>()).PassAs<cc::OutputSurface>(); | 112 .PassAs<WebKit::WebGraphicsContext3D>()).PassAs<cc::OutputSurface>(); |
107 } | 113 } |
108 | 114 |
109 } // namespace cc | 115 } // namespace cc |
110 | 116 |
111 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ | 117 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ |
OLD | NEW |