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

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

Issue 1304063014: cc: Plumbing for BeginFrameSource based on Surfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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_id_allocator.h"
13 #include "cc/surfaces/surface_manager.h" 13 #include "cc/surfaces/surface_manager.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 // The frame index starts at 2 so that empty frames will be treated as 17 // The frame index starts at 2 so that empty frames will be treated as
18 // completely damaged the first time they're drawn from. 18 // completely damaged the first time they're drawn from.
19 static const int kFrameIndexStart = 2; 19 static const int kFrameIndexStart = 2;
20 20
21 Surface::Surface(SurfaceId id, SurfaceFactory* factory) 21 Surface::Surface(SurfaceId id, SurfaceFactory* factory)
22 : surface_id_(id), 22 : surface_id_(id),
23 factory_(factory->AsWeakPtr()), 23 factory_(factory->AsWeakPtr()),
24 frame_index_(kFrameIndexStart), 24 frame_index_(kFrameIndexStart),
25 destroyed_(false) {} 25 destroyed_(false) {
26 factory_->client()->SetBeginFrameSource(surface_id_, NULL);
27 }
26 28
27 Surface::~Surface() { 29 Surface::~Surface() {
28 ClearCopyRequests(); 30 ClearCopyRequests();
29 if (current_frame_ && factory_) { 31 if (current_frame_ && factory_) {
30 ReturnedResourceArray current_resources; 32 ReturnedResourceArray current_resources;
31 TransferableResource::ReturnResources( 33 TransferableResource::ReturnResources(
32 current_frame_->delegated_frame_data->resource_list, 34 current_frame_->delegated_frame_data->resource_list,
33 &current_resources); 35 &current_resources);
34 factory_->UnrefResources(current_resources); 36 factory_->UnrefResources(current_resources);
35 } 37 }
36 if (!draw_callback_.is_null()) 38 if (!draw_callback_.is_null())
37 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED); 39 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED);
40
41 factory_->client()->SetBeginFrameSource(surface_id_, NULL);
38 } 42 }
39 43
40 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame, 44 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame,
41 const DrawCallback& callback) { 45 const DrawCallback& callback) {
42 DCHECK(factory_); 46 DCHECK(factory_);
43 ClearCopyRequests(); 47 ClearCopyRequests();
44 48
45 if (frame) { 49 if (frame) {
46 TakeLatencyInfo(&frame->metadata.latency_info); 50 TakeLatencyInfo(&frame->metadata.latency_info);
47 } 51 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (current_frame_) { 172 if (current_frame_) {
169 for (const auto& render_pass : 173 for (const auto& render_pass :
170 current_frame_->delegated_frame_data->render_pass_list) { 174 current_frame_->delegated_frame_data->render_pass_list) {
171 for (const auto& copy_request : render_pass->copy_requests) 175 for (const auto& copy_request : render_pass->copy_requests)
172 copy_request->SendEmptyResult(); 176 copy_request->SendEmptyResult();
173 } 177 }
174 } 178 }
175 } 179 }
176 180
177 } // namespace cc 181 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698