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

Side by Side Diff: android_webview/browser/surfaces_instance.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "android_webview/browser/surfaces_instance.h" 5 #include "android_webview/browser/surfaces_instance.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "android_webview/browser/aw_gl_surface.h" 10 #include "android_webview/browser/aw_gl_surface.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 DCHECK(!g_surfaces_instance); 79 DCHECK(!g_surfaces_instance);
80 g_surfaces_instance = this; 80 g_surfaces_instance = this;
81 81
82 } 82 }
83 83
84 SurfacesInstance::~SurfacesInstance() { 84 SurfacesInstance::~SurfacesInstance() {
85 DCHECK_EQ(g_surfaces_instance, this); 85 DCHECK_EQ(g_surfaces_instance, this);
86 g_surfaces_instance = nullptr; 86 g_surfaces_instance = nullptr;
87 87
88 DCHECK(child_ids_.empty()); 88 DCHECK(child_ids_.empty());
89 if (!root_id_.is_null()) 89 if (root_id_.is_valid())
90 surface_factory_->Destroy(root_id_); 90 surface_factory_->Destroy(root_id_);
91 91
92 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); 92 surface_manager_->InvalidateFrameSinkId(frame_sink_id_);
93 } 93 }
94 94
95 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() { 95 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() {
96 return cc::FrameSinkId(next_client_id_++, 0 /* sink_id */); 96 return cc::FrameSinkId(next_client_id_++, 0 /* sink_id */);
97 } 97 }
98 98
99 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() { 99 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() {
(...skipping 28 matching lines...) Expand all
128 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds), 128 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds),
129 gfx::Rect(quad_state->quad_layer_bounds), child_id); 129 gfx::Rect(quad_state->quad_layer_bounds), child_id);
130 130
131 std::unique_ptr<cc::DelegatedFrameData> delegated_frame( 131 std::unique_ptr<cc::DelegatedFrameData> delegated_frame(
132 new cc::DelegatedFrameData); 132 new cc::DelegatedFrameData);
133 delegated_frame->render_pass_list.push_back(std::move(render_pass)); 133 delegated_frame->render_pass_list.push_back(std::move(render_pass));
134 cc::CompositorFrame frame; 134 cc::CompositorFrame frame;
135 frame.delegated_frame_data = std::move(delegated_frame); 135 frame.delegated_frame_data = std::move(delegated_frame);
136 frame.metadata.referenced_surfaces = child_ids_; 136 frame.metadata.referenced_surfaces = child_ids_;
137 137
138 if (root_id_.is_null()) { 138 if (!root_id_.is_valid()) {
139 root_id_ = surface_id_allocator_->GenerateId(); 139 root_id_ = surface_id_allocator_->GenerateId();
140 surface_factory_->Create(root_id_); 140 surface_factory_->Create(root_id_);
141 display_->SetSurfaceId(cc::SurfaceId(frame_sink_id_, root_id_), 1.f); 141 display_->SetSurfaceId(cc::SurfaceId(frame_sink_id_, root_id_), 1.f);
142 } 142 }
143 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame), 143 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame),
144 cc::SurfaceFactory::DrawCallback()); 144 cc::SurfaceFactory::DrawCallback());
145 145
146 display_->Resize(viewport); 146 display_->Resize(viewport);
147 display_->DrawAndSwap(); 147 display_->DrawAndSwap();
148 } 148 }
149 149
150 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) { 150 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) {
151 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) == 151 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) ==
152 child_ids_.end()); 152 child_ids_.end());
153 child_ids_.push_back(child_id); 153 child_ids_.push_back(child_id);
154 if (!root_id_.is_null()) 154 if (root_id_.is_valid())
155 SetEmptyRootFrame(); 155 SetEmptyRootFrame();
156 } 156 }
157 157
158 void SurfacesInstance::RemoveChildId(const cc::SurfaceId& child_id) { 158 void SurfacesInstance::RemoveChildId(const cc::SurfaceId& child_id) {
159 auto itr = std::find(child_ids_.begin(), child_ids_.end(), child_id); 159 auto itr = std::find(child_ids_.begin(), child_ids_.end(), child_id);
160 DCHECK(itr != child_ids_.end()); 160 DCHECK(itr != child_ids_.end());
161 child_ids_.erase(itr); 161 child_ids_.erase(itr);
162 if (!root_id_.is_null()) 162 if (root_id_.is_valid())
163 SetEmptyRootFrame(); 163 SetEmptyRootFrame();
164 } 164 }
165 165
166 void SurfacesInstance::SetEmptyRootFrame() { 166 void SurfacesInstance::SetEmptyRootFrame() {
167 cc::CompositorFrame empty_frame; 167 cc::CompositorFrame empty_frame;
168 empty_frame.delegated_frame_data = 168 empty_frame.delegated_frame_data =
169 base::WrapUnique(new cc::DelegatedFrameData); 169 base::WrapUnique(new cc::DelegatedFrameData);
170 empty_frame.metadata.referenced_surfaces = child_ids_; 170 empty_frame.metadata.referenced_surfaces = child_ids_;
171 surface_factory_->SubmitCompositorFrame(root_id_, std::move(empty_frame), 171 surface_factory_->SubmitCompositorFrame(root_id_, std::move(empty_frame),
172 cc::SurfaceFactory::DrawCallback()); 172 cc::SurfaceFactory::DrawCallback());
173 } 173 }
174 174
175 void SurfacesInstance::ReturnResources( 175 void SurfacesInstance::ReturnResources(
176 const cc::ReturnedResourceArray& resources) { 176 const cc::ReturnedResourceArray& resources) {
177 // Root surface should have no resources to return. 177 // Root surface should have no resources to return.
178 CHECK(resources.empty()); 178 CHECK(resources.empty());
179 } 179 }
180 180
181 void SurfacesInstance::SetBeginFrameSource( 181 void SurfacesInstance::SetBeginFrameSource(
182 cc::BeginFrameSource* begin_frame_source) { 182 cc::BeginFrameSource* begin_frame_source) {
183 // Parent compsitor calls DrawAndSwap directly and doesn't use 183 // Parent compsitor calls DrawAndSwap directly and doesn't use
184 // BeginFrameSource. 184 // BeginFrameSource.
185 } 185 }
186 186
187 } // namespace android_webview 187 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698