| 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 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/bitmap_canvas_layer_updater.h" | 7 #include "cc/bitmap_canvas_layer_updater.h" |
| 8 | 8 |
| 9 #include "cc/layer_painter.h" | 9 #include "cc/layer_painter.h" |
| 10 #include "cc/rendering_stats.h" |
| 10 #include "cc/resource_update.h" | 11 #include "cc/resource_update.h" |
| 11 #include "cc/texture_update_queue.h" | 12 #include "cc/texture_update_queue.h" |
| 12 #include "skia/ext/platform_canvas.h" | 13 #include "skia/ext/platform_canvas.h" |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 | 16 |
| 16 BitmapCanvasLayerUpdater::Texture::Texture(BitmapCanvasLayerUpdater* updater, sc
oped_ptr<PrioritizedTexture> texture) | 17 BitmapCanvasLayerUpdater::Texture::Texture(BitmapCanvasLayerUpdater* updater, sc
oped_ptr<PrioritizedTexture> texture) |
| 17 : LayerUpdater::Texture(texture.Pass()) | 18 : LayerUpdater::Texture(texture.Pass()) |
| 18 , m_updater(updater) | 19 , m_updater(updater) |
| 19 { | 20 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 48 return scoped_ptr<LayerUpdater::Texture>(new Texture(this, PrioritizedTextur
e::create(manager))); | 49 return scoped_ptr<LayerUpdater::Texture>(new Texture(this, PrioritizedTextur
e::create(manager))); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void BitmapCanvasLayerUpdater::prepareToUpdate(const IntRect& contentRect, const
IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect
& resultingOpaqueRect, RenderingStats& stats) | 52 void BitmapCanvasLayerUpdater::prepareToUpdate(const IntRect& contentRect, const
IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect
& resultingOpaqueRect, RenderingStats& stats) |
| 52 { | 53 { |
| 53 if (m_canvasSize != contentRect.size()) { | 54 if (m_canvasSize != contentRect.size()) { |
| 54 m_canvasSize = contentRect.size(); | 55 m_canvasSize = contentRect.size(); |
| 55 m_canvas = make_scoped_ptr(skia::CreateBitmapCanvas(m_canvasSize.width()
, m_canvasSize.height(), m_opaque)); | 56 m_canvas = make_scoped_ptr(skia::CreateBitmapCanvas(m_canvasSize.width()
, m_canvasSize.height(), m_opaque)); |
| 56 } | 57 } |
| 57 | 58 |
| 59 stats.totalPixelsRasterized += contentRect.width() * contentRect.height(); |
| 60 |
| 58 paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeigh
tScale, resultingOpaqueRect, stats); | 61 paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeigh
tScale, resultingOpaqueRect, stats); |
| 59 } | 62 } |
| 60 | 63 |
| 61 void BitmapCanvasLayerUpdater::updateTexture(TextureUpdateQueue& queue, Prioriti
zedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool
partialUpdate) | 64 void BitmapCanvasLayerUpdater::updateTexture(TextureUpdateQueue& queue, Prioriti
zedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool
partialUpdate) |
| 62 { | 65 { |
| 63 ResourceUpdate upload = ResourceUpdate::Create( | 66 ResourceUpdate upload = ResourceUpdate::Create( |
| 64 texture, | 67 texture, |
| 65 &m_canvas->getDevice()->accessBitmap(false), | 68 &m_canvas->getDevice()->accessBitmap(false), |
| 66 contentRect(), | 69 contentRect(), |
| 67 sourceRect, | 70 sourceRect, |
| 68 destOffset); | 71 destOffset); |
| 69 if (partialUpdate) | 72 if (partialUpdate) |
| 70 queue.appendPartialUpload(upload); | 73 queue.appendPartialUpload(upload); |
| 71 else | 74 else |
| 72 queue.appendFullUpload(upload); | 75 queue.appendFullUpload(upload); |
| 73 } | 76 } |
| 74 | 77 |
| 75 void BitmapCanvasLayerUpdater::setOpaque(bool opaque) | 78 void BitmapCanvasLayerUpdater::setOpaque(bool opaque) |
| 76 { | 79 { |
| 77 if (opaque != m_opaque) { | 80 if (opaque != m_opaque) { |
| 78 m_canvas.reset(); | 81 m_canvas.reset(); |
| 79 m_canvasSize = IntSize(); | 82 m_canvasSize = IntSize(); |
| 80 } | 83 } |
| 81 m_opaque = opaque; | 84 m_opaque = opaque; |
| 82 } | 85 } |
| 83 | 86 |
| 84 } // namespace cc | 87 } // namespace cc |
| OLD | NEW |