add a use_alsa gyp setting
[chromium-blink-merge.git] / cc / test / fake_output_surface.h
blob2ab79066ebab4a00c111ea52e143f954d407278a
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 "cc/compositor_frame.h"
9 #include "cc/output_surface.h"
10 #include "cc/test/fake_software_output_device.h"
11 #include "cc/test/test_web_graphics_context_3d.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
14 namespace cc {
16 class FakeOutputSurface : public OutputSurface {
17 public:
18 virtual ~FakeOutputSurface();
20 static scoped_ptr<FakeOutputSurface> Create3d(
21 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) {
22 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false));
25 static scoped_ptr<FakeOutputSurface> Create3d() {
26 scoped_ptr<WebKit::WebGraphicsContext3D> context3d =
27 TestWebGraphicsContext3D::Create(
28 WebKit::WebGraphicsContext3D::Attributes())
29 .PassAs<WebKit::WebGraphicsContext3D>();
30 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false));
33 static scoped_ptr<FakeOutputSurface> CreateSoftware(
34 scoped_ptr<SoftwareOutputDevice> software_device) {
35 return make_scoped_ptr(
36 new FakeOutputSurface(software_device.Pass(), false));
39 static scoped_ptr<FakeOutputSurface> CreateDelegating3d(
40 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) {
41 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true));
44 static scoped_ptr<FakeOutputSurface> CreateDelegating3d() {
45 scoped_ptr<WebKit::WebGraphicsContext3D> context3d =
46 TestWebGraphicsContext3D::Create(
47 WebKit::WebGraphicsContext3D::Attributes())
48 .PassAs<WebKit::WebGraphicsContext3D>();
49 return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true));
52 static scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware(
53 scoped_ptr<SoftwareOutputDevice> software_device) {
54 return make_scoped_ptr(
55 new FakeOutputSurface(software_device.Pass(), true));
58 virtual bool BindToClient(OutputSurfaceClient*) OVERRIDE;
59 virtual void SendFrameToParentCompositor(CompositorFrame*) OVERRIDE;
61 CompositorFrame& last_sent_frame() { return last_sent_frame_; }
62 size_t num_sent_frames() { return num_sent_frames_; }
64 private:
65 FakeOutputSurface(
66 scoped_ptr<WebKit::WebGraphicsContext3D> context3d,
67 bool has_parent);
69 FakeOutputSurface(
70 scoped_ptr<SoftwareOutputDevice> software_device,
71 bool has_parent);
73 CompositorFrame last_sent_frame_;
74 size_t num_sent_frames_;
77 static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface()
79 return FakeOutputSurface::Create3d(
80 TestWebGraphicsContext3D::Create(
81 WebKit::WebGraphicsContext3D::Attributes())
82 .PassAs<WebKit::WebGraphicsContext3D>())
83 .PassAs<cc::OutputSurface>();
86 } // namespace cc
88 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_