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

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

Issue 1175703004: cc: DCHECK if SDOS::SwapBuffersComplete is called prematurely (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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_display_output_surface.h ('k') | no next file » | 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_display_output_surface.h" 5 #include "cc/surfaces/surface_display_output_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/compositor_frame_ack.h" 9 #include "cc/output/compositor_frame_ack.h"
10 #include "cc/surfaces/display.h" 10 #include "cc/surfaces/display.h"
11 #include "cc/surfaces/onscreen_display_client.h" 11 #include "cc/surfaces/onscreen_display_client.h"
12 #include "cc/surfaces/surface.h" 12 #include "cc/surfaces/surface.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 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface( 17 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface(
18 SurfaceManager* surface_manager, 18 SurfaceManager* surface_manager,
19 SurfaceIdAllocator* allocator, 19 SurfaceIdAllocator* allocator,
20 const scoped_refptr<ContextProvider>& context_provider) 20 const scoped_refptr<ContextProvider>& context_provider)
21 : OutputSurface(context_provider), 21 : OutputSurface(context_provider),
22 display_client_(NULL), 22 display_client_(NULL),
23 factory_(surface_manager, this), 23 factory_(surface_manager, this),
24 allocator_(allocator) { 24 allocator_(allocator),
25 inside_swap_buffers_(false) {
jbauman 2015/06/10 00:17:45 0
25 factory_.set_needs_sync_points(false); 26 factory_.set_needs_sync_points(false);
26 capabilities_.delegated_rendering = true; 27 capabilities_.delegated_rendering = true;
27 capabilities_.max_frames_pending = 1; 28 capabilities_.max_frames_pending = 1;
28 capabilities_.adjust_deadline_for_parent = true; 29 capabilities_.adjust_deadline_for_parent = true;
29 capabilities_.can_force_reclaim_resources = true; 30 capabilities_.can_force_reclaim_resources = true;
30 // Display and SurfaceDisplayOutputSurface share a GL context, so sync 31 // Display and SurfaceDisplayOutputSurface share a GL context, so sync
31 // points aren't needed when passing resources between them. 32 // points aren't needed when passing resources between them.
32 capabilities_.delegated_sync_points_required = false; 33 capabilities_.delegated_sync_points_required = false;
33 } 34 }
34 35
35 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { 36 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() {
36 client_ = NULL; 37 client_ = NULL;
37 if (!surface_id_.is_null()) { 38 if (!surface_id_.is_null()) {
38 factory_.Destroy(surface_id_); 39 factory_.Destroy(surface_id_);
39 } 40 }
40 } 41 }
41 42
42 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters( 43 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters(
43 base::TimeTicks timebase, 44 base::TimeTicks timebase,
44 base::TimeDelta interval) { 45 base::TimeDelta interval) {
45 CommitVSyncParameters(timebase, interval); 46 CommitVSyncParameters(timebase, interval);
46 } 47 }
47 48
48 void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame* frame) { 49 void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame* frame) {
50 inside_swap_buffers_ = 1;
51
49 gfx::Size frame_size = 52 gfx::Size frame_size =
50 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); 53 frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
51 if (frame_size.IsEmpty() || frame_size != display_size_) { 54 if (frame_size.IsEmpty() || frame_size != display_size_) {
55 inside_swap_buffers_ = 2;
52 if (!surface_id_.is_null()) { 56 if (!surface_id_.is_null()) {
53 factory_.Destroy(surface_id_); 57 factory_.Destroy(surface_id_);
54 } 58 }
59 inside_swap_buffers_ = 3;
55 surface_id_ = allocator_->GenerateId(); 60 surface_id_ = allocator_->GenerateId();
56 factory_.Create(surface_id_); 61 factory_.Create(surface_id_);
57 display_size_ = frame_size; 62 display_size_ = frame_size;
58 } 63 }
64 inside_swap_buffers_ = 4;
59 display_client_->display()->SetSurfaceId(surface_id_, 65 display_client_->display()->SetSurfaceId(surface_id_,
60 frame->metadata.device_scale_factor); 66 frame->metadata.device_scale_factor);
61 67
68 inside_swap_buffers_ = 5;
62 scoped_ptr<CompositorFrame> frame_copy(new CompositorFrame()); 69 scoped_ptr<CompositorFrame> frame_copy(new CompositorFrame());
70 inside_swap_buffers_ = 6;
63 frame->AssignTo(frame_copy.get()); 71 frame->AssignTo(frame_copy.get());
72 inside_swap_buffers_ = 7;
64 factory_.SubmitFrame( 73 factory_.SubmitFrame(
65 surface_id_, frame_copy.Pass(), 74 surface_id_, frame_copy.Pass(),
66 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, 75 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete,
67 base::Unretained(this))); 76 base::Unretained(this)));
68 77
78 inside_swap_buffers_ = 0;
79
69 client_->DidSwapBuffers(); 80 client_->DidSwapBuffers();
70 } 81 }
71 82
72 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { 83 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) {
73 DCHECK(client); 84 DCHECK(client);
74 DCHECK(display_client_); 85 DCHECK(display_client_);
75 client_ = client; 86 client_ = client;
76 // Avoid initializing GL context here, as this should be sharing the 87 // Avoid initializing GL context here, as this should be sharing the
77 // Display's context. 88 // Display's context.
78 return display_client_->Initialize(); 89 return display_client_->Initialize();
79 } 90 }
80 91
81 void SurfaceDisplayOutputSurface::ForceReclaimResources() { 92 void SurfaceDisplayOutputSurface::ForceReclaimResources() {
82 if (!surface_id_.is_null()) 93 if (!surface_id_.is_null())
83 factory_.SubmitFrame(surface_id_, nullptr, SurfaceFactory::DrawCallback()); 94 factory_.SubmitFrame(surface_id_, nullptr, SurfaceFactory::DrawCallback());
84 } 95 }
85 96
86 void SurfaceDisplayOutputSurface::ReturnResources( 97 void SurfaceDisplayOutputSurface::ReturnResources(
87 const ReturnedResourceArray& resources) { 98 const ReturnedResourceArray& resources) {
88 CompositorFrameAck ack; 99 CompositorFrameAck ack;
89 ack.resources = resources; 100 ack.resources = resources;
90 if (client_) 101 if (client_)
91 client_->ReclaimResources(&ack); 102 client_->ReclaimResources(&ack);
92 } 103 }
93 104
94 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { 105 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) {
106 DCHECK_EQ(0, inside_swap_buffers_);
95 if (client_ && !display_client_->output_surface_lost()) 107 if (client_ && !display_client_->output_surface_lost())
96 client_->DidSwapBuffersComplete(); 108 client_->DidSwapBuffersComplete();
97 } 109 }
98 110
99 } // namespace cc 111 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_display_output_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698