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_LAYER_UPDATER_H_
6 #define CC_LAYER_UPDATER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/cc_export.h"
20 class PrioritizedResource
;
21 class PrioritizedResourceManager
;
22 class ResourceUpdateQueue
;
24 struct RenderingStats
;
26 class CC_EXPORT LayerUpdater
: public base::RefCounted
<LayerUpdater
> {
28 // Allows updaters to store per-resource update properties.
29 class CC_EXPORT Resource
{
33 PrioritizedResource
* texture() { return m_texture
.get(); }
34 void swapTextureWith(scoped_ptr
<PrioritizedResource
>& texture
);
35 // TODO(reveman): partialUpdate should be a property of this class
36 // instead of an argument passed to update().
37 virtual void update(ResourceUpdateQueue
&, const gfx::Rect
& sourceRect
, const gfx::Vector2d
& destOffset
, bool partialUpdate
, RenderingStats
*) = 0;
39 explicit Resource(scoped_ptr
<PrioritizedResource
> texture
);
42 scoped_ptr
<PrioritizedResource
> m_texture
;
44 DISALLOW_COPY_AND_ASSIGN(Resource
);
49 virtual scoped_ptr
<Resource
> createResource(PrioritizedResourceManager
*) = 0;
50 // The |resultingOpaqueRect| gives back a region of the layer that was painted opaque. If the layer is marked opaque in the updater,
51 // then this region should be ignored in preference for the entire layer's area.
52 virtual void prepareToUpdate(const gfx::Rect
& contentRect
, const gfx::Size
& tileSize
, float contentsWidthScale
, float contentsHeightScale
, gfx::Rect
& resultingOpaqueRect
, RenderingStats
*) { }
54 // Set true by the layer when it is known that the entire output is going to be opaque.
55 virtual void setOpaque(bool) { }
58 virtual ~LayerUpdater() { }
61 friend class base::RefCounted
<LayerUpdater
>;
66 #endif // CC_LAYER_UPDATER_H_