| 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" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 uint32_t FakeOutputSurface::GetFramebufferCopyTextureFormat() { | 78 uint32_t FakeOutputSurface::GetFramebufferCopyTextureFormat() { |
| 79 if (framebuffer_) | 79 if (framebuffer_) |
| 80 return framebuffer_format_; | 80 return framebuffer_format_; |
| 81 else | 81 else |
| 82 return GL_RGB; | 82 return GL_RGB; |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { | 85 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { |
| 86 if (OutputSurface::BindToClient(client)) { | 86 if (OutputSurface::BindToClient(client)) { |
| 87 client_ = client; | 87 client_ = client; |
| 88 if (memory_policy_to_set_at_bind_) { | |
| 89 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get()); | |
| 90 memory_policy_to_set_at_bind_ = nullptr; | |
| 91 } | |
| 92 return true; | 88 return true; |
| 93 } else { | 89 } else { |
| 94 return false; | 90 return false; |
| 95 } | 91 } |
| 96 } | 92 } |
| 97 | 93 |
| 98 void FakeOutputSurface::DetachFromClient() { | 94 void FakeOutputSurface::DetachFromClient() { |
| 99 ReturnResourcesHeldByParent(); | 95 ReturnResourcesHeldByParent(); |
| 100 OutputSurface::DetachFromClient(); | 96 OutputSurface::DetachFromClient(); |
| 101 } | 97 } |
| 102 | 98 |
| 103 bool FakeOutputSurface::HasExternalStencilTest() const { | 99 bool FakeOutputSurface::HasExternalStencilTest() const { |
| 104 return has_external_stencil_test_; | 100 return has_external_stencil_test_; |
| 105 } | 101 } |
| 106 | 102 |
| 107 bool FakeOutputSurface::SurfaceIsSuspendForRecycle() const { | 103 bool FakeOutputSurface::SurfaceIsSuspendForRecycle() const { |
| 108 return suspended_for_recycle_; | 104 return suspended_for_recycle_; |
| 109 } | 105 } |
| 110 | 106 |
| 111 OverlayCandidateValidator* FakeOutputSurface::GetOverlayCandidateValidator() | 107 OverlayCandidateValidator* FakeOutputSurface::GetOverlayCandidateValidator() |
| 112 const { | 108 const { |
| 113 return overlay_candidate_validator_; | 109 return overlay_candidate_validator_; |
| 114 } | 110 } |
| 115 | 111 |
| 116 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( | |
| 117 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { | |
| 118 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); | |
| 119 } | |
| 120 | |
| 121 void FakeOutputSurface::ReturnResourcesHeldByParent() { | 112 void FakeOutputSurface::ReturnResourcesHeldByParent() { |
| 122 // Check |delegated_frame_data| because we shouldn't reclaim resources | 113 // Check |delegated_frame_data| because we shouldn't reclaim resources |
| 123 // for the Display which does not swap delegated frames. | 114 // for the Display which does not swap delegated frames. |
| 124 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) { | 115 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) { |
| 125 // Return the last frame's resources immediately. | 116 // Return the last frame's resources immediately. |
| 126 ReturnedResourceArray resources; | 117 ReturnedResourceArray resources; |
| 127 for (const auto& resource : resources_held_by_parent_) | 118 for (const auto& resource : resources_held_by_parent_) |
| 128 resources.push_back(resource.ToReturnedResource()); | 119 resources.push_back(resource.ToReturnedResource()); |
| 129 resources_held_by_parent_.clear(); | 120 resources_held_by_parent_.clear(); |
| 130 client_->ReclaimResources(resources); | 121 client_->ReclaimResources(resources); |
| 131 } | 122 } |
| 132 } | 123 } |
| 133 | 124 |
| 134 } // namespace cc | 125 } // namespace cc |
| OLD | NEW |