Disable flaky SelectFileDialogExtensionBrowserTest tests
[chromium-blink-merge.git] / cc / test / fake_output_surface.h
blob6028cade045a8ebee630896f4d3b6fbd60fc2997
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> CreateAlwaysDrawAndSwap3d() {
77 scoped_ptr<FakeOutputSurface> surface(Create3d());
78 surface->capabilities_.draw_and_swap_full_viewport_every_frame = true;
79 return surface.Pass();
82 static scoped_ptr<FakeOutputSurface> CreateNoRequireSyncPoint(
83 scoped_ptr<TestWebGraphicsContext3D> context) {
84 scoped_ptr<FakeOutputSurface> surface(Create3d(context.Pass()));
85 surface->capabilities_.delegated_sync_points_required = false;
86 return surface.Pass();
89 static scoped_ptr<FakeOutputSurface> CreateOffscreen(
90 scoped_ptr<TestWebGraphicsContext3D> context) {
91 scoped_ptr<FakeOutputSurface> surface(new FakeOutputSurface(
92 TestContextProvider::Create(context.Pass()), false));
93 surface->capabilities_.uses_default_gl_framebuffer = false;
94 return surface.Pass();
97 CompositorFrame& last_sent_frame() { return last_sent_frame_; }
98 size_t num_sent_frames() { return num_sent_frames_; }
100 void SwapBuffers(CompositorFrame* frame) override;
102 OutputSurfaceClient* client() { return client_; }
103 bool BindToClient(OutputSurfaceClient* client) override;
105 void set_framebuffer(unsigned framebuffer) { framebuffer_ = framebuffer; }
106 void BindFramebuffer() override;
108 void SetTreeActivationCallback(const base::Closure& callback);
110 const TransferableResourceArray& resources_held_by_parent() {
111 return resources_held_by_parent_;
114 void ReturnResource(unsigned id, CompositorFrameAck* ack);
116 bool HasExternalStencilTest() const override;
118 void set_has_external_stencil_test(bool has_test) {
119 has_external_stencil_test_ = has_test;
122 void SetMemoryPolicyToSetAtBind(
123 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind);
125 gfx::Rect last_swap_rect() const {
126 return last_swap_rect_;
129 protected:
130 FakeOutputSurface(
131 scoped_refptr<ContextProvider> context_provider,
132 bool delegated_rendering);
134 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider,
135 scoped_refptr<ContextProvider> worker_context_provider,
136 bool delegated_rendering);
138 FakeOutputSurface(scoped_ptr<SoftwareOutputDevice> software_device,
139 bool delegated_rendering);
141 FakeOutputSurface(
142 scoped_refptr<ContextProvider> context_provider,
143 scoped_ptr<SoftwareOutputDevice> software_device,
144 bool delegated_rendering);
146 OutputSurfaceClient* client_;
147 CompositorFrame last_sent_frame_;
148 size_t num_sent_frames_;
149 bool has_external_stencil_test_;
150 unsigned framebuffer_;
151 TransferableResourceArray resources_held_by_parent_;
152 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind_;
153 gfx::Rect last_swap_rect_;
156 } // namespace cc
158 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_