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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCHeadsUpDisplayLayerImpl.h" | 7 #include "CCHeadsUpDisplayLayerImpl.h" |
8 | 8 |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 if (canvasSize.fWidth != bounds().width() || canvasSize.fHeight != bounds().
height() || !m_hudCanvas) | 98 if (canvasSize.fWidth != bounds().width() || canvasSize.fHeight != bounds().
height() || !m_hudCanvas) |
99 m_hudCanvas = make_scoped_ptr(skia::CreateBitmapCanvas(bounds().width(),
bounds().height(), false /* opaque */)); | 99 m_hudCanvas = make_scoped_ptr(skia::CreateBitmapCanvas(bounds().width(),
bounds().height(), false /* opaque */)); |
100 | 100 |
101 m_hudCanvas->clear(SkColorSetARGB(0, 0, 0, 0)); | 101 m_hudCanvas->clear(SkColorSetARGB(0, 0, 0, 0)); |
102 drawHudContents(m_hudCanvas.get()); | 102 drawHudContents(m_hudCanvas.get()); |
103 | 103 |
104 const SkBitmap* bitmap = &m_hudCanvas->getDevice()->accessBitmap(false); | 104 const SkBitmap* bitmap = &m_hudCanvas->getDevice()->accessBitmap(false); |
105 SkAutoLockPixels locker(*bitmap); | 105 SkAutoLockPixels locker(*bitmap); |
106 | 106 |
107 IntRect layerRect(IntPoint(), bounds()); | 107 IntRect layerRect(IntPoint(), bounds()); |
108 ASSERT(bitmap->config() == SkBitmap::kARGB_8888_Config); | 108 DCHECK(bitmap->config() == SkBitmap::kARGB_8888_Config); |
109 resourceProvider->upload(m_hudTexture->id(), static_cast<const uint8_t*>(bit
map->getPixels()), layerRect, layerRect, IntSize()); | 109 resourceProvider->upload(m_hudTexture->id(), static_cast<const uint8_t*>(bit
map->getPixels()), layerRect, layerRect, IntSize()); |
110 } | 110 } |
111 | 111 |
112 void CCHeadsUpDisplayLayerImpl::didDraw(CCResourceProvider* resourceProvider) | 112 void CCHeadsUpDisplayLayerImpl::didDraw(CCResourceProvider* resourceProvider) |
113 { | 113 { |
114 CCLayerImpl::didDraw(resourceProvider); | 114 CCLayerImpl::didDraw(resourceProvider); |
115 | 115 |
116 if (!m_hudTexture->id()) | 116 if (!m_hudTexture->id()) |
117 return; | 117 return; |
118 | 118 |
119 // FIXME: the following assert will not be true when sending resources to a | 119 // FIXME: the following assert will not be true when sending resources to a |
120 // parent compositor. We will probably need to hold on to m_hudTexture for | 120 // parent compositor. We will probably need to hold on to m_hudTexture for |
121 // longer, and have several HUD textures in the pipeline. | 121 // longer, and have several HUD textures in the pipeline. |
122 ASSERT(!resourceProvider->inUseByConsumer(m_hudTexture->id())); | 122 DCHECK(!resourceProvider->inUseByConsumer(m_hudTexture->id())); |
123 } | 123 } |
124 | 124 |
125 void CCHeadsUpDisplayLayerImpl::didLoseContext() | 125 void CCHeadsUpDisplayLayerImpl::didLoseContext() |
126 { | 126 { |
127 m_hudTexture.reset(); | 127 m_hudTexture.reset(); |
128 } | 128 } |
129 | 129 |
130 bool CCHeadsUpDisplayLayerImpl::layerIsAlwaysDamaged() const | 130 bool CCHeadsUpDisplayLayerImpl::layerIsAlwaysDamaged() const |
131 { | 131 { |
132 return true; | 132 return true; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 canvas->drawRect(skRect, paint); | 287 canvas->drawRect(skRect, paint); |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 const char* CCHeadsUpDisplayLayerImpl::layerTypeAsString() const | 291 const char* CCHeadsUpDisplayLayerImpl::layerTypeAsString() const |
292 { | 292 { |
293 return "HeadsUpDisplayLayer"; | 293 return "HeadsUpDisplayLayer"; |
294 } | 294 } |
295 | 295 |
296 } | 296 } |
OLD | NEW |