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 #ifndef BitmapCanvasLayerTextureUpdater_h
7 #define BitmapCanvasLayerTextureUpdater_h
9 #if USE(ACCELERATED_COMPOSITING)
11 #include "CanvasLayerTextureUpdater.h"
17 class LayerPainterChromium
;
19 // This class rasterizes the contentRect into a skia bitmap canvas. It then updates
20 // textures by copying from the canvas into the texture, using MapSubImage if
22 class BitmapCanvasLayerTextureUpdater
: public CanvasLayerTextureUpdater
{
24 class Texture
: public LayerTextureUpdater::Texture
{
26 Texture(BitmapCanvasLayerTextureUpdater
*, scoped_ptr
<CCPrioritizedTexture
>);
29 virtual void updateRect(CCResourceProvider
*, const IntRect
& sourceRect
, const IntSize
& destOffset
) OVERRIDE
;
32 BitmapCanvasLayerTextureUpdater
* textureUpdater() { return m_textureUpdater
; }
34 BitmapCanvasLayerTextureUpdater
* m_textureUpdater
;
37 static PassRefPtr
<BitmapCanvasLayerTextureUpdater
> create(PassOwnPtr
<LayerPainterChromium
>);
38 virtual ~BitmapCanvasLayerTextureUpdater();
40 virtual PassOwnPtr
<LayerTextureUpdater::Texture
> createTexture(CCPrioritizedTextureManager
*) OVERRIDE
;
41 virtual SampledTexelFormat
sampledTexelFormat(GC3Denum textureFormat
) OVERRIDE
;
42 virtual void prepareToUpdate(const IntRect
& contentRect
, const IntSize
& tileSize
, float contentsWidthScale
, float contentsHeightScale
, IntRect
& resultingOpaqueRect
, CCRenderingStats
&) OVERRIDE
;
43 void updateTextureRect(CCResourceProvider
*, CCPrioritizedTexture
*, const IntRect
& sourceRect
, const IntSize
& destOffset
);
45 virtual void setOpaque(bool) OVERRIDE
;
48 explicit BitmapCanvasLayerTextureUpdater(PassOwnPtr
<LayerPainterChromium
>);
50 OwnPtr
<SkCanvas
> m_canvas
;
56 #endif // USE(ACCELERATED_COMPOSITING)
57 #endif // BitmapCanvasLayerTextureUpdater_h