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_LAYER_UPDATER_H_
6 #define CC_RESOURCES_LAYER_UPDATER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/base/cc_export.h"
11 #include "third_party/skia/include/core/SkColor.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/vector2d.h"
17 class PrioritizedResource
;
18 class PrioritizedResourceManager
;
19 class ResourceUpdateQueue
;
22 class CC_EXPORT LayerUpdater
: public base::RefCounted
<LayerUpdater
> {
24 // Allows updaters to store per-resource update properties.
25 class CC_EXPORT Resource
{
29 PrioritizedResource
* texture() { return texture_
.get(); }
30 // TODO(reveman): partial_update should be a property of this class
31 // instead of an argument passed to Update().
32 virtual void Update(ResourceUpdateQueue
* queue
,
33 const gfx::Rect
& source_rect
,
34 const gfx::Vector2d
& dest_offset
,
35 bool partial_update
) = 0;
38 explicit Resource(scoped_ptr
<PrioritizedResource
> texture
);
41 scoped_ptr
<PrioritizedResource
> texture_
;
43 DISALLOW_COPY_AND_ASSIGN(Resource
);
48 virtual scoped_ptr
<Resource
> CreateResource(
49 PrioritizedResourceManager
* manager
) = 0;
50 virtual void PrepareToUpdate(const gfx::Size
& content_size
,
51 const gfx::Rect
& paint_rect
,
52 const gfx::Size
& tile_size
,
53 float contents_width_scale
,
54 float contents_height_scale
) {}
55 virtual void ReduceMemoryUsage() {}
57 // Set true by the layer when it is known that the entire output is going to
59 virtual void SetOpaque(bool opaque
) {}
60 // Set true by the layer when it is known that the entire output bounds will
62 virtual void SetFillsBoundsCompletely(bool fills_bounds
) {}
63 virtual void SetBackgroundColor(SkColor background_color
) {}
66 virtual ~LayerUpdater() {}
69 friend class base::RefCounted
<LayerUpdater
>;
71 DISALLOW_COPY_AND_ASSIGN(LayerUpdater
);
76 #endif // CC_RESOURCES_LAYER_UPDATER_H_