| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 resources_held_by_parent_.insert(resources_held_by_parent_.end(), | 48 resources_held_by_parent_.insert(resources_held_by_parent_.end(), |
| 49 frame_data->resource_list.begin(), | 49 frame_data->resource_list.begin(), |
| 50 frame_data->resource_list.end()); | 50 frame_data->resource_list.end()); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 PostSwapBuffersComplete(); | 54 PostSwapBuffersComplete(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void FakeOutputSurface::BindFramebuffer() { | 57 void FakeOutputSurface::BindFramebuffer() { |
| 58 if (framebuffer_) { | 58 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, framebuffer_); |
| 59 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, | |
| 60 framebuffer_); | |
| 61 } else { | |
| 62 OutputSurface::BindFramebuffer(); | |
| 63 } | |
| 64 } | 59 } |
| 65 | 60 |
| 66 uint32_t FakeOutputSurface::GetFramebufferCopyTextureFormat() { | 61 uint32_t FakeOutputSurface::GetFramebufferCopyTextureFormat() { |
| 67 if (framebuffer_) | 62 if (framebuffer_) |
| 68 return framebuffer_format_; | 63 return framebuffer_format_; |
| 69 else | 64 else |
| 70 return GL_RGB; | 65 return GL_RGB; |
| 71 } | 66 } |
| 72 | 67 |
| 73 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { | 68 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { |
| 74 if (OutputSurface::BindToClient(client)) { | 69 if (OutputSurface::BindToClient(client)) { |
| 75 client_ = client; | 70 client_ = client; |
| 76 return true; | 71 return true; |
| 77 } else { | 72 } else { |
| 78 return false; | 73 return false; |
| 79 } | 74 } |
| 80 } | 75 } |
| 81 | 76 |
| 82 void FakeOutputSurface::DetachFromClient() { | |
| 83 ReturnResourcesHeldByParent(); | |
| 84 OutputSurface::DetachFromClient(); | |
| 85 } | |
| 86 | |
| 87 bool FakeOutputSurface::HasExternalStencilTest() const { | 77 bool FakeOutputSurface::HasExternalStencilTest() const { |
| 88 return has_external_stencil_test_; | 78 return has_external_stencil_test_; |
| 89 } | 79 } |
| 90 | 80 |
| 91 bool FakeOutputSurface::SurfaceIsSuspendForRecycle() const { | 81 bool FakeOutputSurface::SurfaceIsSuspendForRecycle() const { |
| 92 return suspended_for_recycle_; | 82 return suspended_for_recycle_; |
| 93 } | 83 } |
| 94 | 84 |
| 95 OverlayCandidateValidator* FakeOutputSurface::GetOverlayCandidateValidator() | 85 OverlayCandidateValidator* FakeOutputSurface::GetOverlayCandidateValidator() |
| 96 const { | 86 const { |
| 97 return overlay_candidate_validator_; | 87 return overlay_candidate_validator_; |
| 98 } | 88 } |
| 99 | 89 |
| 90 bool FakeOutputSurface::IsDisplayedAsOverlayPlane() const { |
| 91 return false; |
| 92 } |
| 93 |
| 94 unsigned FakeOutputSurface::GetOverlayTextureId() const { |
| 95 return 0; |
| 96 } |
| 97 |
| 100 void FakeOutputSurface::ReturnResourcesHeldByParent() { | 98 void FakeOutputSurface::ReturnResourcesHeldByParent() { |
| 101 // Check |delegated_frame_data| because we shouldn't reclaim resources | 99 // Check |delegated_frame_data| because we shouldn't reclaim resources |
| 102 // for the Display which does not swap delegated frames. | 100 // for the Display which does not swap delegated frames. |
| 103 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) { | 101 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) { |
| 104 // Return the last frame's resources immediately. | 102 // Return the last frame's resources immediately. |
| 105 ReturnedResourceArray resources; | 103 ReturnedResourceArray resources; |
| 106 for (const auto& resource : resources_held_by_parent_) | 104 for (const auto& resource : resources_held_by_parent_) |
| 107 resources.push_back(resource.ToReturnedResource()); | 105 resources.push_back(resource.ToReturnedResource()); |
| 108 resources_held_by_parent_.clear(); | 106 resources_held_by_parent_.clear(); |
| 109 client_->ReclaimResources(resources); | 107 client_->ReclaimResources(resources); |
| 110 } | 108 } |
| 111 } | 109 } |
| 112 | 110 |
| 113 } // namespace cc | 111 } // namespace cc |
| OLD | NEW |