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

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

Issue 2425923003: Replaced is_null() with is_valid in SurfaceId and related classes. (Closed)
Patch Set: Removed added printf statements; LocalFrameId::is_valid() no longer checks if nonce is 0. Created 4 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 "cc/surfaces/direct_compositor_frame_sink.h" 5 #include "cc/surfaces/direct_compositor_frame_sink.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_sink_client.h" 9 #include "cc/output/compositor_frame_sink_client.h"
10 #include "cc/surfaces/display.h" 10 #include "cc/surfaces/display.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // Avoid initializing GL context here, as this should be sharing the 71 // Avoid initializing GL context here, as this should be sharing the
72 // Display's context. 72 // Display's context.
73 display_->Initialize(this, surface_manager_, frame_sink_id_); 73 display_->Initialize(this, surface_manager_, frame_sink_id_);
74 return true; 74 return true;
75 } 75 }
76 76
77 void DirectCompositorFrameSink::DetachFromClient() { 77 void DirectCompositorFrameSink::DetachFromClient() {
78 // Unregister the SurfaceFactoryClient here instead of the dtor so that only 78 // Unregister the SurfaceFactoryClient here instead of the dtor so that only
79 // one client is alive for this namespace at any given time. 79 // one client is alive for this namespace at any given time.
80 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); 80 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
81 if (!delegated_local_frame_id_.is_null()) 81 if (delegated_local_frame_id_.is_valid())
82 factory_.Destroy(delegated_local_frame_id_); 82 factory_.Destroy(delegated_local_frame_id_);
83 83
84 CompositorFrameSink::DetachFromClient(); 84 CompositorFrameSink::DetachFromClient();
85 } 85 }
86 86
87 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { 87 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
88 gfx::Size frame_size = 88 gfx::Size frame_size =
89 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); 89 frame.delegated_frame_data->render_pass_list.back()->output_rect.size();
90 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { 90 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) {
91 if (!delegated_local_frame_id_.is_null()) { 91 if (delegated_local_frame_id_.is_valid()) {
92 factory_.Destroy(delegated_local_frame_id_); 92 factory_.Destroy(delegated_local_frame_id_);
93 } 93 }
94 delegated_local_frame_id_ = surface_id_allocator_.GenerateId(); 94 delegated_local_frame_id_ = surface_id_allocator_.GenerateId();
95 factory_.Create(delegated_local_frame_id_); 95 factory_.Create(delegated_local_frame_id_);
96 last_swap_frame_size_ = frame_size; 96 last_swap_frame_size_ = frame_size;
97 } 97 }
98 display_->SetSurfaceId(SurfaceId(frame_sink_id_, delegated_local_frame_id_), 98 display_->SetSurfaceId(SurfaceId(frame_sink_id_, delegated_local_frame_id_),
99 frame.metadata.device_scale_factor); 99 frame.metadata.device_scale_factor);
100 100
101 factory_.SubmitCompositorFrame( 101 factory_.SubmitCompositorFrame(
102 delegated_local_frame_id_, std::move(frame), 102 delegated_local_frame_id_, std::move(frame),
103 base::Bind(&DirectCompositorFrameSink::DidDrawCallback, 103 base::Bind(&DirectCompositorFrameSink::DidDrawCallback,
104 base::Unretained(this))); 104 base::Unretained(this)));
105 } 105 }
106 106
107 void DirectCompositorFrameSink::ForceReclaimResources() { 107 void DirectCompositorFrameSink::ForceReclaimResources() {
108 if (!delegated_local_frame_id_.is_null()) { 108 if (delegated_local_frame_id_.is_valid()) {
109 factory_.SubmitCompositorFrame(delegated_local_frame_id_, CompositorFrame(), 109 factory_.SubmitCompositorFrame(delegated_local_frame_id_, CompositorFrame(),
110 SurfaceFactory::DrawCallback()); 110 SurfaceFactory::DrawCallback());
111 } 111 }
112 } 112 }
113 113
114 void DirectCompositorFrameSink::ReturnResources( 114 void DirectCompositorFrameSink::ReturnResources(
115 const ReturnedResourceArray& resources) { 115 const ReturnedResourceArray& resources) {
116 if (client_) 116 if (client_)
117 client_->ReclaimResources(resources); 117 client_->ReclaimResources(resources);
118 } 118 }
(...skipping 19 matching lines...) Expand all
138 // This notification is not relevant to our client outside of tests. We 138 // This notification is not relevant to our client outside of tests. We
139 // unblock the client from DidDrawCallback() when the surface is going to 139 // unblock the client from DidDrawCallback() when the surface is going to
140 // be drawn. 140 // be drawn.
141 } 141 }
142 142
143 void DirectCompositorFrameSink::DidDrawCallback() { 143 void DirectCompositorFrameSink::DidDrawCallback() {
144 client_->DidReceiveCompositorFrameAck(); 144 client_->DidReceiveCompositorFrameAck();
145 } 145 }
146 146
147 } // namespace cc 147 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698