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

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 12
13 namespace content { 13 namespace content {
14 14
15 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface( 15 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface(
16 cc::SurfaceManager* surface_manager, 16 cc::SurfaceManager* surface_manager,
17 uint32_t surface_id_namespace, 17 cc::SurfaceIdAllocator* allocator,
18 const scoped_refptr<cc::ContextProvider>& context_provider) 18 const scoped_refptr<cc::ContextProvider>& context_provider)
19 : cc::OutputSurface(context_provider, 19 : cc::OutputSurface(context_provider,
20 scoped_ptr<cc::SoftwareOutputDevice>()), 20 scoped_ptr<cc::SoftwareOutputDevice>()),
21 display_(NULL), 21 display_(NULL),
22 surface_manager_(surface_manager), 22 surface_manager_(surface_manager),
23 factory_(surface_manager, this), 23 factory_(surface_manager, this),
24 allocator_(surface_id_namespace) { 24 allocator_(allocator) {
25 capabilities_.delegated_rendering = true; 25 capabilities_.delegated_rendering = true;
26 capabilities_.max_frames_pending = 1; 26 capabilities_.max_frames_pending = 1;
27 } 27 }
28 28
29 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { 29 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() {
30 client_ = NULL; 30 client_ = NULL;
31 if (!surface_id_.is_null()) { 31 if (!surface_id_.is_null()) {
32 factory_.Destroy(surface_id_); 32 factory_.Destroy(surface_id_);
33 } 33 }
34 } 34 }
35 35
36 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters( 36 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters(
37 base::TimeTicks timebase, 37 base::TimeTicks timebase,
38 base::TimeDelta interval) { 38 base::TimeDelta interval) {
39 CommitVSyncParameters(timebase, interval); 39 CommitVSyncParameters(timebase, interval);
40 } 40 }
41 41
42 void SurfaceDisplayOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { 42 void SurfaceDisplayOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
43 gfx::Size frame_size = 43 gfx::Size frame_size =
44 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); 44 frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
45 if (frame_size != display_size_) { 45 if (frame_size != display_size_) {
46 if (!surface_id_.is_null()) { 46 if (!surface_id_.is_null()) {
47 factory_.Destroy(surface_id_); 47 factory_.Destroy(surface_id_);
48 } 48 }
49 surface_id_ = allocator_.GenerateId(); 49 surface_id_ = allocator_->GenerateId();
50 factory_.Create(surface_id_, frame_size); 50 factory_.Create(surface_id_, frame_size);
51 display_size_ = frame_size; 51 display_size_ = frame_size;
52 display_->Resize(surface_id_, frame_size); 52 display_->Resize(surface_id_, frame_size);
53 } 53 }
54 54
55 scoped_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame()); 55 scoped_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame());
56 frame->AssignTo(frame_copy.get()); 56 frame->AssignTo(frame_copy.get());
57 factory_.SubmitFrame( 57 factory_.SubmitFrame(
58 surface_id_, 58 surface_id_,
59 frame_copy.Pass(), 59 frame_copy.Pass(),
60 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, 60 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete,
61 base::Unretained(this))); 61 base::Unretained(this)));
62 62
63 client_->DidSwapBuffers(); 63 client_->DidSwapBuffers();
64 } 64 }
65 65
66 void SurfaceDisplayOutputSurface::ReturnResources( 66 void SurfaceDisplayOutputSurface::ReturnResources(
67 const cc::ReturnedResourceArray& resources) { 67 const cc::ReturnedResourceArray& resources) {
68 cc::CompositorFrameAck ack; 68 cc::CompositorFrameAck ack;
69 ack.resources = resources; 69 ack.resources = resources;
70 if (client_) 70 if (client_)
71 client_->ReclaimResources(&ack); 71 client_->ReclaimResources(&ack);
72 } 72 }
73 73
74 void SurfaceDisplayOutputSurface::SwapBuffersComplete() { 74 void SurfaceDisplayOutputSurface::SwapBuffersComplete() {
75 client_->DidSwapBuffersComplete(); 75 client_->DidSwapBuffersComplete();
76 } 76 }
77 77
78 } // namespace content 78 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698