Enabling tests which should be fixed by r173829.
[chromium-blink-merge.git] / cc / test / fake_output_surface.h
blob70e79b161fa48816ce75e02a16d2c1bc5758ca12
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
3 // found in the LICENSE file.
5 #ifndef CC_TEST_FAKE_OUTPUT_SURFACE_H_
6 #define CC_TEST_FAKE_OUTPUT_SURFACE_H_
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/output_surface.h"
11 #include "cc/test/fake_software_output_device.h"
12 #include "cc/test/fake_web_graphics_context_3d.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
15 namespace cc {
17 class FakeOutputSurface : public OutputSurface {
18 public:
19 virtual ~FakeOutputSurface();
21 static inline scoped_ptr<FakeOutputSurface> Create3d(
22 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) {
23 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false));
26 static inline scoped_ptr<FakeOutputSurface> Create3d() {
27 scoped_ptr<WebKit::WebGraphicsContext3D> context3d =
28 FakeWebGraphicsContext3D::Create(
29 WebKit::WebGraphicsContext3D::Attributes())
30 .PassAs<WebKit::WebGraphicsContext3D>();
31 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false));
34 static inline scoped_ptr<FakeOutputSurface> CreateSoftware(
35 scoped_ptr<SoftwareOutputDevice> software_device) {
36 return make_scoped_ptr(
37 new FakeOutputSurface(software_device.Pass(), false));
40 static inline scoped_ptr<FakeOutputSurface> CreateDelegating3d(
41 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) {
42 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true));
45 static inline scoped_ptr<FakeOutputSurface> CreateDelegating3d() {
46 scoped_ptr<WebKit::WebGraphicsContext3D> context3d =
47 FakeWebGraphicsContext3D::Create(
48 WebKit::WebGraphicsContext3D::Attributes())
49 .PassAs<WebKit::WebGraphicsContext3D>();
50 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true));
53 static inline scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware(
54 scoped_ptr<SoftwareOutputDevice> software_device) {
55 return make_scoped_ptr(
56 new FakeOutputSurface(software_device.Pass(), true));
59 virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE;
61 virtual const struct Capabilities& Capabilities() const OVERRIDE;
63 virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE;
64 virtual SoftwareOutputDevice* SoftwareDevice() const OVERRIDE;
66 virtual void SendFrameToParentCompositor(const CompositorFrame&) OVERRIDE;
68 private:
69 explicit FakeOutputSurface(
70 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent);
71 explicit FakeOutputSurface(
72 scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent);
74 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
75 scoped_ptr<SoftwareOutputDevice> software_device_;
76 struct Capabilities capabilities_;
77 OutputSurfaceClient* client_;
80 static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface()
82 return FakeOutputSurface::Create3d(
83 FakeWebGraphicsContext3D::Create(
84 WebKit::WebGraphicsContext3D::Attributes())
85 .PassAs<WebKit::WebGraphicsContext3D>())
86 .PassAs<cc::OutputSurface>();
89 } // namespace cc
91 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_