| 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/compositor_frame_ack.h" | 9 #include "cc/output/compositor_frame_ack.h" |
| 10 #include "cc/output/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 std::move(software_device), | 31 std::move(software_device), |
| 32 delegated_rendering) {} | 32 delegated_rendering) {} |
| 33 | 33 |
| 34 FakeOutputSurface::FakeOutputSurface( | 34 FakeOutputSurface::FakeOutputSurface( |
| 35 scoped_refptr<ContextProvider> context_provider, | 35 scoped_refptr<ContextProvider> context_provider, |
| 36 scoped_refptr<ContextProvider> worker_context_provider, | 36 scoped_refptr<ContextProvider> worker_context_provider, |
| 37 std::unique_ptr<SoftwareOutputDevice> software_device, | 37 std::unique_ptr<SoftwareOutputDevice> software_device, |
| 38 bool delegated_rendering) | 38 bool delegated_rendering) |
| 39 : OutputSurface(std::move(context_provider), | 39 : OutputSurface(std::move(context_provider), |
| 40 std::move(worker_context_provider), | 40 std::move(worker_context_provider), |
| 41 std::move(software_device)), | 41 std::move(software_device)) { |
| 42 client_(NULL), | |
| 43 num_sent_frames_(0), | |
| 44 has_external_stencil_test_(false), | |
| 45 suspended_for_recycle_(false), | |
| 46 framebuffer_(0), | |
| 47 overlay_candidate_validator_(nullptr) { | |
| 48 capabilities_.delegated_rendering = delegated_rendering; | 42 capabilities_.delegated_rendering = delegated_rendering; |
| 49 } | 43 } |
| 50 | 44 |
| 51 FakeOutputSurface::~FakeOutputSurface() {} | 45 FakeOutputSurface::~FakeOutputSurface() {} |
| 52 | 46 |
| 53 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) { | 47 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) { |
| 54 if (frame->delegated_frame_data || !context_provider()) { | 48 if (frame->delegated_frame_data || !context_provider()) { |
| 55 frame->AssignTo(&last_sent_frame_); | 49 frame->AssignTo(&last_sent_frame_); |
| 56 | 50 |
| 57 if (last_sent_frame_.delegated_frame_data) { | 51 if (last_sent_frame_.delegated_frame_data) { |
| 58 resources_held_by_parent_.insert( | 52 resources_held_by_parent_.insert( |
| 59 resources_held_by_parent_.end(), | 53 resources_held_by_parent_.end(), |
| 60 last_sent_frame_.delegated_frame_data->resource_list.begin(), | 54 last_sent_frame_.delegated_frame_data->resource_list.begin(), |
| 61 last_sent_frame_.delegated_frame_data->resource_list.end()); | 55 last_sent_frame_.delegated_frame_data->resource_list.end()); |
| 62 } | 56 } |
| 63 | 57 |
| 64 ++num_sent_frames_; | 58 ++num_sent_frames_; |
| 65 } else { | 59 } else { |
| 66 last_swap_rect_ = frame->gl_frame_data->sub_buffer_rect; | 60 last_swap_rect_ = frame->gl_frame_data->sub_buffer_rect; |
| 67 frame->AssignTo(&last_sent_frame_); | 61 frame->AssignTo(&last_sent_frame_); |
| 68 ++num_sent_frames_; | 62 ++num_sent_frames_; |
| 69 } | 63 } |
| 70 PostSwapBuffersComplete(); | 64 PostSwapBuffersComplete(); |
| 71 client_->DidSwapBuffers(); | 65 client_->DidSwapBuffers(); |
| 72 } | 66 } |
| 73 | 67 |
| 74 void FakeOutputSurface::BindFramebuffer() { | 68 void FakeOutputSurface::BindFramebuffer() { |
| 75 if (framebuffer_) | 69 if (framebuffer_) { |
| 76 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, | 70 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, |
| 77 framebuffer_); | 71 framebuffer_); |
| 72 } else { |
| 73 OutputSurface::BindFramebuffer(); |
| 74 } |
| 75 } |
| 76 |
| 77 uint32_t FakeOutputSurface::GetFramebufferCopyTextureFormat() { |
| 78 if (framebuffer_) |
| 79 return framebuffer_format_; |
| 78 else | 80 else |
| 79 OutputSurface::BindFramebuffer(); | 81 return GL_RGB; |
| 80 } | 82 } |
| 81 | 83 |
| 82 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { | 84 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { |
| 83 if (OutputSurface::BindToClient(client)) { | 85 if (OutputSurface::BindToClient(client)) { |
| 84 client_ = client; | 86 client_ = client; |
| 85 if (memory_policy_to_set_at_bind_) { | 87 if (memory_policy_to_set_at_bind_) { |
| 86 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get()); | 88 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get()); |
| 87 memory_policy_to_set_at_bind_ = nullptr; | 89 memory_policy_to_set_at_bind_ = nullptr; |
| 88 } | 90 } |
| 89 return true; | 91 return true; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 const { | 125 const { |
| 124 return overlay_candidate_validator_; | 126 return overlay_candidate_validator_; |
| 125 } | 127 } |
| 126 | 128 |
| 127 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( | 129 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( |
| 128 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { | 130 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { |
| 129 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); | 131 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); |
| 130 } | 132 } |
| 131 | 133 |
| 132 } // namespace cc | 134 } // namespace cc |
| OLD | NEW |