OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "GrSWMaskHelper.h" | 8 #include "GrSWMaskHelper.h" |
9 | 9 |
10 #include "GrDrawState.h" | 10 #include "GrDrawState.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 SkXfermode::kSrcOver_Mode, // kUnion_Op | 30 SkXfermode::kSrcOver_Mode, // kUnion_Op |
31 SkXfermode::kXor_Mode, // kXOR_Op | 31 SkXfermode::kXor_Mode, // kXOR_Op |
32 SkXfermode::kClear_Mode, // kReverseDifference_Op | 32 SkXfermode::kClear_Mode, // kReverseDifference_Op |
33 SkXfermode::kSrc_Mode, // kReplace_Op | 33 SkXfermode::kSrc_Mode, // kReplace_Op |
34 }; | 34 }; |
35 | 35 |
36 return modeMap[op]; | 36 return modeMap[op]; |
37 } | 37 } |
38 | 38 |
39 static inline GrPixelConfig fmt_to_config(SkTextureCompressor::Format fmt) { | 39 static inline GrPixelConfig fmt_to_config(SkTextureCompressor::Format fmt) { |
40 static const GrPixelConfig configMap[] = { | |
41 kLATC_GrPixelConfig, // kLATC_Format, | |
42 kR11_EAC_GrPixelConfig, // kR11_EAC_Format, | |
43 kETC1_GrPixelConfig, // kETC1_Format, | |
44 kASTC_12x12_GrPixelConfig // kASTC_12x12_Format, | |
45 }; | |
46 GR_STATIC_ASSERT(0 == SkTextureCompressor::kLATC_Format); | |
47 GR_STATIC_ASSERT(1 == SkTextureCompressor::kR11_EAC_Format); | |
48 GR_STATIC_ASSERT(2 == SkTextureCompressor::kETC1_Format); | |
49 GR_STATIC_ASSERT(3 == SkTextureCompressor::kASTC_12x12_Format); | |
50 GR_STATIC_ASSERT(SK_ARRAY_COUNT(configMap) == SkTextureCompressor::kFormatCn
t); | |
51 | 40 |
52 return configMap[fmt]; | 41 GrPixelConfig config; |
| 42 switch (fmt) { |
| 43 case SkTextureCompressor::kLATC_Format: |
| 44 config = kLATC_GrPixelConfig; |
| 45 break; |
| 46 |
| 47 case SkTextureCompressor::kR11_EAC_Format: |
| 48 config = kR11_EAC_GrPixelConfig; |
| 49 break; |
| 50 |
| 51 case SkTextureCompressor::kASTC_12x12_Format: |
| 52 config = kASTC_12x12_GrPixelConfig; |
| 53 break; |
| 54 |
| 55 case SkTextureCompressor::kETC1_Format: |
| 56 config = kETC1_GrPixelConfig; |
| 57 break; |
| 58 |
| 59 default: |
| 60 SkDEBUGFAIL("No GrPixelConfig for compression format!"); |
| 61 // Best guess |
| 62 config = kAlpha_8_GrPixelConfig; |
| 63 break; |
| 64 } |
| 65 |
| 66 return config; |
53 } | 67 } |
54 | 68 |
55 #if GR_COMPRESS_ALPHA_MASK | 69 #if GR_COMPRESS_ALPHA_MASK |
56 static bool choose_compressed_fmt(const GrDrawTargetCaps* caps, | 70 static bool choose_compressed_fmt(const GrDrawTargetCaps* caps, |
57 SkTextureCompressor::Format *fmt) { | 71 SkTextureCompressor::Format *fmt) { |
58 if (NULL == fmt) { | 72 if (NULL == fmt) { |
59 return false; | 73 return false; |
60 } | 74 } |
61 | 75 |
62 // We can't use scratch textures without the ability to update | 76 // We can't use scratch textures without the ability to update |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 maskMatrix.preConcat(drawState->getViewMatrix()); | 331 maskMatrix.preConcat(drawState->getViewMatrix()); |
318 | 332 |
319 drawState->addCoverageEffect( | 333 drawState->addCoverageEffect( |
320 GrSimpleTextureEffect::Create(texture, | 334 GrSimpleTextureEffect::Create(texture, |
321 maskMatrix, | 335 maskMatrix, |
322 GrTextureParams::kNone_Fi
lterMode, | 336 GrTextureParams::kNone_Fi
lterMode, |
323 kPosition_GrCoordSet))->u
nref(); | 337 kPosition_GrCoordSet))->u
nref(); |
324 | 338 |
325 target->drawSimpleRect(dstRect); | 339 target->drawSimpleRect(dstRect); |
326 } | 340 } |
OLD | NEW |