| 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 "cc/output/output_surface_client.h" | 9 #include "cc/output/output_surface_client.h" |
| 10 #include "cc/scheduler/begin_frame_source.h" | |
| 11 #include "ui/gfx/transform.h" | 10 #include "ui/gfx/transform.h" |
| 12 | 11 |
| 13 namespace cc { | 12 namespace cc { |
| 14 | 13 |
| 15 PixelTestOutputSurface::PixelTestOutputSurface( | 14 PixelTestOutputSurface::PixelTestOutputSurface( |
| 16 scoped_refptr<ContextProvider> context_provider, | 15 scoped_refptr<ContextProvider> context_provider, |
| 17 scoped_refptr<ContextProvider> worker_context_provider, | 16 scoped_refptr<ContextProvider> worker_context_provider, |
| 18 bool flipped_output_surface, | 17 bool flipped_output_surface) |
| 19 std::unique_ptr<BeginFrameSource> begin_frame_source) | |
| 20 : OutputSurface(std::move(context_provider), | 18 : OutputSurface(std::move(context_provider), |
| 21 std::move(worker_context_provider), | 19 std::move(worker_context_provider), |
| 22 nullptr), | 20 nullptr), |
| 23 begin_frame_source_(std::move(begin_frame_source)), | |
| 24 external_stencil_test_(false) { | 21 external_stencil_test_(false) { |
| 25 capabilities_.adjust_deadline_for_parent = false; | 22 capabilities_.adjust_deadline_for_parent = false; |
| 26 capabilities_.flipped_output_surface = flipped_output_surface; | 23 capabilities_.flipped_output_surface = flipped_output_surface; |
| 27 } | 24 } |
| 28 | 25 |
| 29 PixelTestOutputSurface::PixelTestOutputSurface( | 26 PixelTestOutputSurface::PixelTestOutputSurface( |
| 30 scoped_refptr<ContextProvider> context_provider, | 27 scoped_refptr<ContextProvider> context_provider, |
| 31 bool flipped_output_surface, | 28 bool flipped_output_surface) |
| 32 std::unique_ptr<BeginFrameSource> begin_frame_source) | |
| 33 : PixelTestOutputSurface(std::move(context_provider), | 29 : PixelTestOutputSurface(std::move(context_provider), |
| 34 nullptr, | 30 nullptr, |
| 35 flipped_output_surface, | 31 flipped_output_surface) {} |
| 36 std::move(begin_frame_source)) {} | |
| 37 | 32 |
| 38 PixelTestOutputSurface::PixelTestOutputSurface( | 33 PixelTestOutputSurface::PixelTestOutputSurface( |
| 39 std::unique_ptr<SoftwareOutputDevice> software_device, | 34 std::unique_ptr<SoftwareOutputDevice> software_device) |
| 40 std::unique_ptr<BeginFrameSource> begin_frame_source) | |
| 41 : OutputSurface(nullptr, nullptr, std::move(software_device)), | 35 : OutputSurface(nullptr, nullptr, std::move(software_device)), |
| 42 begin_frame_source_(std::move(begin_frame_source)), | |
| 43 external_stencil_test_(false) {} | 36 external_stencil_test_(false) {} |
| 44 | 37 |
| 45 PixelTestOutputSurface::~PixelTestOutputSurface() {} | 38 PixelTestOutputSurface::~PixelTestOutputSurface() {} |
| 46 | 39 |
| 47 bool PixelTestOutputSurface::BindToClient(OutputSurfaceClient* client) { | |
| 48 if (!OutputSurface::BindToClient(client)) | |
| 49 return false; | |
| 50 | |
| 51 // TODO(enne): Once the renderer uses begin frame sources, this will | |
| 52 // always be valid. | |
| 53 if (begin_frame_source_) | |
| 54 client->SetBeginFrameSource(begin_frame_source_.get()); | |
| 55 return true; | |
| 56 } | |
| 57 | |
| 58 void PixelTestOutputSurface::Reshape(const gfx::Size& size, | 40 void PixelTestOutputSurface::Reshape(const gfx::Size& size, |
| 59 float scale_factor, | 41 float scale_factor, |
| 60 bool has_alpha) { | 42 bool has_alpha) { |
| 61 gfx::Size expanded_size(size.width() + surface_expansion_size_.width(), | 43 gfx::Size expanded_size(size.width() + surface_expansion_size_.width(), |
| 62 size.height() + surface_expansion_size_.height()); | 44 size.height() + surface_expansion_size_.height()); |
| 63 OutputSurface::Reshape(expanded_size, scale_factor, has_alpha); | 45 OutputSurface::Reshape(expanded_size, scale_factor, has_alpha); |
| 64 } | 46 } |
| 65 | 47 |
| 66 bool PixelTestOutputSurface::HasExternalStencilTest() const { | 48 bool PixelTestOutputSurface::HasExternalStencilTest() const { |
| 67 return external_stencil_test_; | 49 return external_stencil_test_; |
| 68 } | 50 } |
| 69 | 51 |
| 70 void PixelTestOutputSurface::SwapBuffers(CompositorFrame* frame) { | 52 void PixelTestOutputSurface::SwapBuffers(CompositorFrame* frame) { |
| 71 PostSwapBuffersComplete(); | 53 PostSwapBuffersComplete(); |
| 72 client_->DidSwapBuffers(); | 54 client_->DidSwapBuffers(); |
| 73 } | 55 } |
| 74 | 56 |
| 75 } // namespace cc | 57 } // namespace cc |
| OLD | NEW |