Merge "Change PixelData to use the handle/body pattern" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / common / image-sampler.h
1 #ifndef __DALI_IMAGE_SAMPLER_H__
2 #define __DALI_IMAGE_SAMPLER_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/sampling.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 /**
31  * ImageSampler represents a set of sampling settings that can be applied to a texture.
32  */
33 namespace ImageSampler
34 {
35    /**
36     * Bitshift values
37     */
38    enum
39    {
40      MINIFY_BIT_SHIFT  = 0,
41      MAGNIFY_BIT_SHIFT = 4,
42      UWRAP_BIT_SHIFT   = 8,
43      VWRAP_BIT_SHIFT   = 12
44    };
45
46    /**
47     * Mask values
48     */
49    enum
50    {
51      MASK_MINIFY_FILTER  = 0x000F,
52      MASK_MAGNIFY_FILTER = 0x00F0,
53      MASK_UWRAP_MODE     = 0x0F00,
54      MASK_VWRAP_MODE     = 0xF000,
55    };
56
57    /**
58     * Precalculate default sampler bitfield
59     */
60    enum
61    {
62      DEFAULT_BITFIELD = (Dali::FilterMode::DEFAULT<<MINIFY_BIT_SHIFT) | (Dali::FilterMode::DEFAULT<<MAGNIFY_BIT_SHIFT) | (Dali::WrapMode::DEFAULT<<UWRAP_BIT_SHIFT) | (Dali::WrapMode::DEFAULT<<VWRAP_BIT_SHIFT)
63    };
64
65   /**
66    * @brief Pack the filter mode into a bitfield.
67    *
68    * @param[in] minify The minification filter.
69    * @param[in] magnify The magnification filter.
70    * @return Return the packed bitfield.
71    */
72    unsigned int PackBitfield( FilterMode::Type minify, FilterMode::Type magnify, WrapMode::Type uWrap = WrapMode::DEFAULT, WrapMode::Type vWrap = WrapMode::DEFAULT );
73
74    /**
75    * @brief Return the minification filter from a packed bitfield.
76    *
77    * @return Return the minification filter.
78    */
79    FilterMode::Type GetMinifyFilterMode( unsigned int bitfield );
80
81    /**
82    * @brief Return the magnification filter from a packed bitfield.
83    *
84    * @return Return the magnification filter.
85    */
86    FilterMode::Type GetMagnifyFilterMode( unsigned int bitfield );
87
88    /**
89     * @brief Return the wrap mode in x direction from a packed bitfield.
90     *
91     * @return Return the wrap mode.
92     */
93    WrapMode::Type GetUWrapMode( unsigned int bitfield );
94
95    /**
96     * @brief Return the wrap mode in y direction from a packed bitfield.
97     *
98     * @return Return the wrap mode.
99     */
100    WrapMode::Type GetVWrapMode( unsigned int bitfield );
101
102 } // namespace ImageSampler
103
104 } // namespace Internal
105
106 } // namespace Dali
107
108
109 #endif // __DALI_INTERNAL_IMAGE_SAMPLER_H__
110
111
112