Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.renderscript; |
| 18 | |
| 19 | |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 20 | import android.util.Log; |
| 21 | |
| 22 | |
| 23 | /** |
Robert Ly | 11518ac | 2011-02-09 13:57:06 -0800 | [diff] [blame] | 24 | * <p>ProgramStore contains a set of parameters that control how |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 25 | * the graphics hardware handles writes to the framebuffer. |
Robert Ly | 11518ac | 2011-02-09 13:57:06 -0800 | [diff] [blame] | 26 | * It could be used to:</p> |
| 27 | * <ul> |
| 28 | * <li>enable/disable depth testing</li> |
| 29 | * <li>specify wheather depth writes are performed</li> |
| 30 | * <li>setup various blending modes for use in effects like |
| 31 | * transparency</li> |
| 32 | * <li>define write masks for color components written into the |
| 33 | * framebuffer</li> |
| 34 | * </ul> |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 35 | * |
| 36 | **/ |
| 37 | public class ProgramStore extends BaseObj { |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 38 | /** |
| 39 | * Specifies the function used to determine whether a fragment |
| 40 | * will be drawn during the depth testing stage in the rendering |
| 41 | * pipeline by comparing its value with that already in the depth |
| 42 | * buffer. DepthFunc is only valid when depth buffer is present |
| 43 | * and depth testing is enabled |
| 44 | */ |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 45 | public enum DepthFunc { |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * Always drawn |
| 49 | */ |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 50 | ALWAYS (0), |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 51 | /** |
| 52 | * Drawn if the incoming depth value is less than that in the |
| 53 | * depth buffer |
| 54 | */ |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 55 | LESS (1), |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 56 | /** |
| 57 | * Drawn if the incoming depth value is less or equal to that in |
| 58 | * the depth buffer |
| 59 | */ |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 60 | LESS_OR_EQUAL (2), |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 61 | /** |
| 62 | * Drawn if the incoming depth value is greater than that in the |
| 63 | * depth buffer |
| 64 | */ |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 65 | GREATER (3), |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 66 | /** |
| 67 | * Drawn if the incoming depth value is greater or equal to that |
| 68 | * in the depth buffer |
| 69 | */ |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 70 | GREATER_OR_EQUAL (4), |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 71 | /** |
| 72 | * Drawn if the incoming depth value is equal to that in the |
| 73 | * depth buffer |
| 74 | */ |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 75 | EQUAL (5), |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 76 | /** |
| 77 | * Drawn if the incoming depth value is not equal to that in the |
| 78 | * depth buffer |
| 79 | */ |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 80 | NOT_EQUAL (6); |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 81 | |
| 82 | int mID; |
| 83 | DepthFunc(int id) { |
| 84 | mID = id; |
| 85 | } |
| 86 | } |
| 87 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 88 | /** |
| 89 | * Specifies the functions used to combine incoming pixels with |
| 90 | * those already in the frame buffer. |
| 91 | * |
| 92 | * BlendSrcFunc describes how the coefficient used to scale the |
| 93 | * source pixels during the blending operation is computed |
| 94 | * |
| 95 | */ |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 96 | public enum BlendSrcFunc { |
| 97 | ZERO (0), |
| 98 | ONE (1), |
| 99 | DST_COLOR (2), |
| 100 | ONE_MINUS_DST_COLOR (3), |
| 101 | SRC_ALPHA (4), |
| 102 | ONE_MINUS_SRC_ALPHA (5), |
| 103 | DST_ALPHA (6), |
Jason Sams | eab4c75 | 2009-10-28 17:40:13 -0700 | [diff] [blame] | 104 | ONE_MINUS_DST_ALPHA (7), |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 105 | SRC_ALPHA_SATURATE (8); |
| 106 | |
| 107 | int mID; |
| 108 | BlendSrcFunc(int id) { |
| 109 | mID = id; |
| 110 | } |
| 111 | } |
| 112 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 113 | /** |
| 114 | * Specifies the functions used to combine incoming pixels with |
| 115 | * those already in the frame buffer. |
| 116 | * |
| 117 | * BlendDstFunc describes how the coefficient used to scale the |
| 118 | * pixels already in the framebuffer is computed during the |
| 119 | * blending operation |
| 120 | * |
| 121 | */ |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 122 | public enum BlendDstFunc { |
| 123 | ZERO (0), |
| 124 | ONE (1), |
| 125 | SRC_COLOR (2), |
| 126 | ONE_MINUS_SRC_COLOR (3), |
| 127 | SRC_ALPHA (4), |
| 128 | ONE_MINUS_SRC_ALPHA (5), |
| 129 | DST_ALPHA (6), |
Jason Sams | eab4c75 | 2009-10-28 17:40:13 -0700 | [diff] [blame] | 130 | ONE_MINUS_DST_ALPHA (7); |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 131 | |
| 132 | int mID; |
| 133 | BlendDstFunc(int id) { |
| 134 | mID = id; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | |
| 139 | ProgramStore(int id, RenderScript rs) { |
Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 140 | super(id, rs); |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 141 | } |
| 142 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 143 | /** |
| 144 | * Returns a pre-defined program store object with the following |
| 145 | * characteristics: |
| 146 | * - incoming pixels are drawn if their depth value is less than |
| 147 | * the stored value in the depth buffer. If the pixel is |
| 148 | * drawn, its value is also stored in the depth buffer |
| 149 | * - incoming pixels override the value stored in the color |
| 150 | * buffer if it passes the depth test |
| 151 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 152 | * @param rs Context to which the program will belong. |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 153 | **/ |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 154 | public static ProgramStore BLEND_NONE_DEPTH_TEST(RenderScript rs) { |
| 155 | if(rs.mProgramStore_BLEND_NONE_DEPTH_TEST == null) { |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 156 | ProgramStore.Builder builder = new ProgramStore.Builder(rs); |
| 157 | builder.setDepthFunc(ProgramStore.DepthFunc.LESS); |
| 158 | builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 159 | builder.setDitherEnabled(false); |
| 160 | builder.setDepthMaskEnabled(true); |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 161 | rs.mProgramStore_BLEND_NONE_DEPTH_TEST = builder.create(); |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 162 | } |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 163 | return rs.mProgramStore_BLEND_NONE_DEPTH_TEST; |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 164 | } |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 165 | /** |
| 166 | * Returns a pre-defined program store object with the following |
| 167 | * characteristics: |
| 168 | * - incoming pixels always pass the depth test and their value |
| 169 | * is not stored in the depth buffer |
| 170 | * - incoming pixels override the value stored in the color |
| 171 | * buffer |
| 172 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 173 | * @param rs Context to which the program will belong. |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 174 | **/ |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 175 | public static ProgramStore BLEND_NONE_DEPTH_NONE(RenderScript rs) { |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 176 | if(rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH == null) { |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 177 | ProgramStore.Builder builder = new ProgramStore.Builder(rs); |
| 178 | builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); |
| 179 | builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 180 | builder.setDitherEnabled(false); |
| 181 | builder.setDepthMaskEnabled(false); |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 182 | rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH = builder.create(); |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 183 | } |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 184 | return rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH; |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 185 | } |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 186 | /** |
| 187 | * Returns a pre-defined program store object with the following |
| 188 | * characteristics: |
| 189 | * - incoming pixels are drawn if their depth value is less than |
| 190 | * the stored value in the depth buffer. If the pixel is |
| 191 | * drawn, its value is also stored in the depth buffer |
| 192 | * - if the incoming (Source) pixel passes depth test, its value |
| 193 | * is combined with the stored color (Dest) using the |
| 194 | * following formula |
| 195 | * Final.RGB = Source.RGB * Source.A + Dest.RGB * (1 - Source.A) |
| 196 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 197 | * @param rs Context to which the program will belong. |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 198 | **/ |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 199 | public static ProgramStore BLEND_ALPHA_DEPTH_TEST(RenderScript rs) { |
| 200 | if(rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST == null) { |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 201 | ProgramStore.Builder builder = new ProgramStore.Builder(rs); |
| 202 | builder.setDepthFunc(ProgramStore.DepthFunc.LESS); |
| 203 | builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 204 | builder.setDitherEnabled(false); |
| 205 | builder.setDepthMaskEnabled(true); |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 206 | rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST = builder.create(); |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 207 | } |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 208 | return rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST; |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 209 | } |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 210 | /** |
| 211 | * Returns a pre-defined program store object with the following |
| 212 | * characteristics: |
| 213 | * - incoming pixels always pass the depth test and their value |
| 214 | * is not stored in the depth buffer |
| 215 | * - incoming pixel's value is combined with the stored color |
| 216 | * (Dest) using the following formula |
| 217 | * Final.RGB = Source.RGB * Source.A + Dest.RGB * (1 - Source.A) |
| 218 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 219 | * @param rs Context to which the program will belong. |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 220 | **/ |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 221 | public static ProgramStore BLEND_ALPHA_DEPTH_NONE(RenderScript rs) { |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 222 | if(rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH == null) { |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 223 | ProgramStore.Builder builder = new ProgramStore.Builder(rs); |
| 224 | builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); |
| 225 | builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 226 | builder.setDitherEnabled(false); |
| 227 | builder.setDepthMaskEnabled(false); |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 228 | rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH = builder.create(); |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 229 | } |
Alex Sakhartchouk | d36f248 | 2010-08-24 11:37:33 -0700 | [diff] [blame] | 230 | return rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH; |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 231 | } |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 232 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 233 | /** |
| 234 | * Builder class for ProgramStore object. If the builder is left |
| 235 | * empty, the equivalent of BLEND_NONE_DEPTH_NONE would be |
| 236 | * returned |
| 237 | */ |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 238 | public static class Builder { |
| 239 | RenderScript mRS; |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 240 | DepthFunc mDepthFunc; |
| 241 | boolean mDepthMask; |
| 242 | boolean mColorMaskR; |
| 243 | boolean mColorMaskG; |
| 244 | boolean mColorMaskB; |
| 245 | boolean mColorMaskA; |
| 246 | BlendSrcFunc mBlendSrc; |
| 247 | BlendDstFunc mBlendDst; |
| 248 | boolean mDither; |
| 249 | |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 250 | public Builder(RenderScript rs) { |
| 251 | mRS = rs; |
Alex Sakhartchouk | 32e09b5 | 2010-08-23 10:24:10 -0700 | [diff] [blame] | 252 | mDepthFunc = DepthFunc.ALWAYS; |
| 253 | mDepthMask = false; |
| 254 | mColorMaskR = true; |
| 255 | mColorMaskG = true; |
| 256 | mColorMaskB = true; |
| 257 | mColorMaskA = true; |
| 258 | mBlendSrc = BlendSrcFunc.ONE; |
| 259 | mBlendDst = BlendDstFunc.ZERO; |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 262 | /** |
| 263 | * Specifies the depth testing behavior |
| 264 | * |
| 265 | * @param func function used for depth testing |
| 266 | * |
| 267 | * @return this |
| 268 | */ |
Jim Shuma | 288c871 | 2010-07-07 14:24:21 -0700 | [diff] [blame] | 269 | public Builder setDepthFunc(DepthFunc func) { |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 270 | mDepthFunc = func; |
Jim Shuma | 288c871 | 2010-07-07 14:24:21 -0700 | [diff] [blame] | 271 | return this; |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 274 | /** |
| 275 | * Enables writes into the depth buffer |
| 276 | * |
| 277 | * @param enable specifies whether depth writes are |
| 278 | * enabled or disabled |
| 279 | * |
| 280 | * @return this |
| 281 | */ |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 282 | public Builder setDepthMaskEnabled(boolean enable) { |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 283 | mDepthMask = enable; |
Jim Shuma | 288c871 | 2010-07-07 14:24:21 -0700 | [diff] [blame] | 284 | return this; |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 287 | /** |
| 288 | * Enables writes into the color buffer |
| 289 | * |
| 290 | * @param r specifies whether red channel is written |
| 291 | * @param g specifies whether green channel is written |
| 292 | * @param b specifies whether blue channel is written |
| 293 | * @param a specifies whether alpha channel is written |
| 294 | * |
| 295 | * @return this |
| 296 | */ |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 297 | public Builder setColorMaskEnabled(boolean r, boolean g, boolean b, boolean a) { |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 298 | mColorMaskR = r; |
| 299 | mColorMaskG = g; |
| 300 | mColorMaskB = b; |
| 301 | mColorMaskA = a; |
Jim Shuma | 288c871 | 2010-07-07 14:24:21 -0700 | [diff] [blame] | 302 | return this; |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 305 | /** |
| 306 | * Specifies how incoming pixels are combined with the pixels |
| 307 | * stored in the framebuffer |
| 308 | * |
| 309 | * @param src specifies how the source blending factor is |
| 310 | * computed |
| 311 | * @param dst specifies how the destination blending factor is |
| 312 | * computed |
| 313 | * |
| 314 | * @return this |
| 315 | */ |
Jim Shuma | 288c871 | 2010-07-07 14:24:21 -0700 | [diff] [blame] | 316 | public Builder setBlendFunc(BlendSrcFunc src, BlendDstFunc dst) { |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 317 | mBlendSrc = src; |
| 318 | mBlendDst = dst; |
Jim Shuma | 288c871 | 2010-07-07 14:24:21 -0700 | [diff] [blame] | 319 | return this; |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 322 | /** |
| 323 | * Enables dithering |
| 324 | * |
| 325 | * @param enable specifies whether dithering is enabled or |
| 326 | * disabled |
| 327 | * |
| 328 | * @return this |
| 329 | */ |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 330 | public Builder setDitherEnabled(boolean enable) { |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 331 | mDither = enable; |
Jim Shuma | 288c871 | 2010-07-07 14:24:21 -0700 | [diff] [blame] | 332 | return this; |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 333 | } |
| 334 | |
Alex Sakhartchouk | 623c54d | 2011-01-12 17:32:36 -0800 | [diff] [blame] | 335 | /** |
| 336 | * Creates a program store from the current state of the builder |
| 337 | */ |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 338 | public ProgramStore create() { |
Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 339 | mRS.validate(); |
Jason Sams | 331bf9b | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 340 | int id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA, |
| 341 | mDepthMask, mDither, |
| 342 | mBlendSrc.mID, mBlendDst.mID, mDepthFunc.mID); |
| 343 | return new ProgramStore(id, mRS); |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | |
| 347 | } |
| 348 | |
| 349 | |
| 350 | |
| 351 | |