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/threading/thread_task_runner_handle.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)), weak_ptr_factory_(this) {} |
19 | 19 |
20 FakeOutputSurface::FakeOutputSurface( | 20 FakeOutputSurface::FakeOutputSurface( |
21 std::unique_ptr<SoftwareOutputDevice> software_device) | 21 std::unique_ptr<SoftwareOutputDevice> software_device) |
22 : OutputSurface(std::move(software_device)) {} | 22 : OutputSurface(std::move(software_device)), weak_ptr_factory_(this) {} |
23 | 23 |
24 FakeOutputSurface::~FakeOutputSurface() = default; | 24 FakeOutputSurface::~FakeOutputSurface() = default; |
25 | 25 |
26 void FakeOutputSurface::SwapBuffers(OutputSurfaceFrame frame) { | 26 void FakeOutputSurface::SwapBuffers(OutputSurfaceFrame frame) { |
27 last_sent_frame_.reset(new OutputSurfaceFrame(std::move(frame))); | 27 last_sent_frame_.reset(new OutputSurfaceFrame(std::move(frame))); |
28 ++num_sent_frames_; | 28 ++num_sent_frames_; |
29 | 29 |
30 if (context_provider()) { | 30 if (context_provider()) { |
31 last_swap_rect_ = last_sent_frame_->sub_buffer_rect; | 31 last_swap_rect_ = last_sent_frame_->sub_buffer_rect; |
32 last_swap_rect_valid_ = true; | 32 last_swap_rect_valid_ = true; |
33 } else { | 33 } else { |
34 // Unknown for direct software frames. | 34 // Unknown for direct software frames. |
35 last_swap_rect_ = gfx::Rect(); | 35 last_swap_rect_ = gfx::Rect(); |
36 last_swap_rect_valid_ = false; | 36 last_swap_rect_valid_ = false; |
37 } | 37 } |
38 | 38 |
39 PostSwapBuffersComplete(); | 39 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 40 FROM_HERE, base::Bind(&FakeOutputSurface::SwapBuffersCallback, |
| 41 weak_ptr_factory_.GetWeakPtr())); |
| 42 } |
| 43 |
| 44 void FakeOutputSurface::SwapBuffersCallback() { |
| 45 client_->DidSwapBuffersComplete(); |
40 } | 46 } |
41 | 47 |
42 void FakeOutputSurface::BindFramebuffer() { | 48 void FakeOutputSurface::BindFramebuffer() { |
43 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, framebuffer_); | 49 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, framebuffer_); |
44 } | 50 } |
45 | 51 |
46 uint32_t FakeOutputSurface::GetFramebufferCopyTextureFormat() { | 52 uint32_t FakeOutputSurface::GetFramebufferCopyTextureFormat() { |
47 if (framebuffer_) | 53 if (framebuffer_) |
48 return framebuffer_format_; | 54 return framebuffer_format_; |
49 else | 55 else |
(...skipping 24 matching lines...) Expand all Loading... |
74 | 80 |
75 bool FakeOutputSurface::IsDisplayedAsOverlayPlane() const { | 81 bool FakeOutputSurface::IsDisplayedAsOverlayPlane() const { |
76 return false; | 82 return false; |
77 } | 83 } |
78 | 84 |
79 unsigned FakeOutputSurface::GetOverlayTextureId() const { | 85 unsigned FakeOutputSurface::GetOverlayTextureId() const { |
80 return 0; | 86 return 0; |
81 } | 87 } |
82 | 88 |
83 } // namespace cc | 89 } // namespace cc |
OLD | NEW |