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

Side by Side Diff: cc/test/fake_compositor_frame_sink.cc

Issue 2503203002: Revert "Getting rid of DelegatedFrameData" (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « cc/surfaces/surfaces_pixeltest.cc ('k') | cc/test/surface_aggregator_test_helpers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_compositor_frame_sink.h" 5 #include "cc/test/fake_compositor_frame_sink.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "cc/output/compositor_frame_sink_client.h" 9 #include "cc/output/compositor_frame_sink_client.h"
10 #include "cc/resources/returned_resource.h" 10 #include "cc/resources/returned_resource.h"
(...skipping 22 matching lines...) Expand all
33 ReturnResourcesHeldByParent(); 33 ReturnResourcesHeldByParent();
34 CompositorFrameSink::DetachFromClient(); 34 CompositorFrameSink::DetachFromClient();
35 } 35 }
36 36
37 void FakeCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { 37 void FakeCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
38 ReturnResourcesHeldByParent(); 38 ReturnResourcesHeldByParent();
39 39
40 last_sent_frame_.reset(new CompositorFrame(std::move(frame))); 40 last_sent_frame_.reset(new CompositorFrame(std::move(frame)));
41 ++num_sent_frames_; 41 ++num_sent_frames_;
42 42
43 if (!last_sent_frame_->render_pass_list.empty()) { 43 if (last_sent_frame_->delegated_frame_data) {
44 last_swap_rect_ = last_sent_frame_->render_pass_list.back()->damage_rect; 44 auto* frame_data = last_sent_frame_->delegated_frame_data.get();
45 last_swap_rect_ = frame_data->render_pass_list.back()->damage_rect;
45 last_swap_rect_valid_ = true; 46 last_swap_rect_valid_ = true;
46 } else { 47 } else {
47 last_swap_rect_ = gfx::Rect(); 48 last_swap_rect_ = gfx::Rect();
48 last_swap_rect_valid_ = false; 49 last_swap_rect_valid_ = false;
49 } 50 }
50 51
51 resources_held_by_parent_.insert(resources_held_by_parent_.end(), 52 if (last_sent_frame_->delegated_frame_data || !context_provider()) {
52 last_sent_frame_->resource_list.begin(), 53 if (last_sent_frame_->delegated_frame_data) {
53 last_sent_frame_->resource_list.end()); 54 auto* frame_data = last_sent_frame_->delegated_frame_data.get();
55 resources_held_by_parent_.insert(resources_held_by_parent_.end(),
56 frame_data->resource_list.begin(),
57 frame_data->resource_list.end());
58 }
59 }
54 60
55 base::ThreadTaskRunnerHandle::Get()->PostTask( 61 base::ThreadTaskRunnerHandle::Get()->PostTask(
56 FROM_HERE, 62 FROM_HERE,
57 base::Bind(&FakeCompositorFrameSink::DidReceiveCompositorFrameAck, 63 base::Bind(&FakeCompositorFrameSink::DidReceiveCompositorFrameAck,
58 weak_ptr_factory_.GetWeakPtr())); 64 weak_ptr_factory_.GetWeakPtr()));
59 } 65 }
60 66
61 void FakeCompositorFrameSink::DidReceiveCompositorFrameAck() { 67 void FakeCompositorFrameSink::DidReceiveCompositorFrameAck() {
62 client_->DidReceiveCompositorFrameAck(); 68 client_->DidReceiveCompositorFrameAck();
63 } 69 }
64 70
65 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() { 71 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() {
66 if (last_sent_frame_) { 72 // Check |delegated_frame_data| because we shouldn't reclaim resources
73 // for the Display which does not swap delegated frames.
74 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) {
67 // Return the last frame's resources immediately. 75 // Return the last frame's resources immediately.
68 ReturnedResourceArray resources; 76 ReturnedResourceArray resources;
69 for (const auto& resource : resources_held_by_parent_) 77 for (const auto& resource : resources_held_by_parent_)
70 resources.push_back(resource.ToReturnedResource()); 78 resources.push_back(resource.ToReturnedResource());
71 resources_held_by_parent_.clear(); 79 resources_held_by_parent_.clear();
72 client_->ReclaimResources(resources); 80 client_->ReclaimResources(resources);
73 } 81 }
74 } 82 }
75 83
76 } // namespace cc 84 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surfaces_pixeltest.cc ('k') | cc/test/surface_aggregator_test_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698