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

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

Issue 465673003: Add callback when queueing frame on Surface to create backpressure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/surfaces/surface.h ('k') | cc/surfaces/surface_aggregator_unittest.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 "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/surfaces/surface_factory.h" 8 #include "cc/surfaces/surface_factory.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 Surface::Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory) 12 Surface::Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory)
13 : surface_id_(id), size_(size), factory_(factory) { 13 : surface_id_(id), size_(size), factory_(factory) {
14 } 14 }
15 15
16 Surface::~Surface() { 16 Surface::~Surface() {
17 if (current_frame_) { 17 if (current_frame_) {
18 ReturnedResourceArray current_resources; 18 ReturnedResourceArray current_resources;
19 TransferableResource::ReturnResources( 19 TransferableResource::ReturnResources(
20 current_frame_->delegated_frame_data->resource_list, 20 current_frame_->delegated_frame_data->resource_list,
21 &current_resources); 21 &current_resources);
22 factory_->UnrefResources(current_resources); 22 factory_->UnrefResources(current_resources);
23 } 23 }
24 } 24 }
25 25
26 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame) { 26 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame,
27 const base::Closure& callback) {
27 scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass(); 28 scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass();
28 current_frame_ = frame.Pass(); 29 current_frame_ = frame.Pass();
29 factory_->ReceiveFromChild( 30 factory_->ReceiveFromChild(
30 current_frame_->delegated_frame_data->resource_list); 31 current_frame_->delegated_frame_data->resource_list);
31 32
32 if (previous_frame) { 33 if (previous_frame) {
33 ReturnedResourceArray previous_resources; 34 ReturnedResourceArray previous_resources;
34 TransferableResource::ReturnResources( 35 TransferableResource::ReturnResources(
35 previous_frame->delegated_frame_data->resource_list, 36 previous_frame->delegated_frame_data->resource_list,
36 &previous_resources); 37 &previous_resources);
37 factory_->UnrefResources(previous_resources); 38 factory_->UnrefResources(previous_resources);
38 } 39 }
40 if (!draw_callback_.is_null())
41 draw_callback_.Run();
42 draw_callback_ = callback;
39 } 43 }
40 44
41 const CompositorFrame* Surface::GetEligibleFrame() { 45 const CompositorFrame* Surface::GetEligibleFrame() {
42 return current_frame_.get(); 46 return current_frame_.get();
43 } 47 }
44 48
49 void Surface::RunDrawCallbacks() {
50 if (!draw_callback_.is_null()) {
51 base::Closure callback = draw_callback_;
52 draw_callback_ = base::Closure();
53 callback.Run();
54 }
55 }
56
45 } // namespace cc 57 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface.h ('k') | cc/surfaces/surface_aggregator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698