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); |
40 | 51 |
41 GrPixelConfig config; | 52 return configMap[fmt]; |
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; | |
67 } | 53 } |
68 | 54 |
69 #if GR_COMPRESS_ALPHA_MASK | 55 #if GR_COMPRESS_ALPHA_MASK |
70 static bool choose_compressed_fmt(const GrDrawTargetCaps* caps, | 56 static bool choose_compressed_fmt(const GrDrawTargetCaps* caps, |
71 SkTextureCompressor::Format *fmt) { | 57 SkTextureCompressor::Format *fmt) { |
72 if (NULL == fmt) { | 58 if (NULL == fmt) { |
73 return false; | 59 return false; |
74 } | 60 } |
75 | 61 |
76 // We can't use scratch textures without the ability to update | 62 // We can't use scratch textures without the ability to update |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 maskMatrix.preConcat(drawState->getViewMatrix()); | 317 maskMatrix.preConcat(drawState->getViewMatrix()); |
332 | 318 |
333 drawState->addCoverageEffect( | 319 drawState->addCoverageEffect( |
334 GrSimpleTextureEffect::Create(texture, | 320 GrSimpleTextureEffect::Create(texture, |
335 maskMatrix, | 321 maskMatrix, |
336 GrTextureParams::kNone_Fi
lterMode, | 322 GrTextureParams::kNone_Fi
lterMode, |
337 kPosition_GrCoordSet))->u
nref(); | 323 kPosition_GrCoordSet))->u
nref(); |
338 | 324 |
339 target->drawSimpleRect(dstRect); | 325 target->drawSimpleRect(dstRect); |
340 } | 326 } |
OLD | NEW |