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 CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_
7 #define CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_
9 #include "cc/content_layer_updater.h"
10 #include "third_party/skia/include/core/SkPicture.h"
18 // This class records the contentRect into an SkPicture. Subclasses, provide
19 // different implementations of tile updating based on this recorded picture.
20 // The BitmapSkPictureContentLayerUpdater and
21 // FrameBufferSkPictureContentLayerUpdater are two examples of such
23 class SkPictureContentLayerUpdater
: public ContentLayerUpdater
{
25 class Resource
: public LayerUpdater::Resource
{
27 Resource(SkPictureContentLayerUpdater
*, scoped_ptr
<PrioritizedResource
>);
30 virtual void update(ResourceUpdateQueue
&, const gfx::Rect
& sourceRect
, const gfx::Vector2d
& destOffset
, bool partialUpdate
, RenderingStats
*) OVERRIDE
;
33 SkPictureContentLayerUpdater
* updater() { return m_updater
; }
35 SkPictureContentLayerUpdater
* m_updater
;
38 static scoped_refptr
<SkPictureContentLayerUpdater
> create(scoped_ptr
<LayerPainter
>);
40 virtual scoped_ptr
<LayerUpdater::Resource
> createResource(PrioritizedResourceManager
*) OVERRIDE
;
41 virtual void setOpaque(bool) OVERRIDE
;
44 explicit SkPictureContentLayerUpdater(scoped_ptr
<LayerPainter
>);
45 virtual ~SkPictureContentLayerUpdater();
47 virtual void prepareToUpdate(const gfx::Rect
& contentRect
, const gfx::Size
& tileSize
, float contentsWidthScale
, float contentsHeightScale
, gfx::Rect
& resultingOpaqueRect
, RenderingStats
*) OVERRIDE
;
48 void drawPicture(SkCanvas
*);
49 void updateTexture(ResourceUpdateQueue
& queue
, PrioritizedResource
* texture
, const gfx::Rect
& sourceRect
, const gfx::Vector2d
& destOffset
, bool partialUpdate
);
51 bool layerIsOpaque() const { return m_layerIsOpaque
; }
56 // True when it is known that all output pixels will be opaque.
61 #endif // CC_SKPICTURE_CONTENT_LAYER_UPDATER_H_