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

Side by Side Diff: content/browser/compositor/surface_display_output_surface.cc

Issue 553213003: Avoid destroying surface before the parent surface stops referencing it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 "content/browser/compositor/surface_display_output_surface.h" 5 #include "content/browser/compositor/surface_display_output_surface.h"
6 6
7 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/output/compositor_frame_ack.h" 8 #include "cc/output/compositor_frame_ack.h"
9 #include "cc/surfaces/display.h" 9 #include "cc/surfaces/display.h"
10 #include "cc/surfaces/surface.h" 10 #include "cc/surfaces/surface.h"
11 #include "cc/surfaces/surface_manager.h" 11 #include "cc/surfaces/surface_manager.h"
12 #include "content/browser/compositor/onscreen_display_client.h" 12 #include "content/browser/compositor/onscreen_display_client.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface( 16 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface(
17 cc::SurfaceManager* surface_manager, 17 cc::SurfaceManager* surface_manager,
18 uint32_t surface_id_namespace, 18 cc::SurfaceIdAllocator* allocator,
19 const scoped_refptr<cc::ContextProvider>& context_provider) 19 const scoped_refptr<cc::ContextProvider>& context_provider)
20 : cc::OutputSurface(context_provider, 20 : cc::OutputSurface(context_provider,
21 scoped_ptr<cc::SoftwareOutputDevice>()), 21 scoped_ptr<cc::SoftwareOutputDevice>()),
22 display_client_(NULL), 22 display_client_(NULL),
23 surface_manager_(surface_manager), 23 surface_manager_(surface_manager),
24 factory_(surface_manager, this), 24 factory_(surface_manager, this),
25 allocator_(surface_id_namespace) { 25 allocator_(allocator) {
26 capabilities_.delegated_rendering = true; 26 capabilities_.delegated_rendering = true;
27 capabilities_.max_frames_pending = 1; 27 capabilities_.max_frames_pending = 1;
28 } 28 }
29 29
30 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { 30 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() {
31 client_ = NULL; 31 client_ = NULL;
32 if (!surface_id_.is_null()) { 32 if (!surface_id_.is_null()) {
33 factory_.Destroy(surface_id_); 33 factory_.Destroy(surface_id_);
34 } 34 }
35 } 35 }
36 36
37 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters( 37 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters(
38 base::TimeTicks timebase, 38 base::TimeTicks timebase,
39 base::TimeDelta interval) { 39 base::TimeDelta interval) {
40 CommitVSyncParameters(timebase, interval); 40 CommitVSyncParameters(timebase, interval);
41 } 41 }
42 42
43 void SurfaceDisplayOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { 43 void SurfaceDisplayOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
44 gfx::Size frame_size = 44 gfx::Size frame_size =
45 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); 45 frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
46 if (frame_size != display_size_) { 46 if (frame_size != display_size_) {
47 if (!surface_id_.is_null()) { 47 if (!surface_id_.is_null()) {
48 factory_.Destroy(surface_id_); 48 factory_.Destroy(surface_id_);
49 } 49 }
50 surface_id_ = allocator_.GenerateId(); 50 surface_id_ = allocator_->GenerateId();
51 factory_.Create(surface_id_, frame_size); 51 factory_.Create(surface_id_, frame_size);
52 display_size_ = frame_size; 52 display_size_ = frame_size;
53 display_client_->display()->Resize(surface_id_, frame_size); 53 display_client_->display()->Resize(surface_id_, frame_size);
54 } 54 }
55 55
56 scoped_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame()); 56 scoped_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame());
57 frame->AssignTo(frame_copy.get()); 57 frame->AssignTo(frame_copy.get());
58 factory_.SubmitFrame( 58 factory_.SubmitFrame(
59 surface_id_, 59 surface_id_,
60 frame_copy.Pass(), 60 frame_copy.Pass(),
(...skipping 20 matching lines...) Expand all
81 ack.resources = resources; 81 ack.resources = resources;
82 if (client_) 82 if (client_)
83 client_->ReclaimResources(&ack); 83 client_->ReclaimResources(&ack);
84 } 84 }
85 85
86 void SurfaceDisplayOutputSurface::SwapBuffersComplete() { 86 void SurfaceDisplayOutputSurface::SwapBuffersComplete() {
87 client_->DidSwapBuffersComplete(); 87 client_->DidSwapBuffersComplete();
88 } 88 }
89 89
90 } // namespace content 90 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698