Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: cc/test/fake_output_surface.h

Issue 20185002: ContextProvider in OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: contextprovider: don't access Context3d() in OutputSurface contructors, it's not bound yet Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/test/fake_layer_tree_host_client.cc ('k') | cc/test/fake_output_surface.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h"
9 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "cc/debug/test_context_provider.h"
10 #include "cc/debug/test_web_graphics_context_3d.h" 12 #include "cc/debug/test_web_graphics_context_3d.h"
11 #include "cc/output/begin_frame_args.h" 13 #include "cc/output/begin_frame_args.h"
12 #include "cc/output/compositor_frame.h" 14 #include "cc/output/compositor_frame.h"
13 #include "cc/output/output_surface.h" 15 #include "cc/output/output_surface.h"
14 #include "cc/output/software_output_device.h" 16 #include "cc/output/software_output_device.h"
15 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
16 17
17 namespace cc { 18 namespace cc {
18 19
19 class FakeOutputSurface : public OutputSurface { 20 class FakeOutputSurface : public OutputSurface {
20 public: 21 public:
21 virtual ~FakeOutputSurface(); 22 virtual ~FakeOutputSurface();
22 23
23 static scoped_ptr<FakeOutputSurface> Create3d( 24 static scoped_ptr<FakeOutputSurface> Create3d() {
24 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { 25 return make_scoped_ptr(new FakeOutputSurface(
25 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); 26 TestContextProvider::Create(), false));
26 } 27 }
27 28
28 static scoped_ptr<FakeOutputSurface> Create3d() { 29 static scoped_ptr<FakeOutputSurface> Create3d(
29 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = 30 scoped_refptr<TestContextProvider> context_provider) {
30 TestWebGraphicsContext3D::Create() 31 return make_scoped_ptr(new FakeOutputSurface(context_provider, false));
31 .PassAs<WebKit::WebGraphicsContext3D>(); 32 }
32 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); 33
34 static scoped_ptr<FakeOutputSurface> Create3d(
35 scoped_ptr<TestWebGraphicsContext3D> context) {
36 return make_scoped_ptr(new FakeOutputSurface(
37 TestContextProvider::Create(context.Pass()), false));
33 } 38 }
34 39
35 static scoped_ptr<FakeOutputSurface> CreateSoftware( 40 static scoped_ptr<FakeOutputSurface> CreateSoftware(
36 scoped_ptr<SoftwareOutputDevice> software_device) { 41 scoped_ptr<SoftwareOutputDevice> software_device) {
37 return make_scoped_ptr( 42 return make_scoped_ptr(new FakeOutputSurface(software_device.Pass(),
38 new FakeOutputSurface(software_device.Pass(), false)); 43 false));
44 }
45
46 static scoped_ptr<FakeOutputSurface> CreateDelegating3d() {
47 return make_scoped_ptr(new FakeOutputSurface(
48 TestContextProvider::Create(), true));
39 } 49 }
40 50
41 static scoped_ptr<FakeOutputSurface> CreateDelegating3d( 51 static scoped_ptr<FakeOutputSurface> CreateDelegating3d(
42 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { 52 scoped_refptr<TestContextProvider> context_provider) {
43 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); 53 return make_scoped_ptr(new FakeOutputSurface(context_provider, true));
44 } 54 }
45 55
46 static scoped_ptr<FakeOutputSurface> CreateDelegating3d() { 56 static scoped_ptr<FakeOutputSurface> CreateDelegating3d(
47 scoped_ptr<WebKit::WebGraphicsContext3D> context3d = 57 scoped_ptr<TestWebGraphicsContext3D> context) {
48 TestWebGraphicsContext3D::Create() 58 return make_scoped_ptr(new FakeOutputSurface(
49 .PassAs<WebKit::WebGraphicsContext3D>(); 59 TestContextProvider::Create(context.Pass()), true));
50 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true));
51 } 60 }
52 61
53 static scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware( 62 static scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware(
54 scoped_ptr<SoftwareOutputDevice> software_device) { 63 scoped_ptr<SoftwareOutputDevice> software_device) {
55 return make_scoped_ptr( 64 return make_scoped_ptr(
56 new FakeOutputSurface(software_device.Pass(), true)); 65 new FakeOutputSurface(software_device.Pass(), true));
57 } 66 }
58 67
59 // TODO(boliu): Use a general factory that takes Capabilities arg. 68 // TODO(boliu): Use a general factory that takes Capabilities arg.
60 static scoped_ptr<FakeOutputSurface> CreateDeferredGL( 69 static scoped_ptr<FakeOutputSurface> CreateDeferredGL(
61 scoped_ptr<SoftwareOutputDevice> software_device) { 70 scoped_ptr<SoftwareOutputDevice> software_device) {
62 scoped_ptr<FakeOutputSurface> result( 71 scoped_ptr<FakeOutputSurface> result(
63 new FakeOutputSurface(software_device.Pass(), false)); 72 new FakeOutputSurface(software_device.Pass(), false));
64 result->capabilities_.deferred_gl_initialization = true; 73 result->capabilities_.deferred_gl_initialization = true;
65 return result.Pass(); 74 return result.Pass();
66 } 75 }
67 76
68 static scoped_ptr<FakeOutputSurface> CreateAlwaysDrawAndSwap3d() { 77 static scoped_ptr<FakeOutputSurface> CreateAlwaysDrawAndSwap3d() {
69 scoped_ptr<FakeOutputSurface> result(Create3d()); 78 scoped_ptr<FakeOutputSurface> surface(Create3d());
70 result->capabilities_.draw_and_swap_full_viewport_every_frame = true; 79 surface->capabilities_.draw_and_swap_full_viewport_every_frame = true;
71 return result.Pass(); 80 return surface.Pass();
72 } 81 }
73 82
74 CompositorFrame& last_sent_frame() { return last_sent_frame_; } 83 CompositorFrame& last_sent_frame() { return last_sent_frame_; }
75 size_t num_sent_frames() { return num_sent_frames_; } 84 size_t num_sent_frames() { return num_sent_frames_; }
76 85
77 virtual void SwapBuffers(CompositorFrame* frame) OVERRIDE; 86 virtual void SwapBuffers(CompositorFrame* frame) OVERRIDE;
78 87
79 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; 88 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE;
80 bool needs_begin_frame() const { 89 bool needs_begin_frame() const {
81 return needs_begin_frame_; 90 return needs_begin_frame_;
82 } 91 }
83 92
84 void set_forced_draw_to_software_device(bool forced) { 93 void set_forced_draw_to_software_device(bool forced) {
85 forced_draw_to_software_device_ = forced; 94 forced_draw_to_software_device_ = forced;
86 } 95 }
87 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; 96 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE;
88 97
89 virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE; 98 virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE;
90 99
91 bool SetAndInitializeContext3D(
92 scoped_ptr<WebKit::WebGraphicsContext3D> context3d);
93
94 using OutputSurface::ReleaseGL; 100 using OutputSurface::ReleaseGL;
101 using OutputSurface::InitializeAndSetContext3d;
95 102
96 void SetTreeActivationCallback(const base::Closure& callback); 103 void SetTreeActivationCallback(const base::Closure& callback);
97 104
98 const TransferableResourceArray& resources_held_by_parent() { 105 const TransferableResourceArray& resources_held_by_parent() {
99 return resources_held_by_parent_; 106 return resources_held_by_parent_;
100 } 107 }
101 108
102 void ReturnResource(unsigned id, CompositorFrameAck* ack); 109 void ReturnResource(unsigned id, CompositorFrameAck* ack);
103 110
104 protected: 111 protected:
105 FakeOutputSurface( 112 FakeOutputSurface(
106 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, 113 scoped_refptr<ContextProvider> context_provider,
107 bool delegated_rendering); 114 bool delegated_rendering);
108 115
109 FakeOutputSurface( 116 FakeOutputSurface(
110 scoped_ptr<SoftwareOutputDevice> software_device, 117 scoped_ptr<SoftwareOutputDevice> software_device,
111 bool delegated_rendering); 118 bool delegated_rendering);
112 119
113 FakeOutputSurface( 120 FakeOutputSurface(
114 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, 121 scoped_refptr<ContextProvider> context_provider,
115 scoped_ptr<SoftwareOutputDevice> software_device, 122 scoped_ptr<SoftwareOutputDevice> software_device,
116 bool delegated_rendering); 123 bool delegated_rendering);
117 124
118 void OnBeginFrame(); 125 void OnBeginFrame();
119 126
120 OutputSurfaceClient* client_; 127 OutputSurfaceClient* client_;
121 CompositorFrame last_sent_frame_; 128 CompositorFrame last_sent_frame_;
122 size_t num_sent_frames_; 129 size_t num_sent_frames_;
123 bool needs_begin_frame_; 130 bool needs_begin_frame_;
124 bool forced_draw_to_software_device_; 131 bool forced_draw_to_software_device_;
125 base::WeakPtrFactory<FakeOutputSurface> fake_weak_ptr_factory_; 132 base::WeakPtrFactory<FakeOutputSurface> fake_weak_ptr_factory_;
126 TransferableResourceArray resources_held_by_parent_; 133 TransferableResourceArray resources_held_by_parent_;
127 }; 134 };
128 135
129 static inline scoped_ptr<cc::OutputSurface> CreateFakeOutputSurface() { 136 static inline scoped_ptr<OutputSurface> CreateFakeOutputSurface() {
130 return FakeOutputSurface::Create3d().PassAs<cc::OutputSurface>(); 137 return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
131 } 138 }
132 139
133 } // namespace cc 140 } // namespace cc
134 141
135 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ 142 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_
OLDNEW
« no previous file with comments | « cc/test/fake_layer_tree_host_client.cc ('k') | cc/test/fake_output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698