| OLD | NEW |
| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "cc/output/begin_frame_args.h" | 14 #include "cc/output/begin_frame_args.h" |
| 15 #include "cc/output/compositor_frame.h" | 15 #include "cc/output/compositor_frame.h" |
| 16 #include "cc/output/managed_memory_policy.h" | 16 #include "cc/output/managed_memory_policy.h" |
| 17 #include "cc/output/output_surface.h" | 17 #include "cc/output/output_surface.h" |
| 18 #include "cc/output/software_output_device.h" | 18 #include "cc/output/software_output_device.h" |
| 19 #include "cc/test/test_context_provider.h" | 19 #include "cc/test/test_context_provider.h" |
| 20 #include "cc/test/test_web_graphics_context_3d.h" | 20 #include "cc/test/test_web_graphics_context_3d.h" |
| 21 | 21 |
| 22 namespace cc { | 22 namespace cc { |
| 23 | 23 |
| 24 class FakeOutputSurface : public OutputSurface { | 24 class FakeOutputSurface : public OutputSurface { |
| 25 public: | 25 public: |
| 26 ~FakeOutputSurface() override; | 26 ~FakeOutputSurface() override; |
| 27 | 27 |
| 28 static std::unique_ptr<FakeOutputSurface> Create3d() { | 28 static std::unique_ptr<FakeOutputSurface> Create3d() { |
| 29 return base::WrapUnique( | 29 return base::WrapUnique(new FakeOutputSurface( |
| 30 new FakeOutputSurface(TestContextProvider::Create(), | 30 base::MakeUnique<TestContextProvider::DeferredCreate>(), |
| 31 TestContextProvider::CreateWorker(), false)); | 31 TestContextProvider::Create(), false)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 static std::unique_ptr<FakeOutputSurface> Create3d( | 34 static std::unique_ptr<FakeOutputSurface> Create3d( |
| 35 scoped_refptr<ContextProvider> context_provider) { | 35 std::unique_ptr<ContextProvider::DeferredCreate> |
| 36 return base::WrapUnique(new FakeOutputSurface( | 36 context_provider_create) { |
| 37 context_provider, TestContextProvider::CreateWorker(), false)); | 37 return base::WrapUnique( |
| 38 new FakeOutputSurface(std::move(context_provider_create), |
| 39 TestContextProvider::Create(), false)); |
| 38 } | 40 } |
| 39 | 41 |
| 40 static std::unique_ptr<FakeOutputSurface> Create3d( | 42 static std::unique_ptr<FakeOutputSurface> Create3d( |
| 41 scoped_refptr<ContextProvider> context_provider, | 43 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create, |
| 42 scoped_refptr<ContextProvider> worker_context_provider) { | 44 scoped_refptr<ContextProvider> worker_context_provider) { |
| 43 return base::WrapUnique(new FakeOutputSurface( | 45 return base::WrapUnique( |
| 44 context_provider, worker_context_provider, false)); | 46 new FakeOutputSurface(std::move(context_provider_create), |
| 47 std::move(worker_context_provider), false)); |
| 45 } | 48 } |
| 46 | 49 |
| 47 static std::unique_ptr<FakeOutputSurface> Create3d( | 50 static std::unique_ptr<FakeOutputSurface> Create3d( |
| 48 std::unique_ptr<TestWebGraphicsContext3D> context) { | 51 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 49 return base::WrapUnique( | 52 return base::WrapUnique(new FakeOutputSurface( |
| 50 new FakeOutputSurface(TestContextProvider::Create(std::move(context)), | 53 base::MakeUnique<TestContextProvider::DeferredCreate>( |
| 51 TestContextProvider::CreateWorker(), false)); | 54 std::move(context)), |
| 55 TestContextProvider::Create(), false)); |
| 52 } | 56 } |
| 53 | 57 |
| 54 static std::unique_ptr<FakeOutputSurface> CreateSoftware( | 58 static std::unique_ptr<FakeOutputSurface> CreateSoftware( |
| 55 std::unique_ptr<SoftwareOutputDevice> software_device) { | 59 std::unique_ptr<SoftwareOutputDevice> software_device) { |
| 56 return base::WrapUnique( | 60 return base::WrapUnique( |
| 57 new FakeOutputSurface(std::move(software_device), false)); | 61 new FakeOutputSurface(std::move(software_device), false)); |
| 58 } | 62 } |
| 59 | 63 |
| 60 static std::unique_ptr<FakeOutputSurface> | 64 static std::unique_ptr<FakeOutputSurface> |
| 61 Create3dWithResourcelessSoftwareSupport() { | 65 Create3dWithResourcelessSoftwareSupport() { |
| 62 return base::WrapUnique(new FakeOutputSurface( | 66 return base::WrapUnique(new FakeOutputSurface( |
| 63 TestContextProvider::Create(), | 67 base::MakeUnique<TestContextProvider::DeferredCreate>(), |
| 64 base::WrapUnique(new SoftwareOutputDevice), false)); | 68 base::WrapUnique(new SoftwareOutputDevice), false)); |
| 65 } | 69 } |
| 66 | 70 |
| 67 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d() { | 71 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d() { |
| 68 return base::WrapUnique( | 72 return base::WrapUnique(new FakeOutputSurface( |
| 69 new FakeOutputSurface(TestContextProvider::Create(), | 73 base::MakeUnique<TestContextProvider::DeferredCreate>(), |
| 70 TestContextProvider::CreateWorker(), true)); | 74 TestContextProvider::Create(), true)); |
| 71 } | 75 } |
| 72 | 76 |
| 73 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d( | 77 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d( |
| 74 scoped_refptr<TestContextProvider> context_provider) { | 78 std::unique_ptr<ContextProvider::DeferredCreate> |
| 75 return base::WrapUnique(new FakeOutputSurface( | 79 context_provider_create) { |
| 76 context_provider, TestContextProvider::CreateWorker(), true)); | 80 return base::WrapUnique( |
| 81 new FakeOutputSurface(std::move(context_provider_create), |
| 82 TestContextProvider::Create(), true)); |
| 77 } | 83 } |
| 78 | 84 |
| 79 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d( | 85 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d( |
| 80 std::unique_ptr<TestWebGraphicsContext3D> context) { | 86 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 81 return base::WrapUnique( | 87 return base::WrapUnique(new FakeOutputSurface( |
| 82 new FakeOutputSurface(TestContextProvider::Create(std::move(context)), | 88 base::MakeUnique<TestContextProvider::DeferredCreate>( |
| 83 TestContextProvider::CreateWorker(), true)); | 89 std::move(context)), |
| 90 TestContextProvider::Create(), true)); |
| 84 } | 91 } |
| 85 | 92 |
| 86 static std::unique_ptr<FakeOutputSurface> CreateDelegatingSoftware( | 93 static std::unique_ptr<FakeOutputSurface> CreateDelegatingSoftware( |
| 87 std::unique_ptr<SoftwareOutputDevice> software_device) { | 94 std::unique_ptr<SoftwareOutputDevice> software_device) { |
| 88 return base::WrapUnique( | 95 return base::WrapUnique( |
| 89 new FakeOutputSurface(std::move(software_device), true)); | 96 new FakeOutputSurface(std::move(software_device), true)); |
| 90 } | 97 } |
| 91 | 98 |
| 92 static std::unique_ptr<FakeOutputSurface> CreateNoRequireSyncPoint( | 99 static std::unique_ptr<FakeOutputSurface> CreateNoRequireSyncPoint( |
| 93 std::unique_ptr<TestWebGraphicsContext3D> context) { | 100 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 94 std::unique_ptr<FakeOutputSurface> surface(Create3d(std::move(context))); | 101 std::unique_ptr<FakeOutputSurface> surface(Create3d(std::move(context))); |
| 95 surface->capabilities_.delegated_sync_points_required = false; | 102 surface->capabilities_.delegated_sync_points_required = false; |
| 96 return surface; | 103 return surface; |
| 97 } | 104 } |
| 98 | 105 |
| 99 static std::unique_ptr<FakeOutputSurface> CreateOffscreen( | 106 static std::unique_ptr<FakeOutputSurface> CreateOffscreen( |
| 100 std::unique_ptr<TestWebGraphicsContext3D> context) { | 107 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 101 std::unique_ptr<FakeOutputSurface> surface(new FakeOutputSurface( | 108 std::unique_ptr<FakeOutputSurface> surface(new FakeOutputSurface( |
| 102 TestContextProvider::Create(std::move(context)), false)); | 109 base::MakeUnique<TestContextProvider::DeferredCreate>( |
| 110 std::move(context)), |
| 111 false)); |
| 103 surface->capabilities_.uses_default_gl_framebuffer = false; | 112 surface->capabilities_.uses_default_gl_framebuffer = false; |
| 104 return surface; | 113 return surface; |
| 105 } | 114 } |
| 106 | 115 |
| 107 void set_max_frames_pending(int max) { | 116 void set_max_frames_pending(int max) { |
| 108 capabilities_.max_frames_pending = max; | 117 capabilities_.max_frames_pending = max; |
| 109 } | 118 } |
| 110 | 119 |
| 111 CompositorFrame& last_sent_frame() { return last_sent_frame_; } | 120 CompositorFrame& last_sent_frame() { return last_sent_frame_; } |
| 112 size_t num_sent_frames() { return num_sent_frames_; } | 121 size_t num_sent_frames() { return num_sent_frames_; } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 155 |
| 147 void SetMemoryPolicyToSetAtBind( | 156 void SetMemoryPolicyToSetAtBind( |
| 148 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind); | 157 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind); |
| 149 | 158 |
| 150 gfx::Rect last_swap_rect() const { | 159 gfx::Rect last_swap_rect() const { |
| 151 return last_swap_rect_; | 160 return last_swap_rect_; |
| 152 } | 161 } |
| 153 | 162 |
| 154 protected: | 163 protected: |
| 155 FakeOutputSurface( | 164 FakeOutputSurface( |
| 156 scoped_refptr<ContextProvider> context_provider, | 165 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create, |
| 157 bool delegated_rendering); | 166 bool delegated_rendering); |
| 158 | 167 |
| 159 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider, | 168 FakeOutputSurface( |
| 160 scoped_refptr<ContextProvider> worker_context_provider, | 169 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create, |
| 161 bool delegated_rendering); | 170 scoped_refptr<ContextProvider> worker_context_provider, |
| 171 bool delegated_rendering); |
| 162 | 172 |
| 163 FakeOutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device, | 173 FakeOutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device, |
| 164 bool delegated_rendering); | 174 bool delegated_rendering); |
| 165 | 175 |
| 166 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider, | 176 FakeOutputSurface( |
| 167 std::unique_ptr<SoftwareOutputDevice> software_device, | 177 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create, |
| 168 bool delegated_rendering); | 178 std::unique_ptr<SoftwareOutputDevice> software_device, |
| 179 bool delegated_rendering); |
| 169 | 180 |
| 170 OutputSurfaceClient* client_; | 181 OutputSurfaceClient* client_; |
| 171 CompositorFrame last_sent_frame_; | 182 CompositorFrame last_sent_frame_; |
| 172 size_t num_sent_frames_; | 183 size_t num_sent_frames_; |
| 173 bool has_external_stencil_test_; | 184 bool has_external_stencil_test_; |
| 174 bool suspended_for_recycle_; | 185 bool suspended_for_recycle_; |
| 175 unsigned framebuffer_; | 186 unsigned framebuffer_; |
| 176 TransferableResourceArray resources_held_by_parent_; | 187 TransferableResourceArray resources_held_by_parent_; |
| 177 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind_; | 188 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind_; |
| 178 OverlayCandidateValidator* overlay_candidate_validator_; | 189 OverlayCandidateValidator* overlay_candidate_validator_; |
| 179 gfx::Rect last_swap_rect_; | 190 gfx::Rect last_swap_rect_; |
| 180 }; | 191 }; |
| 181 | 192 |
| 182 } // namespace cc | 193 } // namespace cc |
| 183 | 194 |
| 184 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ | 195 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ |
| OLD | NEW |