OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 nearest_neighbor); | 172 nearest_neighbor); |
173 } | 173 } |
174 | 174 |
175 void HeadsUpDisplayLayerImpl::UpdateHudTexture( | 175 void HeadsUpDisplayLayerImpl::UpdateHudTexture( |
176 DrawMode draw_mode, | 176 DrawMode draw_mode, |
177 ResourceProvider* resource_provider) { | 177 ResourceProvider* resource_provider) { |
178 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE || !resources_.back()->id()) | 178 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE || !resources_.back()->id()) |
179 return; | 179 return; |
180 | 180 |
181 SkISize canvas_size; | 181 SkISize canvas_size; |
182 if (hud_canvas_) | 182 if (hud_surface_) |
183 canvas_size = hud_canvas_->getDeviceSize(); | 183 canvas_size = hud_surface_->getCanvas()->getDeviceSize(); |
184 else | 184 else |
185 canvas_size.set(0, 0); | 185 canvas_size.set(0, 0); |
186 | 186 |
187 if (canvas_size.width() != internal_content_bounds_.width() || | 187 if (canvas_size.width() != internal_content_bounds_.width() || |
188 canvas_size.height() != internal_content_bounds_.height() || | 188 canvas_size.height() != internal_content_bounds_.height() || |
189 !hud_canvas_) { | 189 !hud_surface_) { |
190 TRACE_EVENT0("cc", "ResizeHudCanvas"); | 190 TRACE_EVENT0("cc", "ResizeHudCanvas"); |
191 | 191 |
192 bool opaque = false; | 192 hud_surface_ = skia::AdoptRef(SkSurface::NewRasterN32Premul( |
193 hud_canvas_ = make_scoped_ptr( | 193 internal_content_bounds_.width(), internal_content_bounds_.height())); |
194 skia::CreateBitmapCanvas(internal_content_bounds_.width(), | |
195 internal_content_bounds_.height(), opaque)); | |
196 } | 194 } |
197 | 195 |
198 UpdateHudContents(); | 196 UpdateHudContents(); |
199 | 197 |
200 { | 198 { |
201 TRACE_EVENT0("cc", "DrawHudContents"); | 199 TRACE_EVENT0("cc", "DrawHudContents"); |
202 hud_canvas_->clear(SkColorSetARGB(0, 0, 0, 0)); | 200 hud_surface_->getCanvas()->clear(SkColorSetARGB(0, 0, 0, 0)); |
203 hud_canvas_->save(); | 201 hud_surface_->getCanvas()->save(); |
204 hud_canvas_->scale(internal_contents_scale_, internal_contents_scale_); | 202 hud_surface_->getCanvas()->scale(internal_contents_scale_, |
| 203 internal_contents_scale_); |
205 | 204 |
206 DrawHudContents(hud_canvas_.get()); | 205 DrawHudContents(hud_surface_->getCanvas()); |
207 | 206 |
208 hud_canvas_->restore(); | 207 hud_surface_->getCanvas()->restore(); |
209 } | 208 } |
210 | 209 |
211 TRACE_EVENT0("cc", "UploadHudTexture"); | 210 TRACE_EVENT0("cc", "UploadHudTexture"); |
212 SkImageInfo info; | 211 SkImageInfo info; |
213 size_t row_bytes = 0; | 212 size_t row_bytes = 0; |
214 const void* pixels = hud_canvas_->peekPixels(&info, &row_bytes); | 213 const void* pixels = hud_surface_->getCanvas()->peekPixels(&info, &row_bytes); |
215 DCHECK(pixels); | 214 DCHECK(pixels); |
216 DCHECK(info.colorType() == kN32_SkColorType); | 215 DCHECK(info.colorType() == kN32_SkColorType); |
217 resource_provider->CopyToResource(resources_.back()->id(), | 216 resource_provider->CopyToResource(resources_.back()->id(), |
218 static_cast<const uint8_t*>(pixels), | 217 static_cast<const uint8_t*>(pixels), |
219 internal_content_bounds_); | 218 internal_content_bounds_); |
220 } | 219 } |
221 | 220 |
222 void HeadsUpDisplayLayerImpl::ReleaseResources() { | 221 void HeadsUpDisplayLayerImpl::ReleaseResources() { |
223 resources_.clear(); | 222 resources_.clear(); |
224 } | 223 } |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 return "cc::HeadsUpDisplayLayerImpl"; | 834 return "cc::HeadsUpDisplayLayerImpl"; |
836 } | 835 } |
837 | 836 |
838 void HeadsUpDisplayLayerImpl::AsValueInto( | 837 void HeadsUpDisplayLayerImpl::AsValueInto( |
839 base::trace_event::TracedValue* dict) const { | 838 base::trace_event::TracedValue* dict) const { |
840 LayerImpl::AsValueInto(dict); | 839 LayerImpl::AsValueInto(dict); |
841 dict->SetString("layer_name", "Heads Up Display Layer"); | 840 dict->SetString("layer_name", "Heads Up Display Layer"); |
842 } | 841 } |
843 | 842 |
844 } // namespace cc | 843 } // namespace cc |
OLD | NEW |