OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrTypes_DEFINED | 8 #ifndef GrTypes_DEFINED |
9 #define GrTypes_DEFINED | 9 #define GrTypes_DEFINED |
10 | 10 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 kRGBA_8888_GrPixelConfig, | 211 kRGBA_8888_GrPixelConfig, |
212 /** | 212 /** |
213 * Premultiplied. Byte order is b,g,r,a. | 213 * Premultiplied. Byte order is b,g,r,a. |
214 */ | 214 */ |
215 kBGRA_8888_GrPixelConfig, | 215 kBGRA_8888_GrPixelConfig, |
216 /** | 216 /** |
217 * Premultiplied and sRGB. Byte order is r,g,b,a. | 217 * Premultiplied and sRGB. Byte order is r,g,b,a. |
218 */ | 218 */ |
219 kSRGBA_8888_GrPixelConfig, | 219 kSRGBA_8888_GrPixelConfig, |
220 /** | 220 /** |
| 221 * Premultiplied and sRGB. Byte order is b,g,r,a. |
| 222 */ |
| 223 kSBGRA_8888_GrPixelConfig, |
| 224 /** |
221 * ETC1 Compressed Data | 225 * ETC1 Compressed Data |
222 */ | 226 */ |
223 kETC1_GrPixelConfig, | 227 kETC1_GrPixelConfig, |
224 /** | 228 /** |
225 * LATC/RGTC/3Dc/BC4 Compressed Data | 229 * LATC/RGTC/3Dc/BC4 Compressed Data |
226 */ | 230 */ |
227 kLATC_GrPixelConfig, | 231 kLATC_GrPixelConfig, |
228 /** | 232 /** |
229 * R11 EAC Compressed Data | 233 * R11 EAC Compressed Data |
230 * (Corresponds to section C.3.5 of the OpenGL 4.4 core profile spec) | 234 * (Corresponds to section C.3.5 of the OpenGL 4.4 core profile spec) |
(...skipping 30 matching lines...) Expand all Loading... |
261 kLast_GrPixelConfig = kRGBA_half_GrPixelConfig | 265 kLast_GrPixelConfig = kRGBA_half_GrPixelConfig |
262 }; | 266 }; |
263 static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1; | 267 static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1; |
264 | 268 |
265 // Aliases for pixel configs that match skia's byte order. | 269 // Aliases for pixel configs that match skia's byte order. |
266 #ifndef SK_CPU_LENDIAN | 270 #ifndef SK_CPU_LENDIAN |
267 #error "Skia gpu currently assumes little endian" | 271 #error "Skia gpu currently assumes little endian" |
268 #endif | 272 #endif |
269 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) | 273 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) |
270 static const GrPixelConfig kSkia8888_GrPixelConfig = kBGRA_8888_GrPixelConfi
g; | 274 static const GrPixelConfig kSkia8888_GrPixelConfig = kBGRA_8888_GrPixelConfi
g; |
| 275 static const GrPixelConfig kSkiaGamma8888_GrPixelConfig = kSBGRA_8888_GrPixe
lConfig; |
271 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) | 276 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
272 static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfi
g; | 277 static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfi
g; |
| 278 static const GrPixelConfig kSkiaGamma8888_GrPixelConfig = kSRGBA_8888_GrPixe
lConfig; |
273 #else | 279 #else |
274 #error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format." | 280 #error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format." |
275 #endif | 281 #endif |
276 | 282 |
277 // Returns true if the pixel config is a GPU-specific compressed format | 283 // Returns true if the pixel config is a GPU-specific compressed format |
278 // representation. | 284 // representation. |
279 static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) { | 285 static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) { |
280 switch (config) { | 286 switch (config) { |
281 case kIndex_8_GrPixelConfig: | 287 case kIndex_8_GrPixelConfig: |
282 case kETC1_GrPixelConfig: | 288 case kETC1_GrPixelConfig: |
(...skipping 21 matching lines...) Expand all Loading... |
304 return config; | 310 return config; |
305 } | 311 } |
306 } | 312 } |
307 | 313 |
308 // Returns true if the pixel config is 32 bits per pixel | 314 // Returns true if the pixel config is 32 bits per pixel |
309 static inline bool GrPixelConfigIs8888(GrPixelConfig config) { | 315 static inline bool GrPixelConfigIs8888(GrPixelConfig config) { |
310 switch (config) { | 316 switch (config) { |
311 case kRGBA_8888_GrPixelConfig: | 317 case kRGBA_8888_GrPixelConfig: |
312 case kBGRA_8888_GrPixelConfig: | 318 case kBGRA_8888_GrPixelConfig: |
313 case kSRGBA_8888_GrPixelConfig: | 319 case kSRGBA_8888_GrPixelConfig: |
| 320 case kSBGRA_8888_GrPixelConfig: |
314 return true; | 321 return true; |
315 default: | 322 default: |
316 return false; | 323 return false; |
317 } | 324 } |
318 } | 325 } |
319 | 326 |
320 // Returns true if the color (non-alpha) components represent sRGB values. It do
es NOT indicate that | 327 // Returns true if the color (non-alpha) components represent sRGB values. It do
es NOT indicate that |
321 // all three color components are present in the config or anything about their
order. | 328 // all three color components are present in the config or anything about their
order. |
322 static inline bool GrPixelConfigIsSRGB(GrPixelConfig config) { | 329 static inline bool GrPixelConfigIsSRGB(GrPixelConfig config) { |
323 switch (config) { | 330 switch (config) { |
324 case kSRGBA_8888_GrPixelConfig: | 331 case kSRGBA_8888_GrPixelConfig: |
| 332 case kSBGRA_8888_GrPixelConfig: |
325 return true; | 333 return true; |
326 default: | 334 default: |
327 return false; | 335 return false; |
328 } | 336 } |
329 } | 337 } |
330 | 338 |
331 // Takes a config and returns the equivalent config with the R and B order | 339 // Takes a config and returns the equivalent config with the R and B order |
332 // swapped if such a config exists. Otherwise, kUnknown_GrPixelConfig | 340 // swapped if such a config exists. Otherwise, kUnknown_GrPixelConfig |
333 static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) { | 341 static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) { |
334 switch (config) { | 342 switch (config) { |
335 case kBGRA_8888_GrPixelConfig: | 343 case kBGRA_8888_GrPixelConfig: |
336 return kRGBA_8888_GrPixelConfig; | 344 return kRGBA_8888_GrPixelConfig; |
337 case kRGBA_8888_GrPixelConfig: | 345 case kRGBA_8888_GrPixelConfig: |
338 return kBGRA_8888_GrPixelConfig; | 346 return kBGRA_8888_GrPixelConfig; |
| 347 case kSBGRA_8888_GrPixelConfig: |
| 348 return kSRGBA_8888_GrPixelConfig; |
| 349 case kSRGBA_8888_GrPixelConfig: |
| 350 return kSBGRA_8888_GrPixelConfig; |
339 default: | 351 default: |
340 return kUnknown_GrPixelConfig; | 352 return kUnknown_GrPixelConfig; |
341 } | 353 } |
342 } | 354 } |
343 | 355 |
344 static inline size_t GrBytesPerPixel(GrPixelConfig config) { | 356 static inline size_t GrBytesPerPixel(GrPixelConfig config) { |
345 SkASSERT(!GrPixelConfigIsCompressed(config)); | 357 SkASSERT(!GrPixelConfigIsCompressed(config)); |
346 switch (config) { | 358 switch (config) { |
347 case kAlpha_8_GrPixelConfig: | 359 case kAlpha_8_GrPixelConfig: |
348 return 1; | 360 return 1; |
349 case kRGB_565_GrPixelConfig: | 361 case kRGB_565_GrPixelConfig: |
350 case kRGBA_4444_GrPixelConfig: | 362 case kRGBA_4444_GrPixelConfig: |
351 case kAlpha_half_GrPixelConfig: | 363 case kAlpha_half_GrPixelConfig: |
352 return 2; | 364 return 2; |
353 case kRGBA_8888_GrPixelConfig: | 365 case kRGBA_8888_GrPixelConfig: |
354 case kBGRA_8888_GrPixelConfig: | 366 case kBGRA_8888_GrPixelConfig: |
355 case kSRGBA_8888_GrPixelConfig: | 367 case kSRGBA_8888_GrPixelConfig: |
| 368 case kSBGRA_8888_GrPixelConfig: |
356 return 4; | 369 return 4; |
357 case kRGBA_half_GrPixelConfig: | 370 case kRGBA_half_GrPixelConfig: |
358 return 8; | 371 return 8; |
359 case kRGBA_float_GrPixelConfig: | 372 case kRGBA_float_GrPixelConfig: |
360 return 16; | 373 return 16; |
361 default: | 374 default: |
362 return 0; | 375 return 0; |
363 } | 376 } |
364 } | 377 } |
365 | 378 |
(...skipping 13 matching lines...) Expand all Loading... |
379 case kLATC_GrPixelConfig: | 392 case kLATC_GrPixelConfig: |
380 case kASTC_12x12_GrPixelConfig: | 393 case kASTC_12x12_GrPixelConfig: |
381 case kAlpha_8_GrPixelConfig: | 394 case kAlpha_8_GrPixelConfig: |
382 case kAlpha_half_GrPixelConfig: | 395 case kAlpha_half_GrPixelConfig: |
383 return true; | 396 return true; |
384 default: | 397 default: |
385 return false; | 398 return false; |
386 } | 399 } |
387 } | 400 } |
388 | 401 |
| 402 static inline bool GrAllowSRGBForDestinationPixelConfig(GrPixelConfig config) { |
| 403 switch (config) { |
| 404 case kRGBA_8888_GrPixelConfig: |
| 405 case kBGRA_8888_GrPixelConfig: |
| 406 return false; |
| 407 default: |
| 408 return true; |
| 409 } |
| 410 } |
| 411 |
389 /** | 412 /** |
390 * Optional bitfield flags that can be set on GrSurfaceDesc (below). | 413 * Optional bitfield flags that can be set on GrSurfaceDesc (below). |
391 */ | 414 */ |
392 enum GrSurfaceFlags { | 415 enum GrSurfaceFlags { |
393 kNone_GrSurfaceFlags = 0x0, | 416 kNone_GrSurfaceFlags = 0x0, |
394 /** | 417 /** |
395 * Creates a texture that can be rendered to as a GrRenderTarget. Use | 418 * Creates a texture that can be rendered to as a GrRenderTarget. Use |
396 * GrTexture::asRenderTarget() to access. | 419 * GrTexture::asRenderTarget() to access. |
397 */ | 420 */ |
398 kRenderTarget_GrSurfaceFlag = 0x1, | 421 kRenderTarget_GrSurfaceFlag = 0x1, |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 return 4 * width * height; | 707 return 4 * width * height; |
685 } | 708 } |
686 } | 709 } |
687 | 710 |
688 /** | 711 /** |
689 * This value translates to reseting all the context state for any backend. | 712 * This value translates to reseting all the context state for any backend. |
690 */ | 713 */ |
691 static const uint32_t kAll_GrBackendState = 0xffffffff; | 714 static const uint32_t kAll_GrBackendState = 0xffffffff; |
692 | 715 |
693 #endif | 716 #endif |
OLD | NEW |