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

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

Issue 2475773005: Add SurfaceFactory::Reset (Closed)
Patch Set: Add comment per review comment Created 4 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "cc/base/container_util.h" 12 #include "cc/base/container_util.h"
13 #include "cc/output/compositor_frame.h" 13 #include "cc/output/compositor_frame.h"
14 #include "cc/output/copy_output_request.h" 14 #include "cc/output/copy_output_request.h"
15 #include "cc/surfaces/surface_factory.h" 15 #include "cc/surfaces/surface_factory.h"
16 #include "cc/surfaces/surface_id_allocator.h" 16 #include "cc/surfaces/surface_id_allocator.h"
17 #include "cc/surfaces/surface_manager.h" 17 #include "cc/surfaces/surface_manager.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 // The frame index starts at 2 so that empty frames will be treated as 21 // The frame index starts at 2 so that empty frames will be treated as
22 // completely damaged the first time they're drawn from. 22 // completely damaged the first time they're drawn from.
23 static const int kFrameIndexStart = 2; 23 static const int kFrameIndexStart = 2;
24 24
25 Surface::Surface(const SurfaceId& id, SurfaceFactory* factory) 25 Surface::Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory)
26 : surface_id_(id), 26 : surface_id_(id),
27 previous_frame_surface_id_(id), 27 previous_frame_surface_id_(id),
28 factory_(factory->AsWeakPtr()), 28 factory_(factory),
29 frame_index_(kFrameIndexStart), 29 frame_index_(kFrameIndexStart),
30 destroyed_(false) {} 30 destroyed_(false) {}
31 31
32 Surface::~Surface() { 32 Surface::~Surface() {
33 ClearCopyRequests(); 33 ClearCopyRequests();
34 if (current_frame_ && factory_) { 34 if (current_frame_ && factory_) {
35 UnrefFrameResources(*current_frame_); 35 UnrefFrameResources(*current_frame_);
36 } 36 }
37 if (!draw_callback_.is_null()) 37 if (!draw_callback_.is_null())
38 draw_callback_.Run(); 38 draw_callback_.Run();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void Surface::ClearCopyRequests() { 182 void Surface::ClearCopyRequests() {
183 if (current_frame_) { 183 if (current_frame_) {
184 for (const auto& render_pass : current_frame_->render_pass_list) { 184 for (const auto& render_pass : current_frame_->render_pass_list) {
185 for (const auto& copy_request : render_pass->copy_requests) 185 for (const auto& copy_request : render_pass->copy_requests)
186 copy_request->SendEmptyResult(); 186 copy_request->SendEmptyResult();
187 } 187 }
188 } 188 }
189 } 189 }
190 190
191 } // namespace cc 191 } // 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