ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / cc / test / fake_output_surface.h
blob39a78ead5946bb537ed6d4c909eafd0c7c3d6e9e
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/callback.h"
9 #include "base/logging.h"
10 #include "base/time/time.h"
11 #include "cc/output/begin_frame_args.h"
12 #include "cc/output/compositor_frame.h"
13 #include "cc/output/managed_memory_policy.h"
14 #include "cc/output/output_surface.h"
15 #include "cc/output/software_output_device.h"
16 #include "cc/test/test_context_provider.h"
17 #include "cc/test/test_web_graphics_context_3d.h"
19 namespace cc {
21 class FakeOutputSurface : public OutputSurface {
22 public:
23 ~FakeOutputSurface() override;
25 static scoped_ptr<FakeOutputSurface> Create3d() {
26 return make_scoped_ptr(new FakeOutputSurface(
27 TestContextProvider::Create(), TestContextProvider::Create(), false));
30 static scoped_ptr<FakeOutputSurface> Create3d(
31 scoped_refptr<ContextProvider> context_provider) {
32 return make_scoped_ptr(new FakeOutputSurface(context_provider, false));
35 static scoped_ptr<FakeOutputSurface> Create3d(
36 scoped_refptr<ContextProvider> context_provider,
37 scoped_refptr<ContextProvider> worker_context_provider) {
38 return make_scoped_ptr(new FakeOutputSurface(
39 context_provider, worker_context_provider, false));
42 static scoped_ptr<FakeOutputSurface> Create3d(
43 scoped_ptr<TestWebGraphicsContext3D> context) {
44 return make_scoped_ptr(new FakeOutputSurface(
45 TestContextProvider::Create(context.Pass()), false));
48 static scoped_ptr<FakeOutputSurface> CreateSoftware(
49 scoped_ptr<SoftwareOutputDevice> software_device) {
50 return make_scoped_ptr(new FakeOutputSurface(software_device.Pass(),
51 false));
54 static scoped_ptr<FakeOutputSurface> CreateDelegating3d() {
55 return make_scoped_ptr(new FakeOutputSurface(
56 TestContextProvider::Create(), TestContextProvider::Create(), true));
59 static scoped_ptr<FakeOutputSurface> CreateDelegating3d(
60 scoped_refptr<TestContextProvider> context_provider) {
61 return make_scoped_ptr(new FakeOutputSurface(context_provider, true));
64 static scoped_ptr<FakeOutputSurface> CreateDelegating3d(
65 scoped_ptr<TestWebGraphicsContext3D> context) {
66 return make_scoped_ptr(new FakeOutputSurface(
67 TestContextProvider::Create(context.Pass()), true));
70 static scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware(
71 scoped_ptr<SoftwareOutputDevice> software_device) {
72 return make_scoped_ptr(
73 new FakeOutputSurface(software_device.Pass(), true));
76 static scoped_ptr<FakeOutputSurface> CreateDeferredGL(
77 scoped_ptr<SoftwareOutputDevice> software_device,
78 bool delegated_rendering) {
79 scoped_ptr<FakeOutputSurface> result(
80 new FakeOutputSurface(software_device.Pass(), delegated_rendering));
81 result->capabilities_.deferred_gl_initialization = true;
82 return result.Pass();
85 static scoped_ptr<FakeOutputSurface> CreateAlwaysDrawAndSwap3d() {
86 scoped_ptr<FakeOutputSurface> surface(Create3d());
87 surface->capabilities_.draw_and_swap_full_viewport_every_frame = true;
88 return surface.Pass();
91 static scoped_ptr<FakeOutputSurface> CreateOffscreen(
92 scoped_ptr<TestWebGraphicsContext3D> context) {
93 scoped_ptr<FakeOutputSurface> surface(new FakeOutputSurface(
94 TestContextProvider::Create(context.Pass()), false));
95 surface->capabilities_.uses_default_gl_framebuffer = false;
96 return surface.Pass();
99 CompositorFrame& last_sent_frame() { return last_sent_frame_; }
100 size_t num_sent_frames() { return num_sent_frames_; }
102 void SwapBuffers(CompositorFrame* frame) override;
104 bool BindToClient(OutputSurfaceClient* client) override;
106 void set_framebuffer(unsigned framebuffer) { framebuffer_ = framebuffer; }
107 void BindFramebuffer() override;
109 using OutputSurface::ReleaseGL;
110 using OutputSurface::InitializeAndSetContext3d;
112 void SetTreeActivationCallback(const base::Closure& callback);
114 const TransferableResourceArray& resources_held_by_parent() {
115 return resources_held_by_parent_;
118 void ReturnResource(unsigned id, CompositorFrameAck* ack);
120 bool HasExternalStencilTest() const override;
122 void set_has_external_stencil_test(bool has_test) {
123 has_external_stencil_test_ = has_test;
126 void SetMemoryPolicyToSetAtBind(
127 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind);
129 gfx::Rect last_swap_rect() const {
130 return last_swap_rect_;
133 protected:
134 FakeOutputSurface(
135 scoped_refptr<ContextProvider> context_provider,
136 bool delegated_rendering);
138 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider,
139 scoped_refptr<ContextProvider> worker_context_provider,
140 bool delegated_rendering);
142 FakeOutputSurface(scoped_ptr<SoftwareOutputDevice> software_device,
143 bool delegated_rendering);
145 FakeOutputSurface(
146 scoped_refptr<ContextProvider> context_provider,
147 scoped_ptr<SoftwareOutputDevice> software_device,
148 bool delegated_rendering);
150 OutputSurfaceClient* client_;
151 CompositorFrame last_sent_frame_;
152 size_t num_sent_frames_;
153 bool has_external_stencil_test_;
154 unsigned framebuffer_;
155 TransferableResourceArray resources_held_by_parent_;
156 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind_;
157 gfx::Rect last_swap_rect_;
160 } // namespace cc
162 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_