OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 m_hudTexture = CCScopedTexture::create(resourceProvider); | 65 m_hudTexture = CCScopedTexture::create(resourceProvider); |
66 | 66 |
67 // FIXME: Scale the HUD by deviceScale to make it more friendly under high D
PI. | 67 // FIXME: Scale the HUD by deviceScale to make it more friendly under high D
PI. |
68 | 68 |
69 if (m_hudTexture->size() != bounds()) | 69 if (m_hudTexture->size() != bounds()) |
70 m_hudTexture->free(); | 70 m_hudTexture->free(); |
71 | 71 |
72 if (!m_hudTexture->id() && !m_hudTexture->allocate(CCRenderer::ImplPool, bou
nds(), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny)) | 72 if (!m_hudTexture->id() && !m_hudTexture->allocate(CCRenderer::ImplPool, bou
nds(), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny)) |
73 return; | 73 return; |
74 | 74 |
75 // Render pixels into the texture. | 75 SkISize canvasSize; |
76 OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(bounds().width()
, bounds().height(), false /* opaque */)); | 76 if (m_hudCanvas) |
77 drawHudContents(canvas.get()); | 77 canvasSize = m_hudCanvas->getDeviceSize(); |
| 78 else |
| 79 canvasSize.set(0, 0); |
78 | 80 |
79 const SkBitmap* bitmap = &canvas->getDevice()->accessBitmap(false); | 81 if (canvasSize.fWidth != bounds().width() || canvasSize.fHeight != bounds().
height() || !m_hudCanvas) |
| 82 m_hudCanvas = adoptPtr(skia::CreateBitmapCanvas(bounds().width(), bounds
().height(), false /* opaque */)); |
| 83 |
| 84 m_hudCanvas->clear(SkColorSetARGB(0, 0, 0, 0)); |
| 85 drawHudContents(m_hudCanvas.get()); |
| 86 |
| 87 const SkBitmap* bitmap = &m_hudCanvas->getDevice()->accessBitmap(false); |
80 SkAutoLockPixels locker(*bitmap); | 88 SkAutoLockPixels locker(*bitmap); |
81 | 89 |
82 IntRect layerRect(IntPoint(), bounds()); | 90 IntRect layerRect(IntPoint(), bounds()); |
83 ASSERT(bitmap->config() == SkBitmap::kARGB_8888_Config); | 91 ASSERT(bitmap->config() == SkBitmap::kARGB_8888_Config); |
84 resourceProvider->upload(m_hudTexture->id(), static_cast<const uint8_t*>(bit
map->getPixels()), layerRect, layerRect, layerRect); | 92 resourceProvider->upload(m_hudTexture->id(), static_cast<const uint8_t*>(bit
map->getPixels()), layerRect, layerRect, layerRect); |
85 } | 93 } |
86 | 94 |
87 void CCHeadsUpDisplayLayerImpl::appendQuads(CCQuadSink& quadList, const CCShared
QuadState* sharedQuadState, bool&) | 95 void CCHeadsUpDisplayLayerImpl::appendQuads(CCQuadSink& quadList, const CCShared
QuadState* sharedQuadState, bool&) |
88 { | 96 { |
89 if (!m_hudTexture->id()) | 97 if (!m_hudTexture->id()) |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 canvas->drawRect(skRect, paint); | 272 canvas->drawRect(skRect, paint); |
265 | 273 |
266 paint.setColor(strokeColor); | 274 paint.setColor(strokeColor); |
267 paint.setStyle(SkPaint::kStroke_Style); | 275 paint.setStyle(SkPaint::kStroke_Style); |
268 paint.setStrokeWidth(2); | 276 paint.setStrokeWidth(2); |
269 canvas->drawRect(skRect, paint); | 277 canvas->drawRect(skRect, paint); |
270 } | 278 } |
271 } | 279 } |
272 | 280 |
273 } | 281 } |
OLD | NEW |