app_list: Update separator color.
[chromium-blink-merge.git] / cc / BitmapSkPictureCanvasLayerTextureUpdater.cpp
blob1d0c913014b6e929664e92f993dbde6c578f56e5
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.
6 #include "config.h"
8 #if USE(ACCELERATED_COMPOSITING)
10 #include "BitmapSkPictureCanvasLayerTextureUpdater.h"
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>
19 namespace WebCore {
21 BitmapSkPictureCanvasLayerTextureUpdater::Texture::Texture(BitmapSkPictureCanvasLayerTextureUpdater* textureUpdater, PassOwnPtr<CCPrioritizedTexture> texture)
22 : CanvasLayerTextureUpdater::Texture(texture)
23 , m_textureUpdater(textureUpdater)
27 void BitmapSkPictureCanvasLayerTextureUpdater::Texture::prepareRect(const IntRect& sourceRect, CCRenderingStats& stats)
29 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRect.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() - paintBeginTime;
39 void BitmapSkPictureCanvasLayerTextureUpdater::Texture::updateRect(CCResourceProvider* resourceProvider, const IntRect& sourceRect, const IntSize& destOffset)
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();
47 PassRefPtr<BitmapSkPictureCanvasLayerTextureUpdater> BitmapSkPictureCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter)
49 return adoptRef(new BitmapSkPictureCanvasLayerTextureUpdater(painter));
52 BitmapSkPictureCanvasLayerTextureUpdater::BitmapSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter)
53 : SkPictureCanvasLayerTextureUpdater(painter)
57 BitmapSkPictureCanvasLayerTextureUpdater::~BitmapSkPictureCanvasLayerTextureUpdater()
61 PassOwnPtr<LayerTextureUpdater::Texture> BitmapSkPictureCanvasLayerTextureUpdater::createTexture(CCPrioritizedTextureManager* manager)
63 return adoptPtr(new Texture(this, CCPrioritizedTexture::create(manager)));
66 LayerTextureUpdater::SampledTexelFormat BitmapSkPictureCanvasLayerTextureUpdater::sampledTexelFormat(GC3Denum textureFormat)
68 // The component order may be bgra if we uploaded bgra pixels to rgba textures.
69 return PlatformColor::sameComponentOrder(textureFormat) ?
70 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA;
73 void BitmapSkPictureCanvasLayerTextureUpdater::paintContentsRect(SkCanvas* canvas, const IntRect& sourceRect, CCRenderingStats& stats)
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() - rasterizeBeginTime;
83 } // namespace WebCore
84 #endif // USE(ACCELERATED_COMPOSITING)