| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 | |
| 6 #include "config.h" | |
| 7 | |
| 8 #if USE(ACCELERATED_COMPOSITING) | |
| 9 | |
| 10 #include "BitmapSkPictureCanvasLayerTextureUpdater.h" | |
| 11 | |
| 12 #include "CCRenderingStats.h" | |
| 13 #include "LayerPainterChromium.h" | |
| 14 #include "PlatformColor.h" | |
| 15 #include "SkCanvas.h" | |
| 16 #include "SkDevice.h" | |
| 17 #include <wtf/CurrentTime.h> | |
| 18 | |
| 19 namespace cc { | |
| 20 | |
| 21 BitmapSkPictureCanvasLayerTextureUpdater::Texture::Texture(BitmapSkPictureCanvas
LayerTextureUpdater* textureUpdater, scoped_ptr<CCPrioritizedTexture> texture) | |
| 22 : CanvasLayerTextureUpdater::Texture(texture.Pass()) | |
| 23 , m_textureUpdater(textureUpdater) | |
| 24 { | |
| 25 } | |
| 26 | |
| 27 void BitmapSkPictureCanvasLayerTextureUpdater::Texture::prepareRect(const IntRec
t& sourceRect, CCRenderingStats& stats) | |
| 28 { | |
| 29 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRe
ct.height()); | |
| 30 m_bitmap.allocPixels(); | |
| 31 m_bitmap.setIsOpaque(m_textureUpdater->layerIsOpaque()); | |
| 32 SkDevice device(m_bitmap); | |
| 33 SkCanvas canvas(&device); | |
| 34 double paintBeginTime = monotonicallyIncreasingTime(); | |
| 35 textureUpdater()->paintContentsRect(&canvas, sourceRect, stats); | |
| 36 stats.totalPaintTimeInSeconds += monotonicallyIncreasingTime() - paintBeginT
ime; | |
| 37 } | |
| 38 | |
| 39 void BitmapSkPictureCanvasLayerTextureUpdater::Texture::updateRect(CCResourcePro
vider* resourceProvider, const IntRect& sourceRect, const IntSize& destOffset) | |
| 40 { | |
| 41 m_bitmap.lockPixels(); | |
| 42 texture()->upload(resourceProvider, static_cast<uint8_t*>(m_bitmap.getPixels
()), sourceRect, sourceRect, destOffset); | |
| 43 m_bitmap.unlockPixels(); | |
| 44 m_bitmap.reset(); | |
| 45 } | |
| 46 | |
| 47 PassRefPtr<BitmapSkPictureCanvasLayerTextureUpdater> BitmapSkPictureCanvasLayerT
extureUpdater::create(PassOwnPtr<LayerPainterChromium> painter) | |
| 48 { | |
| 49 return adoptRef(new BitmapSkPictureCanvasLayerTextureUpdater(painter)); | |
| 50 } | |
| 51 | |
| 52 BitmapSkPictureCanvasLayerTextureUpdater::BitmapSkPictureCanvasLayerTextureUpdat
er(PassOwnPtr<LayerPainterChromium> painter) | |
| 53 : SkPictureCanvasLayerTextureUpdater(painter) | |
| 54 { | |
| 55 } | |
| 56 | |
| 57 BitmapSkPictureCanvasLayerTextureUpdater::~BitmapSkPictureCanvasLayerTextureUpda
ter() | |
| 58 { | |
| 59 } | |
| 60 | |
| 61 PassOwnPtr<LayerTextureUpdater::Texture> BitmapSkPictureCanvasLayerTextureUpdate
r::createTexture(CCPrioritizedTextureManager* manager) | |
| 62 { | |
| 63 return adoptPtr(new Texture(this, CCPrioritizedTexture::create(manager))); | |
| 64 } | |
| 65 | |
| 66 LayerTextureUpdater::SampledTexelFormat BitmapSkPictureCanvasLayerTextureUpdater
::sampledTexelFormat(GC3Denum textureFormat) | |
| 67 { | |
| 68 // The component order may be bgra if we uploaded bgra pixels to rgba textur
es. | |
| 69 return PlatformColor::sameComponentOrder(textureFormat) ? | |
| 70 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::S
ampledTexelFormatBGRA; | |
| 71 } | |
| 72 | |
| 73 void BitmapSkPictureCanvasLayerTextureUpdater::paintContentsRect(SkCanvas* canva
s, const IntRect& sourceRect, CCRenderingStats& stats) | |
| 74 { | |
| 75 // Translate the origin of contentRect to that of sourceRect. | |
| 76 canvas->translate(contentRect().x() - sourceRect.x(), | |
| 77 contentRect().y() - sourceRect.y()); | |
| 78 double rasterizeBeginTime = monotonicallyIncreasingTime(); | |
| 79 drawPicture(canvas); | |
| 80 stats.totalRasterizeTimeInSeconds += monotonicallyIncreasingTime() - rasteri
zeBeginTime; | |
| 81 } | |
| 82 | |
| 83 } // namespace cc | |
| 84 #endif // USE(ACCELERATED_COMPOSITING) | |
| OLD | NEW |