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

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: num_draws_ 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
« no previous file with comments | « cc/test/fake_output_surface.h ('k') | cc/test/layer_tree_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fb16c08021115888dcef15e3e32659ac54a3b617 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,17 @@ void FakeOutputSurface::SetMemoryPolicyToSetAtBind(
memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind);
}
+void FakeOutputSurface::ReturnResourcesHeldByParent() {
+ // Check |delegated_frame_data| because we shouldn't reclaim resources
+ // for the Display which does not swap delegated frames.
+ if (last_sent_frame_ && last_sent_frame_->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
« no previous file with comments | « cc/test/fake_output_surface.h ('k') | cc/test/layer_tree_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698