| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 | 5 |
| 6 #include "config.h" | 6 #include "config.h" |
| 7 | 7 |
| 8 #if USE(ACCELERATED_COMPOSITING) | 8 #if USE(ACCELERATED_COMPOSITING) |
| 9 | 9 |
| 10 #include "BitmapCanvasLayerTextureUpdater.h" | 10 #include "BitmapCanvasLayerTextureUpdater.h" |
| 11 | 11 |
| 12 #include "CCRenderingStats.h" |
| 13 |
| 12 #include "LayerPainterChromium.h" | 14 #include "LayerPainterChromium.h" |
| 13 #include "PlatformColor.h" | 15 #include "PlatformColor.h" |
| 14 #include "skia/ext/platform_canvas.h" | 16 #include "skia/ext/platform_canvas.h" |
| 15 | 17 |
| 16 namespace cc { | 18 namespace cc { |
| 17 | 19 |
| 18 BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdate
r* textureUpdater, PassOwnPtr<CCPrioritizedTexture> texture) | 20 BitmapCanvasLayerTextureUpdater::Texture::Texture(BitmapCanvasLayerTextureUpdate
r* textureUpdater, PassOwnPtr<CCPrioritizedTexture> texture) |
| 19 : LayerTextureUpdater::Texture(texture) | 21 : LayerTextureUpdater::Texture(texture) |
| 20 , m_textureUpdater(textureUpdater) | 22 , m_textureUpdater(textureUpdater) |
| 21 { | 23 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::S
ampledTexelFormatBGRA; | 59 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::S
ampledTexelFormatBGRA; |
| 58 } | 60 } |
| 59 | 61 |
| 60 void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect
, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale,
IntRect& resultingOpaqueRect, CCRenderingStats& stats) | 62 void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect
, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale,
IntRect& resultingOpaqueRect, CCRenderingStats& stats) |
| 61 { | 63 { |
| 62 if (m_canvasSize != contentRect.size()) { | 64 if (m_canvasSize != contentRect.size()) { |
| 63 m_canvasSize = contentRect.size(); | 65 m_canvasSize = contentRect.size(); |
| 64 m_canvas = adoptPtr(skia::CreateBitmapCanvas(m_canvasSize.width(), m_can
vasSize.height(), m_opaque)); | 66 m_canvas = adoptPtr(skia::CreateBitmapCanvas(m_canvasSize.width(), m_can
vasSize.height(), m_opaque)); |
| 65 } | 67 } |
| 66 | 68 |
| 69 stats.totalPixelsRasterized += contentRect.width() * contentRect.height(); |
| 70 |
| 67 paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeigh
tScale, resultingOpaqueRect, stats); | 71 paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeigh
tScale, resultingOpaqueRect, stats); |
| 68 } | 72 } |
| 69 | 73 |
| 70 void BitmapCanvasLayerTextureUpdater::updateTextureRect(CCResourceProvider* reso
urceProvider, CCPrioritizedTexture* texture, const IntRect& sourceRect, const In
tSize& destOffset) | 74 void BitmapCanvasLayerTextureUpdater::updateTextureRect(CCResourceProvider* reso
urceProvider, CCPrioritizedTexture* texture, const IntRect& sourceRect, const In
tSize& destOffset) |
| 71 { | 75 { |
| 72 const SkBitmap& bitmap = m_canvas->getDevice()->accessBitmap(false); | 76 const SkBitmap& bitmap = m_canvas->getDevice()->accessBitmap(false); |
| 73 bitmap.lockPixels(); | 77 bitmap.lockPixels(); |
| 74 | 78 |
| 75 texture->upload(resourceProvider, static_cast<const uint8_t*>(bitmap.getPixe
ls()), contentRect(), sourceRect, destOffset); | 79 texture->upload(resourceProvider, static_cast<const uint8_t*>(bitmap.getPixe
ls()), contentRect(), sourceRect, destOffset); |
| 76 bitmap.unlockPixels(); | 80 bitmap.unlockPixels(); |
| 77 } | 81 } |
| 78 | 82 |
| 79 void BitmapCanvasLayerTextureUpdater::setOpaque(bool opaque) | 83 void BitmapCanvasLayerTextureUpdater::setOpaque(bool opaque) |
| 80 { | 84 { |
| 81 if (opaque != m_opaque) { | 85 if (opaque != m_opaque) { |
| 82 m_canvas.clear(); | 86 m_canvas.clear(); |
| 83 m_canvasSize = IntSize(); | 87 m_canvasSize = IntSize(); |
| 84 } | 88 } |
| 85 m_opaque = opaque; | 89 m_opaque = opaque; |
| 86 } | 90 } |
| 87 | 91 |
| 88 } // namespace cc | 92 } // namespace cc |
| 89 #endif // USE(ACCELERATED_COMPOSITING) | 93 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |