OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "cc/test/pixel_test_output_surface.h" | 5 #include "cc/test/pixel_test_output_surface.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" |
9 #include "cc/output/output_surface_client.h" | 11 #include "cc/output/output_surface_client.h" |
10 #include "cc/output/output_surface_frame.h" | 12 #include "cc/output/output_surface_frame.h" |
11 #include "gpu/command_buffer/client/gles2_interface.h" | 13 #include "gpu/command_buffer/client/gles2_interface.h" |
12 #include "third_party/khronos/GLES2/gl2.h" | 14 #include "third_party/khronos/GLES2/gl2.h" |
13 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
14 | 16 |
15 namespace cc { | 17 namespace cc { |
16 | 18 |
17 PixelTestOutputSurface::PixelTestOutputSurface( | 19 PixelTestOutputSurface::PixelTestOutputSurface( |
18 scoped_refptr<ContextProvider> context_provider, | 20 scoped_refptr<ContextProvider> context_provider, |
19 bool flipped_output_surface) | 21 bool flipped_output_surface) |
20 : OutputSurface(std::move(context_provider)), | 22 : OutputSurface(std::move(context_provider)), weak_ptr_factory_(this) { |
21 external_stencil_test_(false) { | |
22 capabilities_.flipped_output_surface = flipped_output_surface; | 23 capabilities_.flipped_output_surface = flipped_output_surface; |
23 } | 24 } |
24 | 25 |
25 PixelTestOutputSurface::PixelTestOutputSurface( | 26 PixelTestOutputSurface::PixelTestOutputSurface( |
26 std::unique_ptr<SoftwareOutputDevice> software_device) | 27 std::unique_ptr<SoftwareOutputDevice> software_device) |
27 : OutputSurface(std::move(software_device)), | 28 : OutputSurface(std::move(software_device)), weak_ptr_factory_(this) {} |
28 external_stencil_test_(false) {} | |
29 | 29 |
30 PixelTestOutputSurface::~PixelTestOutputSurface() = default; | 30 PixelTestOutputSurface::~PixelTestOutputSurface() = default; |
31 | 31 |
32 void PixelTestOutputSurface::EnsureBackbuffer() {} | 32 void PixelTestOutputSurface::EnsureBackbuffer() {} |
33 | 33 |
34 void PixelTestOutputSurface::DiscardBackbuffer() {} | 34 void PixelTestOutputSurface::DiscardBackbuffer() {} |
35 | 35 |
36 void PixelTestOutputSurface::BindFramebuffer() { | 36 void PixelTestOutputSurface::BindFramebuffer() { |
37 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); | 37 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
38 } | 38 } |
(...skipping 10 matching lines...) Expand all Loading... |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 bool PixelTestOutputSurface::HasExternalStencilTest() const { | 52 bool PixelTestOutputSurface::HasExternalStencilTest() const { |
53 return external_stencil_test_; | 53 return external_stencil_test_; |
54 } | 54 } |
55 | 55 |
56 void PixelTestOutputSurface::ApplyExternalStencil() {} | 56 void PixelTestOutputSurface::ApplyExternalStencil() {} |
57 | 57 |
58 void PixelTestOutputSurface::SwapBuffers(OutputSurfaceFrame frame) { | 58 void PixelTestOutputSurface::SwapBuffers(OutputSurfaceFrame frame) { |
59 PostSwapBuffersComplete(); | 59 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 60 FROM_HERE, base::Bind(&PixelTestOutputSurface::SwapBuffersCallback, |
| 61 weak_ptr_factory_.GetWeakPtr())); |
| 62 } |
| 63 |
| 64 void PixelTestOutputSurface::SwapBuffersCallback() { |
| 65 client_->DidSwapBuffersComplete(); |
60 } | 66 } |
61 | 67 |
62 OverlayCandidateValidator* | 68 OverlayCandidateValidator* |
63 PixelTestOutputSurface::GetOverlayCandidateValidator() const { | 69 PixelTestOutputSurface::GetOverlayCandidateValidator() const { |
64 return nullptr; | 70 return nullptr; |
65 } | 71 } |
66 | 72 |
67 bool PixelTestOutputSurface::IsDisplayedAsOverlayPlane() const { | 73 bool PixelTestOutputSurface::IsDisplayedAsOverlayPlane() const { |
68 return false; | 74 return false; |
69 } | 75 } |
70 | 76 |
71 unsigned PixelTestOutputSurface::GetOverlayTextureId() const { | 77 unsigned PixelTestOutputSurface::GetOverlayTextureId() const { |
72 return 0; | 78 return 0; |
73 } | 79 } |
74 | 80 |
75 bool PixelTestOutputSurface::SurfaceIsSuspendForRecycle() const { | 81 bool PixelTestOutputSurface::SurfaceIsSuspendForRecycle() const { |
76 return false; | 82 return false; |
77 } | 83 } |
78 | 84 |
79 uint32_t PixelTestOutputSurface::GetFramebufferCopyTextureFormat() { | 85 uint32_t PixelTestOutputSurface::GetFramebufferCopyTextureFormat() { |
80 // This format will work if the |context_provider| has an RGB or RGBA | 86 // This format will work if the |context_provider| has an RGB or RGBA |
81 // framebuffer. For now assume tests do not want/care about alpha in | 87 // framebuffer. For now assume tests do not want/care about alpha in |
82 // the root render pass. | 88 // the root render pass. |
83 return GL_RGB; | 89 return GL_RGB; |
84 } | 90 } |
85 | 91 |
86 } // namespace cc | 92 } // namespace cc |
OLD | NEW |