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

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

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: IsEmpty + rebase 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
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 15 matching lines...) Expand all
26 ReturnResourcesHeldByParent(); 26 ReturnResourcesHeldByParent();
27 CompositorFrameSink::DetachFromClient(); 27 CompositorFrameSink::DetachFromClient();
28 } 28 }
29 29
30 void FakeCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { 30 void FakeCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
31 ReturnResourcesHeldByParent(); 31 ReturnResourcesHeldByParent();
32 32
33 last_sent_frame_.reset(new CompositorFrame(std::move(frame))); 33 last_sent_frame_.reset(new CompositorFrame(std::move(frame)));
34 ++num_sent_frames_; 34 ++num_sent_frames_;
35 35
36 if (last_sent_frame_->delegated_frame_data) { 36 if (!last_sent_frame_->render_pass_list.empty()) {
37 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); 37 last_swap_rect_ = last_sent_frame_->render_pass_list.back()->damage_rect;
38 last_swap_rect_ = frame_data->render_pass_list.back()->damage_rect;
39 last_swap_rect_valid_ = true; 38 last_swap_rect_valid_ = true;
40 } else { 39 } else {
41 last_swap_rect_ = gfx::Rect(); 40 last_swap_rect_ = gfx::Rect();
42 last_swap_rect_valid_ = false; 41 last_swap_rect_valid_ = false;
43 } 42 }
44 43
45 if (last_sent_frame_->delegated_frame_data || !context_provider()) { 44 if (!last_sent_frame_->resource_list.empty()) {
danakj 2016/10/27 23:06:57 dont need this if at all, begin() and end() will d
Saman Sami 2016/10/28 16:47:36 Done.
46 if (last_sent_frame_->delegated_frame_data) { 45 resources_held_by_parent_.insert(resources_held_by_parent_.end(),
47 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); 46 last_sent_frame_->resource_list.begin(),
48 resources_held_by_parent_.insert(resources_held_by_parent_.end(), 47 last_sent_frame_->resource_list.end());
49 frame_data->resource_list.begin(),
50 frame_data->resource_list.end());
51 }
52 } 48 }
53 49
54 base::ThreadTaskRunnerHandle::Get()->PostTask( 50 base::ThreadTaskRunnerHandle::Get()->PostTask(
55 FROM_HERE, 51 FROM_HERE,
56 base::Bind(&FakeCompositorFrameSink::DidReceiveCompositorFrameAck, 52 base::Bind(&FakeCompositorFrameSink::DidReceiveCompositorFrameAck,
57 weak_ptr_factory_.GetWeakPtr())); 53 weak_ptr_factory_.GetWeakPtr()));
58 } 54 }
59 55
60 void FakeCompositorFrameSink::DidReceiveCompositorFrameAck() { 56 void FakeCompositorFrameSink::DidReceiveCompositorFrameAck() {
61 client_->DidReceiveCompositorFrameAck(); 57 client_->DidReceiveCompositorFrameAck();
62 } 58 }
63 59
64 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() { 60 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() {
65 // Check |delegated_frame_data| because we shouldn't reclaim resources 61 if (last_sent_frame_) {
66 // for the Display which does not swap delegated frames.
67 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) {
68 // Return the last frame's resources immediately. 62 // Return the last frame's resources immediately.
69 ReturnedResourceArray resources; 63 ReturnedResourceArray resources;
70 for (const auto& resource : resources_held_by_parent_) 64 for (const auto& resource : resources_held_by_parent_)
71 resources.push_back(resource.ToReturnedResource()); 65 resources.push_back(resource.ToReturnedResource());
72 resources_held_by_parent_.clear(); 66 resources_held_by_parent_.clear();
73 client_->ReclaimResources(resources); 67 client_->ReclaimResources(resources);
74 } 68 }
75 } 69 }
76 70
77 } // namespace cc 71 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698