| 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( |
| 30 new FakeOutputSurface(TestContextProvider::Create(), | 30 new FakeOutputSurface(base::MakeUnique<TestContextProvider::Factory>(), |
| 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::Factory> compositor_context_factory) { |
| 36 return base::WrapUnique(new FakeOutputSurface( | 36 return base::WrapUnique( |
| 37 context_provider, TestContextProvider::CreateWorker(), false)); | 37 new FakeOutputSurface(std::move(compositor_context_factory), |
| 38 TestContextProvider::Create(), false)); |
| 38 } | 39 } |
| 39 | 40 |
| 40 static std::unique_ptr<FakeOutputSurface> Create3d( | 41 static std::unique_ptr<FakeOutputSurface> Create3d( |
| 41 scoped_refptr<ContextProvider> context_provider, | 42 std::unique_ptr<ContextProvider::Factory> compositor_context_factory, |
| 42 scoped_refptr<ContextProvider> worker_context_provider) { | 43 scoped_refptr<ContextProvider> worker_context_provider) { |
| 43 return base::WrapUnique(new FakeOutputSurface( | 44 return base::WrapUnique( |
| 44 context_provider, worker_context_provider, false)); | 45 new FakeOutputSurface(std::move(compositor_context_factory), |
| 46 std::move(worker_context_provider), false)); |
| 45 } | 47 } |
| 46 | 48 |
| 47 static std::unique_ptr<FakeOutputSurface> Create3d( | 49 static std::unique_ptr<FakeOutputSurface> Create3d( |
| 48 std::unique_ptr<TestWebGraphicsContext3D> context) { | 50 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 49 return base::WrapUnique( | 51 return base::WrapUnique(new FakeOutputSurface( |
| 50 new FakeOutputSurface(TestContextProvider::Create(std::move(context)), | 52 base::MakeUnique<TestContextProvider::Factory>(std::move(context)), |
| 51 TestContextProvider::CreateWorker(), false)); | 53 TestContextProvider::Create(), false)); |
| 52 } | 54 } |
| 53 | 55 |
| 54 static std::unique_ptr<FakeOutputSurface> CreateSoftware( | 56 static std::unique_ptr<FakeOutputSurface> CreateSoftware( |
| 55 std::unique_ptr<SoftwareOutputDevice> software_device) { | 57 std::unique_ptr<SoftwareOutputDevice> software_device) { |
| 56 return base::WrapUnique( | 58 return base::WrapUnique( |
| 57 new FakeOutputSurface(std::move(software_device), false)); | 59 new FakeOutputSurface(std::move(software_device), false)); |
| 58 } | 60 } |
| 59 | 61 |
| 60 static std::unique_ptr<FakeOutputSurface> | 62 static std::unique_ptr<FakeOutputSurface> |
| 61 Create3dWithResourcelessSoftwareSupport() { | 63 Create3dWithResourcelessSoftwareSupport() { |
| 62 return base::WrapUnique(new FakeOutputSurface( | 64 return base::WrapUnique(new FakeOutputSurface( |
| 63 TestContextProvider::Create(), | 65 base::MakeUnique<TestContextProvider::Factory>(), |
| 64 base::WrapUnique(new SoftwareOutputDevice), false)); | 66 base::WrapUnique(new SoftwareOutputDevice), false)); |
| 65 } | 67 } |
| 66 | 68 |
| 67 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d() { | 69 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d() { |
| 68 return base::WrapUnique( | 70 return base::WrapUnique( |
| 69 new FakeOutputSurface(TestContextProvider::Create(), | 71 new FakeOutputSurface(base::MakeUnique<TestContextProvider::Factory>(), |
| 70 TestContextProvider::CreateWorker(), true)); | 72 TestContextProvider::Create(), true)); |
| 71 } | 73 } |
| 72 | 74 |
| 73 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d( | 75 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d( |
| 74 scoped_refptr<TestContextProvider> context_provider) { | 76 std::unique_ptr<ContextProvider::Factory> compositor_context_factory) { |
| 75 return base::WrapUnique(new FakeOutputSurface( | 77 return base::WrapUnique( |
| 76 context_provider, TestContextProvider::CreateWorker(), true)); | 78 new FakeOutputSurface(std::move(compositor_context_factory), |
| 79 TestContextProvider::Create(), true)); |
| 77 } | 80 } |
| 78 | 81 |
| 79 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d( | 82 static std::unique_ptr<FakeOutputSurface> CreateDelegating3d( |
| 80 std::unique_ptr<TestWebGraphicsContext3D> context) { | 83 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 81 return base::WrapUnique( | 84 return base::WrapUnique(new FakeOutputSurface( |
| 82 new FakeOutputSurface(TestContextProvider::Create(std::move(context)), | 85 base::MakeUnique<TestContextProvider::Factory>(std::move(context)), |
| 83 TestContextProvider::CreateWorker(), true)); | 86 TestContextProvider::Create(), true)); |
| 84 } | 87 } |
| 85 | 88 |
| 86 static std::unique_ptr<FakeOutputSurface> CreateDelegatingSoftware( | 89 static std::unique_ptr<FakeOutputSurface> CreateDelegatingSoftware( |
| 87 std::unique_ptr<SoftwareOutputDevice> software_device) { | 90 std::unique_ptr<SoftwareOutputDevice> software_device) { |
| 88 return base::WrapUnique( | 91 return base::WrapUnique( |
| 89 new FakeOutputSurface(std::move(software_device), true)); | 92 new FakeOutputSurface(std::move(software_device), true)); |
| 90 } | 93 } |
| 91 | 94 |
| 92 static std::unique_ptr<FakeOutputSurface> CreateNoRequireSyncPoint( | 95 static std::unique_ptr<FakeOutputSurface> CreateNoRequireSyncPoint( |
| 93 std::unique_ptr<TestWebGraphicsContext3D> context) { | 96 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 94 std::unique_ptr<FakeOutputSurface> surface(Create3d(std::move(context))); | 97 std::unique_ptr<FakeOutputSurface> surface(Create3d(std::move(context))); |
| 95 surface->capabilities_.delegated_sync_points_required = false; | 98 surface->capabilities_.delegated_sync_points_required = false; |
| 96 return surface; | 99 return surface; |
| 97 } | 100 } |
| 98 | 101 |
| 99 static std::unique_ptr<FakeOutputSurface> CreateOffscreen( | 102 static std::unique_ptr<FakeOutputSurface> CreateOffscreen( |
| 100 std::unique_ptr<TestWebGraphicsContext3D> context) { | 103 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 101 std::unique_ptr<FakeOutputSurface> surface(new FakeOutputSurface( | 104 std::unique_ptr<FakeOutputSurface> surface(new FakeOutputSurface( |
| 102 TestContextProvider::Create(std::move(context)), false)); | 105 base::MakeUnique<TestContextProvider::Factory>(std::move(context)), |
| 106 false)); |
| 103 surface->capabilities_.uses_default_gl_framebuffer = false; | 107 surface->capabilities_.uses_default_gl_framebuffer = false; |
| 104 return surface; | 108 return surface; |
| 105 } | 109 } |
| 106 | 110 |
| 107 void set_max_frames_pending(int max) { | 111 void set_max_frames_pending(int max) { |
| 108 capabilities_.max_frames_pending = max; | 112 capabilities_.max_frames_pending = max; |
| 109 } | 113 } |
| 110 | 114 |
| 111 CompositorFrame& last_sent_frame() { return last_sent_frame_; } | 115 CompositorFrame& last_sent_frame() { return last_sent_frame_; } |
| 112 size_t num_sent_frames() { return num_sent_frames_; } | 116 size_t num_sent_frames() { return num_sent_frames_; } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 150 |
| 147 void SetMemoryPolicyToSetAtBind( | 151 void SetMemoryPolicyToSetAtBind( |
| 148 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind); | 152 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind); |
| 149 | 153 |
| 150 gfx::Rect last_swap_rect() const { | 154 gfx::Rect last_swap_rect() const { |
| 151 return last_swap_rect_; | 155 return last_swap_rect_; |
| 152 } | 156 } |
| 153 | 157 |
| 154 protected: | 158 protected: |
| 155 FakeOutputSurface( | 159 FakeOutputSurface( |
| 156 scoped_refptr<ContextProvider> context_provider, | 160 std::unique_ptr<ContextProvider::Factory> compositor_context_factory, |
| 157 bool delegated_rendering); | 161 bool delegated_rendering); |
| 158 | 162 |
| 159 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider, | 163 FakeOutputSurface( |
| 160 scoped_refptr<ContextProvider> worker_context_provider, | 164 std::unique_ptr<ContextProvider::Factory> compositor_context_factory, |
| 161 bool delegated_rendering); | 165 scoped_refptr<ContextProvider> worker_context_provider, |
| 166 bool delegated_rendering); |
| 162 | 167 |
| 163 FakeOutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device, | 168 FakeOutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device, |
| 164 bool delegated_rendering); | 169 bool delegated_rendering); |
| 165 | 170 |
| 166 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider, | 171 FakeOutputSurface( |
| 167 std::unique_ptr<SoftwareOutputDevice> software_device, | 172 std::unique_ptr<ContextProvider::Factory> compositor_context_factory, |
| 168 bool delegated_rendering); | 173 std::unique_ptr<SoftwareOutputDevice> software_device, |
| 174 bool delegated_rendering); |
| 169 | 175 |
| 170 OutputSurfaceClient* client_; | 176 OutputSurfaceClient* client_; |
| 171 CompositorFrame last_sent_frame_; | 177 CompositorFrame last_sent_frame_; |
| 172 size_t num_sent_frames_; | 178 size_t num_sent_frames_; |
| 173 bool has_external_stencil_test_; | 179 bool has_external_stencil_test_; |
| 174 bool suspended_for_recycle_; | 180 bool suspended_for_recycle_; |
| 175 unsigned framebuffer_; | 181 unsigned framebuffer_; |
| 176 TransferableResourceArray resources_held_by_parent_; | 182 TransferableResourceArray resources_held_by_parent_; |
| 177 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind_; | 183 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind_; |
| 178 OverlayCandidateValidator* overlay_candidate_validator_; | 184 OverlayCandidateValidator* overlay_candidate_validator_; |
| 179 gfx::Rect last_swap_rect_; | 185 gfx::Rect last_swap_rect_; |
| 180 }; | 186 }; |
| 181 | 187 |
| 182 } // namespace cc | 188 } // namespace cc |
| 183 | 189 |
| 184 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ | 190 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ |
| OLD | NEW |