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

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

Issue 1073323002: Use null rather than empty frame to lock Surface resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix frame_index_ incrementing Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | cc/surfaces/surface_display_output_surface.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 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"
(...skipping 23 matching lines...) Expand all
34 factory_->UnrefResources(current_resources); 34 factory_->UnrefResources(current_resources);
35 } 35 }
36 if (!draw_callback_.is_null()) 36 if (!draw_callback_.is_null())
37 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED); 37 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED);
38 } 38 }
39 39
40 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame, 40 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame,
41 const DrawCallback& callback) { 41 const DrawCallback& callback) {
42 DCHECK(factory_); 42 DCHECK(factory_);
43 ClearCopyRequests(); 43 ClearCopyRequests();
44 TakeLatencyInfo(&frame->metadata.latency_info); 44
45 if (frame) {
46 TakeLatencyInfo(&frame->metadata.latency_info);
47 }
48
45 scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass(); 49 scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass();
46 current_frame_ = frame.Pass(); 50 current_frame_ = frame.Pass();
47 factory_->ReceiveFromChild( 51
48 current_frame_->delegated_frame_data->resource_list); 52 if (current_frame_) {
53 factory_->ReceiveFromChild(
54 current_frame_->delegated_frame_data->resource_list);
55 }
56
49 // Empty frames shouldn't be drawn and shouldn't contribute damage, so don't 57 // Empty frames shouldn't be drawn and shouldn't contribute damage, so don't
50 // increment frame index for them. 58 // increment frame index for them.
51 if (!current_frame_ || 59 if (current_frame_ &&
52 !current_frame_->delegated_frame_data->render_pass_list.empty()) 60 !current_frame_->delegated_frame_data->render_pass_list.empty())
53 ++frame_index_; 61 ++frame_index_;
54 62
55 if (previous_frame) { 63 if (previous_frame) {
56 ReturnedResourceArray previous_resources; 64 ReturnedResourceArray previous_resources;
57 TransferableResource::ReturnResources( 65 TransferableResource::ReturnResources(
58 previous_frame->delegated_frame_data->resource_list, 66 previous_frame->delegated_frame_data->resource_list,
59 &previous_resources); 67 &previous_resources);
60 factory_->UnrefResources(previous_resources); 68 factory_->UnrefResources(previous_resources);
61 } 69 }
62 if (!draw_callback_.is_null()) 70 if (!draw_callback_.is_null())
63 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED); 71 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED);
64 draw_callback_ = callback; 72 draw_callback_ = callback;
65 factory_->manager()->DidSatisfySequences( 73
66 SurfaceIdAllocator::NamespaceForId(surface_id_), 74 if (current_frame_) {
67 &current_frame_->metadata.satisfies_sequences); 75 factory_->manager()->DidSatisfySequences(
76 SurfaceIdAllocator::NamespaceForId(surface_id_),
77 &current_frame_->metadata.satisfies_sequences);
78 }
68 } 79 }
69 80
70 void Surface::RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request) { 81 void Surface::RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request) {
71 if (current_frame_ && 82 if (current_frame_ &&
72 !current_frame_->delegated_frame_data->render_pass_list.empty()) 83 !current_frame_->delegated_frame_data->render_pass_list.empty())
73 current_frame_->delegated_frame_data->render_pass_list.back() 84 current_frame_->delegated_frame_data->render_pass_list.back()
74 ->copy_requests.push_back(copy_request.Pass()); 85 ->copy_requests.push_back(copy_request.Pass());
75 else 86 else
76 copy_request->SendEmptyResult(); 87 copy_request->SendEmptyResult();
77 } 88 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (current_frame_) { 146 if (current_frame_) {
136 for (const auto& render_pass : 147 for (const auto& render_pass :
137 current_frame_->delegated_frame_data->render_pass_list) { 148 current_frame_->delegated_frame_data->render_pass_list) {
138 for (const auto& copy_request : render_pass->copy_requests) 149 for (const auto& copy_request : render_pass->copy_requests)
139 copy_request->SendEmptyResult(); 150 copy_request->SendEmptyResult();
140 } 151 }
141 } 152 }
142 } 153 }
143 154
144 } // namespace cc 155 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface_display_output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698