Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4077)

Unified Diff: cc/test/fake_output_surface.cc

Issue 2151433004: cc: Make LayerTreeHostImpl::SwapBuffers not virtual. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@removedidswap
Patch Set: novirtualswapbuffers: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/test/fake_output_surface.cc
diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc
index 876b64f986309ce228bebf681327b8655d28fee3..65ec1af0e04be6b404740182897551fd5181257e 100644
--- a/cc/test/fake_output_surface.cc
+++ b/cc/test/fake_output_surface.cc
@@ -42,9 +42,11 @@ FakeOutputSurface::FakeOutputSurface(
capabilities_.delegated_rendering = delegated_rendering;
}
-FakeOutputSurface::~FakeOutputSurface() {}
+FakeOutputSurface::~FakeOutputSurface() = default;
void FakeOutputSurface::SwapBuffers(CompositorFrame frame) {
+ ReturnResourcesHeldByParent();
+
std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame);
*frame_copy = std::move(frame);
if (frame_copy->delegated_frame_data || !context_provider()) {
@@ -95,25 +97,17 @@ bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) {
}
}
+void FakeOutputSurface::DetachFromClient() {
+ ReturnResourcesHeldByParent();
+ OutputSurface::DetachFromClient();
+}
+
void FakeOutputSurface::SetTreeActivationCallback(
const base::Closure& callback) {
DCHECK(client_);
client_->SetTreeActivationCallback(callback);
}
-void FakeOutputSurface::ReturnResource(unsigned id, CompositorFrameAck* ack) {
- TransferableResourceArray::iterator it;
- for (it = resources_held_by_parent_.begin();
- it != resources_held_by_parent_.end();
- ++it) {
- if (it->id == id)
- break;
- }
- DCHECK(it != resources_held_by_parent_.end());
- ack->resources.push_back(it->ToReturnedResource());
- resources_held_by_parent_.erase(it);
-}
-
bool FakeOutputSurface::HasExternalStencilTest() const {
return has_external_stencil_test_;
}
@@ -132,4 +126,19 @@ void FakeOutputSurface::SetMemoryPolicyToSetAtBind(
memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind);
}
+void FakeOutputSurface::ReturnResourcesHeldByParent() {
+ if (last_sent_frame_) {
+ DelegatedFrameData* delegated_frame_data =
+ last_sent_frame_->delegated_frame_data.get();
+ if (delegated_frame_data) {
+ // Return the last frame's resources immediately.
+ CompositorFrameAck ack;
+ for (const auto& resource : resources_held_by_parent_)
+ ack.resources.push_back(resource.ToReturnedResource());
+ resources_held_by_parent_.clear();
+ client_->ReclaimResources(&ack);
+ }
+ }
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698