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"
17 class RenderingStatsInstrumenation;
19 // This class rasterizes the content_rect into a skia bitmap canvas. It then
20 // updates textures by copying from the canvas into the texture, using
21 // MapSubImage if possible.
22 class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater {
24 class Resource : public LayerUpdater::Resource {
26 Resource(BitmapContentLayerUpdater* updater,
27 scoped_ptr<PrioritizedResource> resource);
30 virtual void Update(ResourceUpdateQueue* queue,
31 gfx::Rect source_rect,
32 gfx::Vector2d dest_offset,
33 bool partial_update) OVERRIDE;
36 BitmapContentLayerUpdater* updater_;
38 DISALLOW_COPY_AND_ASSIGN(Resource);
41 static scoped_refptr<BitmapContentLayerUpdater> Create(
42 scoped_ptr<LayerPainter> painter,
43 RenderingStatsInstrumentation* stats_instrumenation,
46 virtual scoped_ptr<LayerUpdater::Resource> CreateResource(
47 PrioritizedResourceManager* manager) OVERRIDE;
48 virtual void PrepareToUpdate(gfx::Rect content_rect,
50 float contents_width_scale,
51 float contents_height_scale,
52 gfx::Rect* resulting_opaque_rect) OVERRIDE;
53 void UpdateTexture(ResourceUpdateQueue* queue,
54 PrioritizedResource* resource,
55 gfx::Rect source_rect,
56 gfx::Vector2d dest_offset,
58 virtual void SetOpaque(bool opaque) OVERRIDE;
59 virtual void ReduceMemoryUsage() OVERRIDE;
62 BitmapContentLayerUpdater(
63 scoped_ptr<LayerPainter> painter,
64 RenderingStatsInstrumentation* stats_instrumenation,
66 virtual ~BitmapContentLayerUpdater();
68 skia::RefPtr<SkCanvas> canvas_;
69 gfx::Size canvas_size_;
73 DISALLOW_COPY_AND_ASSIGN(BitmapContentLayerUpdater);
78 #endif // CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_