| 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 #include "cc/test/fake_output_surface.h" | 5 #include "cc/test/fake_output_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "cc/output/output_surface_client.h" | 9 #include "cc/output/output_surface_client.h" |
| 10 #include "cc/resources/returned_resource.h" | 10 #include "cc/resources/returned_resource.h" |
| 11 #include "cc/test/begin_frame_args_test.h" | 11 #include "cc/test/begin_frame_args_test.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 FakeOutputSurface::FakeOutputSurface( | 16 FakeOutputSurface::FakeOutputSurface( |
| 17 scoped_refptr<ContextProvider> context_provider) | 17 scoped_refptr<ContextProvider> context_provider) |
| 18 : OutputSurface(std::move(context_provider)) {} | 18 : OutputSurface(std::move(context_provider)) { |
| 19 DCHECK(OutputSurface::context_provider()); |
| 20 } |
| 19 | 21 |
| 20 FakeOutputSurface::FakeOutputSurface( | 22 FakeOutputSurface::FakeOutputSurface( |
| 21 std::unique_ptr<SoftwareOutputDevice> software_device) | 23 std::unique_ptr<SoftwareOutputDevice> software_device) |
| 22 : OutputSurface(std::move(software_device)) {} | 24 : OutputSurface(std::move(software_device)) { |
| 25 DCHECK(OutputSurface::software_device()); |
| 26 } |
| 23 | 27 |
| 24 FakeOutputSurface::~FakeOutputSurface() = default; | 28 FakeOutputSurface::~FakeOutputSurface() = default; |
| 25 | 29 |
| 30 void FakeOutputSurface::Reshape(const gfx::Size& size, |
| 31 float device_scale_factor, |
| 32 const gfx::ColorSpace& color_space, |
| 33 bool has_alpha) { |
| 34 if (context_provider()) { |
| 35 context_provider()->ContextGL()->ResizeCHROMIUM( |
| 36 size.width(), size.height(), device_scale_factor, has_alpha); |
| 37 } else { |
| 38 software_device()->Resize(size, device_scale_factor); |
| 39 } |
| 40 } |
| 41 |
| 26 void FakeOutputSurface::SwapBuffers(OutputSurfaceFrame frame) { | 42 void FakeOutputSurface::SwapBuffers(OutputSurfaceFrame frame) { |
| 27 last_sent_frame_.reset(new OutputSurfaceFrame(std::move(frame))); | 43 last_sent_frame_.reset(new OutputSurfaceFrame(std::move(frame))); |
| 28 ++num_sent_frames_; | 44 ++num_sent_frames_; |
| 29 | 45 |
| 30 if (context_provider()) { | 46 if (context_provider()) { |
| 31 last_swap_rect_ = last_sent_frame_->sub_buffer_rect; | 47 last_swap_rect_ = last_sent_frame_->sub_buffer_rect; |
| 32 last_swap_rect_valid_ = true; | 48 last_swap_rect_valid_ = true; |
| 33 } else { | 49 } else { |
| 34 // Unknown for direct software frames. | 50 // Unknown for direct software frames. |
| 35 last_swap_rect_ = gfx::Rect(); | 51 last_swap_rect_ = gfx::Rect(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 90 |
| 75 bool FakeOutputSurface::IsDisplayedAsOverlayPlane() const { | 91 bool FakeOutputSurface::IsDisplayedAsOverlayPlane() const { |
| 76 return false; | 92 return false; |
| 77 } | 93 } |
| 78 | 94 |
| 79 unsigned FakeOutputSurface::GetOverlayTextureId() const { | 95 unsigned FakeOutputSurface::GetOverlayTextureId() const { |
| 80 return 0; | 96 return 0; |
| 81 } | 97 } |
| 82 | 98 |
| 83 } // namespace cc | 99 } // namespace cc |
| OLD | NEW |