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

Side by Side Diff: cc/surfaces/surface.cc

Issue 666163006: Allow layers to signal that additional sequences are needed before surface destruction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/surface.h ('k') | cc/surfaces/surface_factory.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/surfaces/surface.h" 5 #include "cc/surfaces/surface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
10 #include "cc/output/copy_output_request.h" 10 #include "cc/output/copy_output_request.h"
11 #include "cc/surfaces/surface_factory.h" 11 #include "cc/surfaces/surface_factory.h"
12 #include "cc/surfaces/surface_id_allocator.h"
12 #include "cc/surfaces/surface_manager.h" 13 #include "cc/surfaces/surface_manager.h"
13 14
14 namespace cc { 15 namespace cc {
15 16
17 namespace {
18 struct SatisfyChecker {
19 SatisfyChecker(base::hash_set<SurfaceSequence>* satisfied)
jamesr 2014/11/06 01:16:17 explicit
20 : satisfied_(satisfied) {}
21
22 bool operator()(const SurfaceSequence& seq) {
23 auto it = satisfied_->find(seq);
24 if (it != satisfied_->end()) {
25 satisfied_->erase(it);
26 return true;
27 }
28 return false;
29 }
30 base::hash_set<SurfaceSequence>* satisfied_;
31 };
32 } // namespace
33
16 // The frame index starts at 2 so that empty frames will be treated as 34 // The frame index starts at 2 so that empty frames will be treated as
17 // completely damaged the first time they're drawn from. 35 // completely damaged the first time they're drawn from.
18 static const int kFrameIndexStart = 2; 36 static const int kFrameIndexStart = 2;
19 37
20 Surface::Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory) 38 Surface::Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory)
21 : surface_id_(id), 39 : surface_id_(id),
22 size_(size), 40 size_(size),
23 factory_(factory->AsWeakPtr()), 41 factory_(factory->AsWeakPtr()),
24 frame_index_(kFrameIndexStart) { 42 frame_index_(kFrameIndexStart) {
25 } 43 }
(...skipping 24 matching lines...) Expand all
50 ReturnedResourceArray previous_resources; 68 ReturnedResourceArray previous_resources;
51 TransferableResource::ReturnResources( 69 TransferableResource::ReturnResources(
52 previous_frame->delegated_frame_data->resource_list, 70 previous_frame->delegated_frame_data->resource_list,
53 &previous_resources); 71 &previous_resources);
54 factory_->UnrefResources(previous_resources); 72 factory_->UnrefResources(previous_resources);
55 } 73 }
56 if (!draw_callback_.is_null()) 74 if (!draw_callback_.is_null())
57 draw_callback_.Run(); 75 draw_callback_.Run();
58 draw_callback_ = callback; 76 draw_callback_ = callback;
59 factory_->manager()->DidSatisfySequences( 77 factory_->manager()->DidSatisfySequences(
60 surface_id_, &current_frame_->metadata.satisfies_sequences); 78 SurfaceIdAllocator::NamespaceForId(surface_id_),
79 &current_frame_->metadata.satisfies_sequences);
61 } 80 }
62 81
63 void Surface::RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request) { 82 void Surface::RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request) {
64 if (current_frame_ && 83 if (current_frame_ &&
65 !current_frame_->delegated_frame_data->render_pass_list.empty()) 84 !current_frame_->delegated_frame_data->render_pass_list.empty())
66 current_frame_->delegated_frame_data->render_pass_list.back() 85 current_frame_->delegated_frame_data->render_pass_list.back()
67 ->copy_requests.push_back(copy_request.Pass()); 86 ->copy_requests.push_back(copy_request.Pass());
68 else 87 else
69 copy_request->SendEmptyResult(); 88 copy_request->SendEmptyResult();
70 } 89 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 123 }
105 124
106 void Surface::RunDrawCallbacks() { 125 void Surface::RunDrawCallbacks() {
107 if (!draw_callback_.is_null()) { 126 if (!draw_callback_.is_null()) {
108 base::Closure callback = draw_callback_; 127 base::Closure callback = draw_callback_;
109 draw_callback_ = base::Closure(); 128 draw_callback_ = base::Closure();
110 callback.Run(); 129 callback.Run();
111 } 130 }
112 } 131 }
113 132
133 void Surface::AddDestructionDependency(SurfaceSequence sequence) {
134 destruction_dependencies_.push_back(sequence);
135 }
136
137 void Surface::SatisfyDestructionDependencies(
138 base::hash_set<SurfaceSequence>* sequences) {
139 destruction_dependencies_.erase(
140 std::remove_if(destruction_dependencies_.begin(),
141 destruction_dependencies_.end(),
142 SatisfyChecker(sequences)),
jamesr 2014/11/06 01:16:17 i think this would be a good use case for a lambda
143 destruction_dependencies_.end());
144 }
145
114 void Surface::ClearCopyRequests() { 146 void Surface::ClearCopyRequests() {
115 if (current_frame_) { 147 if (current_frame_) {
116 for (const auto& render_pass : 148 for (const auto& render_pass :
117 current_frame_->delegated_frame_data->render_pass_list) { 149 current_frame_->delegated_frame_data->render_pass_list) {
118 for (const auto& copy_request : render_pass->copy_requests) 150 for (const auto& copy_request : render_pass->copy_requests)
119 copy_request->SendEmptyResult(); 151 copy_request->SendEmptyResult();
120 } 152 }
121 } 153 }
122 } 154 }
123 155
124 } // namespace cc 156 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface.h ('k') | cc/surfaces/surface_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698