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

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

Issue 12041062: Have a common implementation of cc::OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 10 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/DEPS ('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/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/test_web_graphics_context_3d.h" 11 #include "cc/test/test_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 TestWebGraphicsContext3D::Create( 27 TestWebGraphicsContext3D::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 TestWebGraphicsContext3D::Create( 46 TestWebGraphicsContext3D::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; 58 virtual bool BindToClient(OutputSurfaceClient*) 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; 59 virtual void SendFrameToParentCompositor(CompositorFrame*) OVERRIDE;
68 60
69 CompositorFrame& last_sent_frame() { return last_sent_frame_; } 61 CompositorFrame& last_sent_frame() { return last_sent_frame_; }
70 size_t num_sent_frames() { return num_sent_frames_; } 62 size_t num_sent_frames() { return num_sent_frames_; }
71 63
72 private: 64 private:
73 explicit FakeOutputSurface( 65 FakeOutputSurface(
74 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent); 66 scoped_ptr<WebKit::WebGraphicsContext3D> context3d,
75 explicit FakeOutputSurface( 67 bool has_parent);
76 scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent);
77 68
78 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; 69 FakeOutputSurface(
79 scoped_ptr<SoftwareOutputDevice> software_device_; 70 scoped_ptr<SoftwareOutputDevice> software_device,
80 struct Capabilities capabilities_; 71 bool has_parent);
81 OutputSurfaceClient* client_; 72
82 CompositorFrame last_sent_frame_; 73 CompositorFrame last_sent_frame_;
83 size_t num_sent_frames_; 74 size_t num_sent_frames_;
84 }; 75 };
85 76
86 static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface() 77 static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface()
87 { 78 {
88 return FakeOutputSurface::Create3d( 79 return FakeOutputSurface::Create3d(
89 TestWebGraphicsContext3D::Create( 80 TestWebGraphicsContext3D::Create(
90 WebKit::WebGraphicsContext3D::Attributes()) 81 WebKit::WebGraphicsContext3D::Attributes())
91 .PassAs<WebKit::WebGraphicsContext3D>()) 82 .PassAs<WebKit::WebGraphicsContext3D>())
92 .PassAs<cc::OutputSurface>(); 83 .PassAs<cc::OutputSurface>();
93 } 84 }
94 85
95 } // namespace cc 86 } // namespace cc
96 87
97 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ 88 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_
OLDNEW
« no previous file with comments | « cc/test/DEPS ('k') | cc/test/fake_output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698