1 // Copyright 2013 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_LAYERS_UI_RESOURCE_LAYER_IMPL_H_
6 #define CC_LAYERS_UI_RESOURCE_LAYER_IMPL_H_
10 #include "cc/base/cc_export.h"
11 #include "cc/layers/layer_impl.h"
12 #include "cc/resources/resource_provider.h"
13 #include "cc/resources/ui_resource_client.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/size.h"
18 class DictionaryValue
;
23 class CC_EXPORT UIResourceLayerImpl
: public LayerImpl
{
25 static scoped_ptr
<UIResourceLayerImpl
> Create(LayerTreeImpl
* tree_impl
,
27 return make_scoped_ptr(new UIResourceLayerImpl(tree_impl
, id
));
29 virtual ~UIResourceLayerImpl();
31 void SetUIResourceId(UIResourceId uid
);
33 void SetImageBounds(gfx::Size image_bounds
);
35 // Sets a UV transform to be used at draw time. Defaults to (0, 0) and (1, 1).
36 void SetUV(gfx::PointF top_left
, gfx::PointF bottom_right
);
38 // Sets an opacity value per vertex. It will be multiplied by the layer
40 void SetVertexOpacity(const float vertex_opacity
[4]);
42 virtual scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
)
44 virtual void PushPropertiesTo(LayerImpl
* layer
) OVERRIDE
;
46 virtual bool WillDraw(DrawMode draw_mode
,
47 ResourceProvider
* resource_provider
) OVERRIDE
;
48 virtual void AppendQuads(QuadSink
* quad_sink
,
49 AppendQuadsData
* append_quads_data
) OVERRIDE
;
51 virtual base::DictionaryValue
* LayerTreeAsJson() const OVERRIDE
;
54 UIResourceLayerImpl(LayerTreeImpl
* tree_impl
, int id
);
56 // The size of the resource bitmap in pixels.
57 gfx::Size image_bounds_
;
59 UIResourceId ui_resource_id_
;
61 gfx::PointF uv_top_left_
;
62 gfx::PointF uv_bottom_right_
;
63 float vertex_opacity_
[4];
66 virtual const char* LayerTypeAsString() const OVERRIDE
;
68 DISALLOW_COPY_AND_ASSIGN(UIResourceLayerImpl
);
73 #endif // CC_LAYERS_UI_RESOURCE_LAYER_IMPL_H_