OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkAAClip.h" | 9 #include "SkAAClip.h" |
10 #include "SkAtomics.h" | 10 #include "SkAtomics.h" |
(...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 | 2049 |
2050 static inline uint16_t mergeOne(uint16_t value, unsigned alpha) { | 2050 static inline uint16_t mergeOne(uint16_t value, unsigned alpha) { |
2051 unsigned r = SkGetPackedR16(value); | 2051 unsigned r = SkGetPackedR16(value); |
2052 unsigned g = SkGetPackedG16(value); | 2052 unsigned g = SkGetPackedG16(value); |
2053 unsigned b = SkGetPackedB16(value); | 2053 unsigned b = SkGetPackedB16(value); |
2054 return SkPackRGB16(SkMulDiv255Round(r, alpha), | 2054 return SkPackRGB16(SkMulDiv255Round(r, alpha), |
2055 SkMulDiv255Round(g, alpha), | 2055 SkMulDiv255Round(g, alpha), |
2056 SkMulDiv255Round(b, alpha)); | 2056 SkMulDiv255Round(b, alpha)); |
2057 } | 2057 } |
2058 | 2058 |
2059 template <typename T> void mergeT(const T* SK_RESTRICT src, int srcN, | 2059 template <typename T> |
2060 const uint8_t* SK_RESTRICT row, int rowN, | 2060 void mergeT(const void* inSrc, int srcN, const uint8_t* SK_RESTRICT row, int row
N, void* inDst) { |
2061 T* SK_RESTRICT dst) { | 2061 const T* SK_RESTRICT src = static_cast<const T*>(inSrc); |
| 2062 T* SK_RESTRICT dst = static_cast<T*>(inDst); |
2062 for (;;) { | 2063 for (;;) { |
2063 SkASSERT(rowN > 0); | 2064 SkASSERT(rowN > 0); |
2064 SkASSERT(srcN > 0); | 2065 SkASSERT(srcN > 0); |
2065 | 2066 |
2066 int n = SkMin32(rowN, srcN); | 2067 int n = SkMin32(rowN, srcN); |
2067 unsigned rowA = row[1]; | 2068 unsigned rowA = row[1]; |
2068 if (0xFF == rowA) { | 2069 if (0xFF == rowA) { |
2069 small_memcpy(dst, src, n * sizeof(T)); | 2070 small_memcpy(dst, src, n * sizeof(T)); |
2070 } else if (0 == rowA) { | 2071 } else if (0 == rowA) { |
2071 small_bzero(dst, n * sizeof(T)); | 2072 small_bzero(dst, n * sizeof(T)); |
(...skipping 15 matching lines...) Expand all Loading... |
2087 rowN = row[0]; | 2088 rowN = row[0]; |
2088 } | 2089 } |
2089 } | 2090 } |
2090 | 2091 |
2091 static MergeAAProc find_merge_aa_proc(SkMask::Format format) { | 2092 static MergeAAProc find_merge_aa_proc(SkMask::Format format) { |
2092 switch (format) { | 2093 switch (format) { |
2093 case SkMask::kBW_Format: | 2094 case SkMask::kBW_Format: |
2094 SkDEBUGFAIL("unsupported"); | 2095 SkDEBUGFAIL("unsupported"); |
2095 return nullptr; | 2096 return nullptr; |
2096 case SkMask::kA8_Format: | 2097 case SkMask::kA8_Format: |
2097 case SkMask::k3D_Format: { | 2098 case SkMask::k3D_Format: |
2098 void (*proc8)(const uint8_t*, int, const uint8_t*, int, uint8_t*) =
mergeT; | 2099 return mergeT<uint8_t> ; |
2099 return (MergeAAProc)proc8; | 2100 case SkMask::kLCD16_Format: |
2100 } | 2101 return mergeT<uint16_t>; |
2101 case SkMask::kLCD16_Format: { | |
2102 void (*proc16)(const uint16_t*, int, const uint8_t*, int, uint16_t*)
= mergeT; | |
2103 return (MergeAAProc)proc16; | |
2104 } | |
2105 default: | 2102 default: |
2106 SkDEBUGFAIL("unsupported"); | 2103 SkDEBUGFAIL("unsupported"); |
2107 return nullptr; | 2104 return nullptr; |
2108 } | 2105 } |
2109 } | 2106 } |
2110 | 2107 |
2111 static U8CPU bit2byte(int bitInAByte) { | 2108 static U8CPU bit2byte(int bitInAByte) { |
2112 SkASSERT(bitInAByte <= 0xFF); | 2109 SkASSERT(bitInAByte <= 0xFF); |
2113 // negation turns any non-zero into 0xFFFFFF??, so we just shift down | 2110 // negation turns any non-zero into 0xFFFFFF??, so we just shift down |
2114 // some value >= 8 to get a full FF value | 2111 // some value >= 8 to get a full FF value |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2215 rowMask.fBounds.fBottom = y + 1; | 2212 rowMask.fBounds.fBottom = y + 1; |
2216 fBlitter->blitMask(rowMask, rowMask.fBounds); | 2213 fBlitter->blitMask(rowMask, rowMask.fBounds); |
2217 src = (const void*)((const char*)src + srcRB); | 2214 src = (const void*)((const char*)src + srcRB); |
2218 } while (++y < localStopY); | 2215 } while (++y < localStopY); |
2219 } while (y < stopY); | 2216 } while (y < stopY); |
2220 } | 2217 } |
2221 | 2218 |
2222 const SkPixmap* SkAAClipBlitter::justAnOpaqueColor(uint32_t* value) { | 2219 const SkPixmap* SkAAClipBlitter::justAnOpaqueColor(uint32_t* value) { |
2223 return nullptr; | 2220 return nullptr; |
2224 } | 2221 } |
OLD | NEW |