| 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_skpicture_canvas_layer_texture_updater.h" | 7 #include "cc/bitmap_skpicture_canvas_layer_texture_updater.h" |
| 8 | 8 |
| 9 #include "CCRenderingStats.h" | 9 #include "CCRenderingStats.h" |
| 10 #include "CCTextureUpdateQueue.h" | 10 #include "CCTextureUpdateQueue.h" |
| 11 #include "cc/layer_painter.h" | 11 #include "cc/layer_painter.h" |
| 12 #include "cc/platform_color.h" | 12 #include "cc/platform_color.h" |
| 13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
| 14 #include "third_party/skia/include/core/SkDevice.h" | 14 #include "third_party/skia/include/core/SkDevice.h" |
| 15 #include <wtf/CurrentTime.h> | 15 #include <wtf/CurrentTime.h> |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 BitmapSkPictureCanvasLayerTextureUpdater::Texture::Texture(BitmapSkPictureCanvas
LayerTextureUpdater* textureUpdater, scoped_ptr<CCPrioritizedTexture> texture) | 19 BitmapSkPictureCanvasLayerTextureUpdater::Texture::Texture(BitmapSkPictureCanvas
LayerTextureUpdater* textureUpdater, scoped_ptr<PrioritizedTexture> texture) |
| 20 : CanvasLayerTextureUpdater::Texture(texture.Pass()) | 20 : CanvasLayerTextureUpdater::Texture(texture.Pass()) |
| 21 , m_textureUpdater(textureUpdater) | 21 , m_textureUpdater(textureUpdater) |
| 22 { | 22 { |
| 23 } | 23 } |
| 24 | 24 |
| 25 void BitmapSkPictureCanvasLayerTextureUpdater::Texture::update(CCTextureUpdateQu
eue& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUp
date, CCRenderingStats& stats) | 25 void BitmapSkPictureCanvasLayerTextureUpdater::Texture::update(TextureUpdateQueu
e& queue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpda
te, RenderingStats& stats) |
| 26 { | 26 { |
| 27 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRe
ct.height()); | 27 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRe
ct.height()); |
| 28 m_bitmap.allocPixels(); | 28 m_bitmap.allocPixels(); |
| 29 m_bitmap.setIsOpaque(m_textureUpdater->layerIsOpaque()); | 29 m_bitmap.setIsOpaque(m_textureUpdater->layerIsOpaque()); |
| 30 SkDevice device(m_bitmap); | 30 SkDevice device(m_bitmap); |
| 31 SkCanvas canvas(&device); | 31 SkCanvas canvas(&device); |
| 32 double paintBeginTime = monotonicallyIncreasingTime(); | 32 double paintBeginTime = monotonicallyIncreasingTime(); |
| 33 textureUpdater()->paintContentsRect(&canvas, sourceRect, stats); | 33 textureUpdater()->paintContentsRect(&canvas, sourceRect, stats); |
| 34 stats.totalPaintTimeInSeconds += monotonicallyIncreasingTime() - paintBeginT
ime; | 34 stats.totalPaintTimeInSeconds += monotonicallyIncreasingTime() - paintBeginT
ime; |
| 35 | 35 |
| 36 TextureUploader::Parameters upload = { texture(), &m_bitmap, NULL, { sourceR
ect, sourceRect, destOffset } }; | 36 TextureUploader::Parameters upload = { texture(), &m_bitmap, NULL, { sourceR
ect, sourceRect, destOffset } }; |
| 37 if (partialUpdate) | 37 if (partialUpdate) |
| 38 queue.appendPartialUpload(upload); | 38 queue.appendPartialUpload(upload); |
| 39 else | 39 else |
| 40 queue.appendFullUpload(upload); | 40 queue.appendFullUpload(upload); |
| 41 } | 41 } |
| 42 | 42 |
| 43 scoped_refptr<BitmapSkPictureCanvasLayerTextureUpdater> BitmapSkPictureCanvasLay
erTextureUpdater::create(scoped_ptr<LayerPainterChromium> painter) | 43 scoped_refptr<BitmapSkPictureCanvasLayerTextureUpdater> BitmapSkPictureCanvasLay
erTextureUpdater::create(scoped_ptr<LayerPainter> painter) |
| 44 { | 44 { |
| 45 return make_scoped_refptr(new BitmapSkPictureCanvasLayerTextureUpdater(paint
er.Pass())); | 45 return make_scoped_refptr(new BitmapSkPictureCanvasLayerTextureUpdater(paint
er.Pass())); |
| 46 } | 46 } |
| 47 | 47 |
| 48 BitmapSkPictureCanvasLayerTextureUpdater::BitmapSkPictureCanvasLayerTextureUpdat
er(scoped_ptr<LayerPainterChromium> painter) | 48 BitmapSkPictureCanvasLayerTextureUpdater::BitmapSkPictureCanvasLayerTextureUpdat
er(scoped_ptr<LayerPainter> painter) |
| 49 : SkPictureCanvasLayerTextureUpdater(painter.Pass()) | 49 : SkPictureCanvasLayerTextureUpdater(painter.Pass()) |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 BitmapSkPictureCanvasLayerTextureUpdater::~BitmapSkPictureCanvasLayerTextureUpda
ter() | 53 BitmapSkPictureCanvasLayerTextureUpdater::~BitmapSkPictureCanvasLayerTextureUpda
ter() |
| 54 { | 54 { |
| 55 } | 55 } |
| 56 | 56 |
| 57 scoped_ptr<LayerTextureUpdater::Texture> BitmapSkPictureCanvasLayerTextureUpdate
r::createTexture(CCPrioritizedTextureManager* manager) | 57 scoped_ptr<LayerTextureUpdater::Texture> BitmapSkPictureCanvasLayerTextureUpdate
r::createTexture(PrioritizedTextureManager* manager) |
| 58 { | 58 { |
| 59 return scoped_ptr<LayerTextureUpdater::Texture>(new Texture(this, CCPrioriti
zedTexture::create(manager))); | 59 return scoped_ptr<LayerTextureUpdater::Texture>(new Texture(this, Prioritize
dTexture::create(manager))); |
| 60 } | 60 } |
| 61 | 61 |
| 62 LayerTextureUpdater::SampledTexelFormat BitmapSkPictureCanvasLayerTextureUpdater
::sampledTexelFormat(GC3Denum textureFormat) | 62 LayerTextureUpdater::SampledTexelFormat BitmapSkPictureCanvasLayerTextureUpdater
::sampledTexelFormat(GC3Denum textureFormat) |
| 63 { | 63 { |
| 64 // The component order may be bgra if we uploaded bgra pixels to rgba textur
es. | 64 // The component order may be bgra if we uploaded bgra pixels to rgba textur
es. |
| 65 return PlatformColor::sameComponentOrder(textureFormat) ? | 65 return PlatformColor::sameComponentOrder(textureFormat) ? |
| 66 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::S
ampledTexelFormatBGRA; | 66 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::S
ampledTexelFormatBGRA; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void BitmapSkPictureCanvasLayerTextureUpdater::paintContentsRect(SkCanvas* canva
s, const IntRect& sourceRect, CCRenderingStats& stats) | 69 void BitmapSkPictureCanvasLayerTextureUpdater::paintContentsRect(SkCanvas* canva
s, const IntRect& sourceRect, RenderingStats& stats) |
| 70 { | 70 { |
| 71 // Translate the origin of contentRect to that of sourceRect. | 71 // Translate the origin of contentRect to that of sourceRect. |
| 72 canvas->translate(contentRect().x() - sourceRect.x(), | 72 canvas->translate(contentRect().x() - sourceRect.x(), |
| 73 contentRect().y() - sourceRect.y()); | 73 contentRect().y() - sourceRect.y()); |
| 74 double rasterizeBeginTime = monotonicallyIncreasingTime(); | 74 double rasterizeBeginTime = monotonicallyIncreasingTime(); |
| 75 drawPicture(canvas); | 75 drawPicture(canvas); |
| 76 stats.totalRasterizeTimeInSeconds += monotonicallyIncreasingTime() - rasteri
zeBeginTime; | 76 stats.totalRasterizeTimeInSeconds += monotonicallyIncreasingTime() - rasteri
zeBeginTime; |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace cc | 79 } // namespace cc |
| OLD | NEW |