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/heads_up_display_layer_impl.h" | 5 #include "cc/heads_up_display_layer_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "cc/debug_colors.h" | 10 #include "cc/debug_colors.h" |
11 #include "cc/debug_rect_history.h" | 11 #include "cc/debug_rect_history.h" |
12 #include "cc/font_atlas.h" | 12 #include "cc/font_atlas.h" |
13 #include "cc/frame_rate_counter.h" | 13 #include "cc/frame_rate_counter.h" |
14 #include "cc/layer_tree_host_impl.h" | 14 #include "cc/layer_tree_impl.h" |
15 #include "cc/quad_sink.h" | 15 #include "cc/quad_sink.h" |
| 16 #include "cc/renderer.h" |
16 #include "cc/texture_draw_quad.h" | 17 #include "cc/texture_draw_quad.h" |
17 #include "skia/ext/platform_canvas.h" | 18 #include "skia/ext/platform_canvas.h" |
18 #include "skia/ext/platform_canvas.h" | 19 #include "skia/ext/platform_canvas.h" |
19 #include "third_party/khronos/GLES2/gl2.h" | 20 #include "third_party/khronos/GLES2/gl2.h" |
20 #include "third_party/khronos/GLES2/gl2ext.h" | 21 #include "third_party/khronos/GLES2/gl2ext.h" |
21 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
22 #include "third_party/skia/include/core/SkPaint.h" | 23 #include "third_party/skia/include/core/SkPaint.h" |
23 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" | 24 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" |
24 #include "ui/gfx/point.h" | 25 #include "ui/gfx/point.h" |
25 #include "ui/gfx/size.h" | 26 #include "ui/gfx/size.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 m_hudTexture.reset(); | 140 m_hudTexture.reset(); |
140 } | 141 } |
141 | 142 |
142 bool HeadsUpDisplayLayerImpl::layerIsAlwaysDamaged() const | 143 bool HeadsUpDisplayLayerImpl::layerIsAlwaysDamaged() const |
143 { | 144 { |
144 return true; | 145 return true; |
145 } | 146 } |
146 | 147 |
147 void HeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas) | 148 void HeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas) |
148 { | 149 { |
149 const LayerTreeDebugState& debugState = layerTreeHostImpl()->debugState(); | 150 const LayerTreeDebugState& debugState = layerTreeImpl()->debug_state(); |
150 | 151 |
151 if (debugState.showPlatformLayerTree) { | 152 if (debugState.showPlatformLayerTree) { |
152 SkPaint paint = createPaint(); | 153 SkPaint paint = createPaint(); |
153 paint.setColor(SkColorSetARGB(192, 0, 0, 0)); | 154 paint.setColor(SkColorSetARGB(192, 0, 0, 0)); |
154 canvas->drawRect(SkRect::MakeXYWH(0, 0, bounds().width(), bounds().heigh
t()), paint); | 155 canvas->drawRect(SkRect::MakeXYWH(0, 0, bounds().width(), bounds().heigh
t()), paint); |
155 } | 156 } |
156 | 157 |
157 int platformLayerTreeTop = 0; | 158 int platformLayerTreeTop = 0; |
158 | 159 |
159 if (debugState.showFPSCounter) | 160 if (debugState.showFPSCounter) |
160 platformLayerTreeTop = drawFPSCounter(canvas, layerTreeHostImpl()->fpsCo
unter()); | 161 platformLayerTreeTop = drawFPSCounter(canvas, layerTreeImpl()->frame_rat
e_counter()); |
161 | 162 |
162 if (debugState.showPlatformLayerTree && m_fontAtlas) { | 163 if (debugState.showPlatformLayerTree && m_fontAtlas) { |
163 std::string layerTree = layerTreeHostImpl()->layerTreeAsText(); | 164 std::string layerTree = layerTreeImpl()->layer_tree_as_text(); |
164 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl
atformLayerTreeTop), bounds()); | 165 m_fontAtlas->drawText(canvas, createPaint(), layerTree, gfx::Point(2, pl
atformLayerTreeTop), bounds()); |
165 } | 166 } |
166 | 167 |
167 if (debugState.showHudRects()) | 168 if (debugState.showHudRects()) |
168 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); | 169 drawDebugRects(canvas, layerTreeImpl()->debug_rect_history()); |
169 } | 170 } |
170 | 171 |
171 int HeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, FrameRateCounter*
fpsCounter) | 172 int HeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, FrameRateCounter*
fpsCounter) |
172 { | 173 { |
173 const int padding = 4; | 174 const int padding = 4; |
174 const int gap = 6; | 175 const int gap = 6; |
175 | 176 |
176 const int fontHeight = m_fontAtlas.get() ? m_fontAtlas->fontHeight() : 0; | 177 const int fontHeight = m_fontAtlas.get() ? m_fontAtlas->fontHeight() : 0; |
177 | 178 |
178 const int graphWidth = fpsCounter->timeStampHistorySize() - 3; | 179 const int graphWidth = fpsCounter->timeStampHistorySize() - 3; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 paint.setAntiAlias(true); | 306 paint.setAntiAlias(true); |
306 paint.setStyle(SkPaint::kStroke_Style); | 307 paint.setStyle(SkPaint::kStroke_Style); |
307 paint.setStrokeWidth(1); | 308 paint.setStrokeWidth(1); |
308 | 309 |
309 canvas->drawPath(path, paint); | 310 canvas->drawPath(path, paint); |
310 } | 311 } |
311 | 312 |
312 void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory*
debugRectHistory) | 313 void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory*
debugRectHistory) |
313 { | 314 { |
314 const std::vector<DebugRect>& debugRects = debugRectHistory->debugRects(); | 315 const std::vector<DebugRect>& debugRects = debugRectHistory->debugRects(); |
315 float rectScale = 1 / layerTreeHostImpl()->deviceScaleFactor(); | 316 float rectScale = 1 / layerTreeImpl()->device_scale_factor(); |
316 | 317 |
317 canvas->save(); | 318 canvas->save(); |
318 canvas->scale(rectScale, rectScale); | 319 canvas->scale(rectScale, rectScale); |
319 | 320 |
320 for (size_t i = 0; i < debugRects.size(); ++i) { | 321 for (size_t i = 0; i < debugRects.size(); ++i) { |
321 SkColor strokeColor = 0; | 322 SkColor strokeColor = 0; |
322 SkColor fillColor = 0; | 323 SkColor fillColor = 0; |
323 float strokeWidth = 0; | 324 float strokeWidth = 0; |
324 | 325 |
325 switch (debugRects[i].type) { | 326 switch (debugRects[i].type) { |
326 case PaintRectType: | 327 case PaintRectType: |
327 strokeColor = DebugColors::PaintRectBorderColor(); | 328 strokeColor = DebugColors::PaintRectBorderColor(); |
328 fillColor = DebugColors::PaintRectFillColor(); | 329 fillColor = DebugColors::PaintRectFillColor(); |
329 strokeWidth = DebugColors::PaintRectBorderWidth(layerTreeHostImpl())
; | 330 strokeWidth = DebugColors::PaintRectBorderWidth(layerTreeImpl()); |
330 break; | 331 break; |
331 case PropertyChangedRectType: | 332 case PropertyChangedRectType: |
332 strokeColor = DebugColors::PropertyChangedRectBorderColor(); | 333 strokeColor = DebugColors::PropertyChangedRectBorderColor(); |
333 fillColor = DebugColors::PropertyChangedRectFillColor(); | 334 fillColor = DebugColors::PropertyChangedRectFillColor(); |
334 strokeWidth = DebugColors::PropertyChangedRectBorderWidth(layerTreeH
ostImpl()); | 335 strokeWidth = DebugColors::PropertyChangedRectBorderWidth(layerTreeI
mpl()); |
335 break; | 336 break; |
336 case SurfaceDamageRectType: | 337 case SurfaceDamageRectType: |
337 strokeColor = DebugColors::SurfaceDamageRectBorderColor(); | 338 strokeColor = DebugColors::SurfaceDamageRectBorderColor(); |
338 fillColor = DebugColors::SurfaceDamageRectFillColor(); | 339 fillColor = DebugColors::SurfaceDamageRectFillColor(); |
339 strokeWidth = DebugColors::SurfaceDamageRectBorderWidth(layerTreeHos
tImpl()); | 340 strokeWidth = DebugColors::SurfaceDamageRectBorderWidth(layerTreeImp
l()); |
340 break; | 341 break; |
341 case ReplicaScreenSpaceRectType: | 342 case ReplicaScreenSpaceRectType: |
342 strokeColor = DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor(
); | 343 strokeColor = DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor(
); |
343 fillColor = DebugColors::ScreenSpaceSurfaceReplicaRectFillColor(); | 344 fillColor = DebugColors::ScreenSpaceSurfaceReplicaRectFillColor(); |
344 strokeWidth = DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth(
layerTreeHostImpl()); | 345 strokeWidth = DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth(
layerTreeImpl()); |
345 break; | 346 break; |
346 case ScreenSpaceRectType: | 347 case ScreenSpaceRectType: |
347 strokeColor = DebugColors::ScreenSpaceLayerRectBorderColor(); | 348 strokeColor = DebugColors::ScreenSpaceLayerRectBorderColor(); |
348 fillColor = DebugColors::ScreenSpaceLayerRectFillColor(); | 349 fillColor = DebugColors::ScreenSpaceLayerRectFillColor(); |
349 strokeWidth = DebugColors::ScreenSpaceLayerRectBorderWidth(layerTree
HostImpl()); | 350 strokeWidth = DebugColors::ScreenSpaceLayerRectBorderWidth(layerTree
Impl()); |
350 break; | 351 break; |
351 case OccludingRectType: | 352 case OccludingRectType: |
352 strokeColor = DebugColors::OccludingRectBorderColor(); | 353 strokeColor = DebugColors::OccludingRectBorderColor(); |
353 fillColor = DebugColors::OccludingRectFillColor(); | 354 fillColor = DebugColors::OccludingRectFillColor(); |
354 strokeWidth = DebugColors::OccludingRectBorderWidth(layerTreeHostImp
l()); | 355 strokeWidth = DebugColors::OccludingRectBorderWidth(layerTreeImpl())
; |
355 break; | 356 break; |
356 case NonOccludingRectType: | 357 case NonOccludingRectType: |
357 strokeColor = DebugColors::NonOccludingRectBorderColor(); | 358 strokeColor = DebugColors::NonOccludingRectBorderColor(); |
358 fillColor = DebugColors::NonOccludingRectFillColor(); | 359 fillColor = DebugColors::NonOccludingRectFillColor(); |
359 strokeWidth = DebugColors::NonOccludingRectBorderWidth(layerTreeHost
Impl()); | 360 strokeWidth = DebugColors::NonOccludingRectBorderWidth(layerTreeImpl
()); |
360 break; | 361 break; |
361 } | 362 } |
362 | 363 |
363 const gfx::RectF& rect = debugRects[i].rect; | 364 const gfx::RectF& rect = debugRects[i].rect; |
364 SkRect skRect = SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.
height()); | 365 SkRect skRect = SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.
height()); |
365 SkPaint paint = createPaint(); | 366 SkPaint paint = createPaint(); |
366 paint.setColor(fillColor); | 367 paint.setColor(fillColor); |
367 canvas->drawRect(skRect, paint); | 368 canvas->drawRect(skRect, paint); |
368 | 369 |
369 paint.setColor(strokeColor); | 370 paint.setColor(strokeColor); |
370 paint.setStyle(SkPaint::kStroke_Style); | 371 paint.setStyle(SkPaint::kStroke_Style); |
371 paint.setStrokeWidth(SkFloatToScalar(strokeWidth)); | 372 paint.setStrokeWidth(SkFloatToScalar(strokeWidth)); |
372 canvas->drawRect(skRect, paint); | 373 canvas->drawRect(skRect, paint); |
373 } | 374 } |
374 | 375 |
375 canvas->restore(); | 376 canvas->restore(); |
376 } | 377 } |
377 | 378 |
378 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const | 379 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const |
379 { | 380 { |
380 return "HeadsUpDisplayLayer"; | 381 return "HeadsUpDisplayLayer"; |
381 } | 382 } |
382 | 383 |
383 } // namespace cc | 384 } // namespace cc |
OLD | NEW |