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

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

Issue 506273002: Aggregate damage rects in surface aggregator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « cc/surfaces/surface.h ('k') | cc/surfaces/surface_aggregator.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 "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 // The frame index starts at 2 so that empty frames will be treated as
13 // completely damaged the first time they're drawn from.
14 static const int kFrameIndexStart = 2;
15
12 Surface::Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory) 16 Surface::Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory)
13 : surface_id_(id), size_(size), factory_(factory) { 17 : surface_id_(id),
18 size_(size),
19 factory_(factory),
20 frame_index_(kFrameIndexStart) {
14 } 21 }
15 22
16 Surface::~Surface() { 23 Surface::~Surface() {
17 if (current_frame_) { 24 if (current_frame_) {
18 ReturnedResourceArray current_resources; 25 ReturnedResourceArray current_resources;
19 TransferableResource::ReturnResources( 26 TransferableResource::ReturnResources(
20 current_frame_->delegated_frame_data->resource_list, 27 current_frame_->delegated_frame_data->resource_list,
21 &current_resources); 28 &current_resources);
22 factory_->UnrefResources(current_resources); 29 factory_->UnrefResources(current_resources);
23 } 30 }
24 } 31 }
25 32
26 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame, 33 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame,
27 const base::Closure& callback) { 34 const base::Closure& callback) {
28 scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass(); 35 scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass();
29 current_frame_ = frame.Pass(); 36 current_frame_ = frame.Pass();
30 factory_->ReceiveFromChild( 37 factory_->ReceiveFromChild(
31 current_frame_->delegated_frame_data->resource_list); 38 current_frame_->delegated_frame_data->resource_list);
39 ++frame_index_;
32 40
33 if (previous_frame) { 41 if (previous_frame) {
34 ReturnedResourceArray previous_resources; 42 ReturnedResourceArray previous_resources;
35 TransferableResource::ReturnResources( 43 TransferableResource::ReturnResources(
36 previous_frame->delegated_frame_data->resource_list, 44 previous_frame->delegated_frame_data->resource_list,
37 &previous_resources); 45 &previous_resources);
38 factory_->UnrefResources(previous_resources); 46 factory_->UnrefResources(previous_resources);
39 } 47 }
40 if (!draw_callback_.is_null()) 48 if (!draw_callback_.is_null())
41 draw_callback_.Run(); 49 draw_callback_.Run();
42 draw_callback_ = callback; 50 draw_callback_ = callback;
43 } 51 }
44 52
45 const CompositorFrame* Surface::GetEligibleFrame() { 53 const CompositorFrame* Surface::GetEligibleFrame() {
46 return current_frame_.get(); 54 return current_frame_.get();
47 } 55 }
48 56
49 void Surface::RunDrawCallbacks() { 57 void Surface::RunDrawCallbacks() {
50 if (!draw_callback_.is_null()) { 58 if (!draw_callback_.is_null()) {
51 base::Closure callback = draw_callback_; 59 base::Closure callback = draw_callback_;
52 draw_callback_ = base::Closure(); 60 draw_callback_ = base::Closure();
53 callback.Run(); 61 callback.Run();
54 } 62 }
55 } 63 }
56 64
57 } // namespace cc 65 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface.h ('k') | cc/surfaces/surface_aggregator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698