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

Side by Side Diff: cc/layers/heads_up_display_layer_impl.cc

Issue 2961633002: cc: HUD handle context lost in Gpu raster.
Patch Set: update Created 3 years, 5 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/heads_up_display_layer_impl.h" 5 #include "cc/layers/heads_up_display_layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 current_upper_bound += (target_upper_bound - current_upper_bound) * 0.5; 70 current_upper_bound += (target_upper_bound - current_upper_bound) * 0.5;
71 return current_upper_bound; 71 return current_upper_bound;
72 } 72 }
73 73
74 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, 74 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl,
75 int id) 75 int id)
76 : LayerImpl(tree_impl, id), 76 : LayerImpl(tree_impl, id),
77 internal_contents_scale_(1.f), 77 internal_contents_scale_(1.f),
78 fps_graph_(60.0, 80.0), 78 fps_graph_(60.0, 80.0),
79 paint_time_graph_(16.0, 48.0), 79 paint_time_graph_(16.0, 48.0),
80 fade_step_(0) { 80 fade_step_(0) {}
81 }
82 81
83 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() {} 82 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() {}
84 83
85 std::unique_ptr<LayerImpl> HeadsUpDisplayLayerImpl::CreateLayerImpl( 84 std::unique_ptr<LayerImpl> HeadsUpDisplayLayerImpl::CreateLayerImpl(
86 LayerTreeImpl* tree_impl) { 85 LayerTreeImpl* tree_impl) {
87 return HeadsUpDisplayLayerImpl::Create(tree_impl, id()); 86 return HeadsUpDisplayLayerImpl::Create(tree_impl, id());
88 } 87 }
89 88
90 void HeadsUpDisplayLayerImpl::AcquireResource( 89 void HeadsUpDisplayLayerImpl::AcquireResource(
91 ResourceProvider* resource_provider) { 90 ResourceProvider* resource_provider) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 bool nearest_neighbor = false; 150 bool nearest_neighbor = false;
152 TextureDrawQuad* quad = 151 TextureDrawQuad* quad =
153 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 152 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
154 quad->SetNew(shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, 153 quad->SetNew(shared_quad_state, quad_rect, opaque_rect, visible_quad_rect,
155 resources_.back()->id(), premultiplied_alpha, uv_top_left, 154 resources_.back()->id(), premultiplied_alpha, uv_top_left,
156 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, flipped, 155 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, flipped,
157 nearest_neighbor, false); 156 nearest_neighbor, false);
158 ValidateQuadResources(quad); 157 ValidateQuadResources(quad);
159 } 158 }
160 159
161 void HeadsUpDisplayLayerImpl::UpdateHudTexture( 160 uint32_t HeadsUpDisplayLayerImpl::UpdateHudTexture(
vmpstr 2017/06/30 23:16:51 The actual return type is ResourceId (even though
sohan 2017/07/04 16:51:13 Done.
162 DrawMode draw_mode, 161 DrawMode draw_mode,
163 ResourceProvider* resource_provider, 162 ResourceProvider* resource_provider,
164 ContextProvider* context_provider) { 163 ContextProvider* context_provider) {
165 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE || !resources_.back()->id()) 164 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE || !resources_.back()->id())
166 return; 165 return 0U;
167 166
168 if (context_provider) { 167 if (context_provider) {
169 gpu::gles2::GLES2Interface* gl = context_provider->ContextGL(); 168 gpu::gles2::GLES2Interface* gl = context_provider->ContextGL();
170 DCHECK(gl); 169 DCHECK(gl);
171 ScopedGpuRaster gpu_raster(context_provider); 170 ScopedGpuRaster gpu_raster(context_provider);
172 bool using_worker_context = false; 171 bool using_worker_context = false;
173 ResourceProvider::ScopedWriteLockGL lock( 172 ResourceProvider::ScopedWriteLockGL lock(
174 resource_provider, resources_.back()->id(), using_worker_context); 173 resource_provider, resources_.back()->id(), using_worker_context);
175 174
176 TRACE_EVENT_BEGIN0("cc", "CreateHudCanvas"); 175 TRACE_EVENT_BEGIN0("cc", "CreateHudCanvas");
177 bool use_distance_field_text = false; 176 bool use_distance_field_text = false;
178 bool can_use_lcd_text = false; 177 bool can_use_lcd_text = false;
179 int msaa_sample_count = 0; 178 int msaa_sample_count = 0;
180 ResourceProvider::ScopedSkSurfaceProvider scoped_surface( 179 ResourceProvider::ScopedSkSurfaceProvider scoped_surface(
181 context_provider, &lock, using_worker_context, use_distance_field_text, 180 context_provider, &lock, using_worker_context, use_distance_field_text,
182 can_use_lcd_text, msaa_sample_count); 181 can_use_lcd_text, msaa_sample_count);
182 if (!scoped_surface.sk_surface())
183 return resources_.back()->id();
vmpstr 2017/06/30 23:16:51 Should we be somehow cleaning up resources_ if thi
sohan 2017/07/04 16:51:12 Hmm. we are in ScopedWriteLockGL scope here, so if
183 SkCanvas* gpu_raster_canvas = scoped_surface.sk_surface()->getCanvas(); 184 SkCanvas* gpu_raster_canvas = scoped_surface.sk_surface()->getCanvas();
184 TRACE_EVENT_END0("cc", "CreateHudCanvas"); 185 TRACE_EVENT_END0("cc", "CreateHudCanvas");
185 186
186 UpdateHudContents(); 187 UpdateHudContents();
187 188
188 DrawHudContents(gpu_raster_canvas); 189 DrawHudContents(gpu_raster_canvas);
189 190
190 TRACE_EVENT_BEGIN0("cc", "UploadHudTexture"); 191 TRACE_EVENT_BEGIN0("cc", "UploadHudTexture");
191 const uint64_t fence = gl->InsertFenceSyncCHROMIUM(); 192 const uint64_t fence = gl->InsertFenceSyncCHROMIUM();
192 gl->OrderingBarrierCHROMIUM(); 193 gl->OrderingBarrierCHROMIUM();
(...skipping 25 matching lines...) Expand all
218 TRACE_EVENT0("cc", "UploadHudTexture"); 219 TRACE_EVENT0("cc", "UploadHudTexture");
219 SkPixmap pixmap; 220 SkPixmap pixmap;
220 hud_surface_->peekPixels(&pixmap); 221 hud_surface_->peekPixels(&pixmap);
221 DCHECK(pixmap.addr()); 222 DCHECK(pixmap.addr());
222 DCHECK(pixmap.info().colorType() == kN32_SkColorType); 223 DCHECK(pixmap.info().colorType() == kN32_SkColorType);
223 resource_provider->CopyToResource( 224 resource_provider->CopyToResource(
224 resources_.back()->id(), static_cast<const uint8_t*>(pixmap.addr()), 225 resources_.back()->id(), static_cast<const uint8_t*>(pixmap.addr()),
225 internal_content_bounds_); 226 internal_content_bounds_);
226 resource_provider->GenerateSyncTokenForResource(resources_.back()->id()); 227 resource_provider->GenerateSyncTokenForResource(resources_.back()->id());
227 } 228 }
229
230 return 0U;
228 } 231 }
229 232
230 void HeadsUpDisplayLayerImpl::ReleaseResources() { 233 void HeadsUpDisplayLayerImpl::ReleaseResources() {
231 resources_.clear(); 234 resources_.clear();
232 } 235 }
233 236
234 gfx::Rect HeadsUpDisplayLayerImpl::GetEnclosingRectInTargetSpace() const { 237 gfx::Rect HeadsUpDisplayLayerImpl::GetEnclosingRectInTargetSpace() const {
235 DCHECK_GT(internal_contents_scale_, 0.f); 238 DCHECK_GT(internal_contents_scale_, 0.f);
236 return GetScaledEnclosingRectInTargetSpace(internal_contents_scale_); 239 return GetScaledEnclosingRectInTargetSpace(internal_contents_scale_);
237 } 240 }
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 return "cc::HeadsUpDisplayLayerImpl"; 828 return "cc::HeadsUpDisplayLayerImpl";
826 } 829 }
827 830
828 void HeadsUpDisplayLayerImpl::AsValueInto( 831 void HeadsUpDisplayLayerImpl::AsValueInto(
829 base::trace_event::TracedValue* dict) const { 832 base::trace_event::TracedValue* dict) const {
830 LayerImpl::AsValueInto(dict); 833 LayerImpl::AsValueInto(dict);
831 dict->SetString("layer_name", "Heads Up Display Layer"); 834 dict->SetString("layer_name", "Heads Up Display Layer");
832 } 835 }
833 836
834 } // namespace cc 837 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698