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

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

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: nit 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_->delegated_frame_data) { 43 if (!last_sent_frame_->render_pass_list.empty()) {
44 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); 44 last_swap_rect_ = last_sent_frame_->render_pass_list.back()->damage_rect;
45 last_swap_rect_ = frame_data->render_pass_list.back()->damage_rect;
46 last_swap_rect_valid_ = true; 45 last_swap_rect_valid_ = true;
47 } else { 46 } else {
48 last_swap_rect_ = gfx::Rect(); 47 last_swap_rect_ = gfx::Rect();
49 last_swap_rect_valid_ = false; 48 last_swap_rect_valid_ = false;
50 } 49 }
51 50
52 if (last_sent_frame_->delegated_frame_data || !context_provider()) { 51 resources_held_by_parent_.insert(resources_held_by_parent_.end(),
53 if (last_sent_frame_->delegated_frame_data) { 52 last_sent_frame_->resource_list.begin(),
54 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); 53 last_sent_frame_->resource_list.end());
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 }
60 54
61 base::ThreadTaskRunnerHandle::Get()->PostTask( 55 base::ThreadTaskRunnerHandle::Get()->PostTask(
62 FROM_HERE, 56 FROM_HERE,
63 base::Bind(&FakeCompositorFrameSink::DidReceiveCompositorFrameAck, 57 base::Bind(&FakeCompositorFrameSink::DidReceiveCompositorFrameAck,
64 weak_ptr_factory_.GetWeakPtr())); 58 weak_ptr_factory_.GetWeakPtr()));
65 } 59 }
66 60
67 void FakeCompositorFrameSink::DidReceiveCompositorFrameAck() { 61 void FakeCompositorFrameSink::DidReceiveCompositorFrameAck() {
68 client_->DidReceiveCompositorFrameAck(); 62 client_->DidReceiveCompositorFrameAck();
69 } 63 }
70 64
71 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() { 65 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() {
72 // Check |delegated_frame_data| because we shouldn't reclaim resources 66 if (last_sent_frame_) {
73 // for the Display which does not swap delegated frames.
74 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) {
75 // Return the last frame's resources immediately. 67 // Return the last frame's resources immediately.
76 ReturnedResourceArray resources; 68 ReturnedResourceArray resources;
77 for (const auto& resource : resources_held_by_parent_) 69 for (const auto& resource : resources_held_by_parent_)
78 resources.push_back(resource.ToReturnedResource()); 70 resources.push_back(resource.ToReturnedResource());
79 resources_held_by_parent_.clear(); 71 resources_held_by_parent_.clear();
80 client_->ReclaimResources(resources); 72 client_->ReclaimResources(resources);
81 } 73 }
82 } 74 }
83 75
84 } // namespace cc 76 } // 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