| 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/output_surface.h" | 15 #include "cc/output/output_surface.h" |
| 16 #include "cc/output/output_surface_frame.h" | 16 #include "cc/output/output_surface_frame.h" |
| 17 #include "cc/output/software_output_device.h" | 17 #include "cc/output/software_output_device.h" |
| 18 #include "cc/test/test_context_provider.h" | 18 #include "cc/test/test_context_provider.h" |
| 19 #include "cc/test/test_gles2_interface.h" | 19 #include "cc/test/test_gles2_interface.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 auto provider = TestContextProvider::Create(); |
| 30 new FakeOutputSurface(TestContextProvider::Create())); | 30 provider->BindToCurrentThread(); |
| 31 return base::WrapUnique(new FakeOutputSurface(std::move(provider))); |
| 31 } | 32 } |
| 32 | 33 |
| 33 static std::unique_ptr<FakeOutputSurface> Create3d( | 34 static std::unique_ptr<FakeOutputSurface> Create3d( |
| 34 scoped_refptr<ContextProvider> context_provider) { | 35 scoped_refptr<ContextProvider> context_provider) { |
| 35 return base::WrapUnique(new FakeOutputSurface(context_provider)); | 36 return base::WrapUnique(new FakeOutputSurface(context_provider)); |
| 36 } | 37 } |
| 37 | 38 |
| 38 static std::unique_ptr<FakeOutputSurface> Create3d( | |
| 39 std::unique_ptr<TestGLES2Interface> gl) { | |
| 40 return base::WrapUnique( | |
| 41 new FakeOutputSurface(TestContextProvider::Create(std::move(gl)))); | |
| 42 } | |
| 43 | |
| 44 static std::unique_ptr<FakeOutputSurface> Create3d( | |
| 45 std::unique_ptr<TestWebGraphicsContext3D> context) { | |
| 46 return base::WrapUnique( | |
| 47 new FakeOutputSurface(TestContextProvider::Create(std::move(context)))); | |
| 48 } | |
| 49 | |
| 50 static std::unique_ptr<FakeOutputSurface> CreateSoftware( | 39 static std::unique_ptr<FakeOutputSurface> CreateSoftware( |
| 51 std::unique_ptr<SoftwareOutputDevice> software_device) { | 40 std::unique_ptr<SoftwareOutputDevice> software_device) { |
| 52 return base::WrapUnique(new FakeOutputSurface(std::move(software_device))); | 41 return base::WrapUnique(new FakeOutputSurface(std::move(software_device))); |
| 53 } | 42 } |
| 54 | 43 |
| 55 static std::unique_ptr<FakeOutputSurface> CreateOffscreen( | 44 static std::unique_ptr<FakeOutputSurface> CreateOffscreen( |
| 56 std::unique_ptr<TestWebGraphicsContext3D> context) { | 45 scoped_refptr<ContextProvider> context_provider) { |
| 57 auto surface = base::WrapUnique( | 46 auto surface = |
| 58 new FakeOutputSurface(TestContextProvider::Create(std::move(context)))); | 47 base::WrapUnique(new FakeOutputSurface(std::move(context_provider))); |
| 59 surface->capabilities_.uses_default_gl_framebuffer = false; | 48 surface->capabilities_.uses_default_gl_framebuffer = false; |
| 60 return surface; | 49 return surface; |
| 61 } | 50 } |
| 62 | 51 |
| 63 void set_max_frames_pending(int max) { | 52 void set_max_frames_pending(int max) { |
| 64 capabilities_.max_frames_pending = max; | 53 capabilities_.max_frames_pending = max; |
| 65 } | 54 } |
| 66 | 55 |
| 67 OutputSurfaceFrame* last_sent_frame() { return last_sent_frame_.get(); } | 56 OutputSurfaceFrame* last_sent_frame() { return last_sent_frame_.get(); } |
| 68 size_t num_sent_frames() { return num_sent_frames_; } | 57 size_t num_sent_frames() { return num_sent_frames_; } |
| 69 | 58 |
| 70 OutputSurfaceClient* client() { return client_; } | 59 OutputSurfaceClient* client() { return client_; } |
| 71 | 60 |
| 72 bool BindToClient(OutputSurfaceClient* client) override; | 61 void BindToClient(OutputSurfaceClient* client) override; |
| 73 void EnsureBackbuffer() override {} | 62 void EnsureBackbuffer() override {} |
| 74 void DiscardBackbuffer() override {} | 63 void DiscardBackbuffer() override {} |
| 75 void BindFramebuffer() override; | 64 void BindFramebuffer() override; |
| 76 void Reshape(const gfx::Size& size, | 65 void Reshape(const gfx::Size& size, |
| 77 float device_scale_factor, | 66 float device_scale_factor, |
| 78 const gfx::ColorSpace& color_space, | 67 const gfx::ColorSpace& color_space, |
| 79 bool has_alpha) override; | 68 bool has_alpha) override; |
| 80 void SwapBuffers(OutputSurfaceFrame frame) override; | 69 void SwapBuffers(OutputSurfaceFrame frame) override; |
| 81 uint32_t GetFramebufferCopyTextureFormat() override; | 70 uint32_t GetFramebufferCopyTextureFormat() override; |
| 82 bool HasExternalStencilTest() const override; | 71 bool HasExternalStencilTest() const override; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 115 |
| 127 private: | 116 private: |
| 128 void SwapBuffersAck(); | 117 void SwapBuffersAck(); |
| 129 | 118 |
| 130 base::WeakPtrFactory<FakeOutputSurface> weak_ptr_factory_; | 119 base::WeakPtrFactory<FakeOutputSurface> weak_ptr_factory_; |
| 131 }; | 120 }; |
| 132 | 121 |
| 133 } // namespace cc | 122 } // namespace cc |
| 134 | 123 |
| 135 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ | 124 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ |
| OLD | NEW |