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.
5 #ifndef CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_
6 #define CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_
8 #include "cc/base/cc_export.h"
9 #include "cc/resources/content_layer_updater.h"
10 #include "skia/ext/refptr.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
18 class RenderingStatsInstrumenation
;
20 // This class rasterizes the content_rect into a skia bitmap canvas. It then
21 // creates a ResourceUpdate with this bitmap canvas and inserts the
22 // ResourceBundle to the provided ResourceUpdateQueue. Actual texture uploading
23 // is done by ResourceUpdateController.
24 class CC_EXPORT BitmapContentLayerUpdater
: public ContentLayerUpdater
{
26 class Resource
: public LayerUpdater::Resource
{
28 Resource(BitmapContentLayerUpdater
* updater
,
29 scoped_ptr
<PrioritizedResource
> resource
);
32 virtual void Update(ResourceUpdateQueue
* queue
,
33 const gfx::Rect
& source_rect
,
34 const gfx::Vector2d
& dest_offset
,
35 bool partial_update
) OVERRIDE
;
38 BitmapContentLayerUpdater
* updater_
;
40 DISALLOW_COPY_AND_ASSIGN(Resource
);
43 static scoped_refptr
<BitmapContentLayerUpdater
> Create(
44 scoped_ptr
<LayerPainter
> painter
,
45 RenderingStatsInstrumentation
* stats_instrumenation
,
48 virtual scoped_ptr
<LayerUpdater::Resource
> CreateResource(
49 PrioritizedResourceManager
* manager
) OVERRIDE
;
50 virtual void PrepareToUpdate(const gfx::Rect
& content_rect
,
51 const gfx::Size
& tile_size
,
52 float contents_width_scale
,
53 float contents_height_scale
,
54 gfx::Rect
* resulting_opaque_rect
) OVERRIDE
;
55 void UpdateTexture(ResourceUpdateQueue
* queue
,
56 PrioritizedResource
* resource
,
57 const gfx::Rect
& source_rect
,
58 const gfx::Vector2d
& dest_offset
,
60 virtual void SetOpaque(bool opaque
) OVERRIDE
;
61 virtual void ReduceMemoryUsage() OVERRIDE
;
64 BitmapContentLayerUpdater(
65 scoped_ptr
<LayerPainter
> painter
,
66 RenderingStatsInstrumentation
* stats_instrumenation
,
68 virtual ~BitmapContentLayerUpdater();
70 SkBitmap bitmap_backing_
;
71 skia::RefPtr
<SkCanvas
> canvas_
;
72 gfx::Size canvas_size_
;
75 DISALLOW_COPY_AND_ASSIGN(BitmapContentLayerUpdater
);
80 #endif // CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_