OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2012 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #include "SkStippleMaskFilter.h" | |
9 #include "SkString.h" | |
10 | |
11 bool SkStippleMaskFilter::filterMask(SkMask* dst, | |
12 const SkMask& src, | |
13 const SkMatrix& matrix, | |
14 SkIPoint* margin) const { | |
15 | |
16 if (src.fFormat != SkMask::kA8_Format) { | |
17 return false; | |
18 } | |
19 | |
20 dst->fBounds = src.fBounds; | |
21 dst->fRowBytes = dst->fBounds.width(); | |
22 dst->fFormat = SkMask::kA8_Format; | |
23 dst->fImage = NULL; | |
24 | |
25 if (NULL != src.fImage) { | |
26 size_t dstSize = dst->computeImageSize(); | |
27 if (0 == dstSize) { | |
28 return false; // too big to allocate, abort | |
29 } | |
30 | |
31 dst->fImage = SkMask::AllocImage(dstSize); | |
32 | |
33 uint8_t* srcScanLine = src.fImage; | |
34 uint8_t* scanline = dst->fImage; | |
35 | |
36 for (int y = 0; y < src.fBounds.height(); ++y) { | |
37 for (int x = 0; x < src.fBounds.width(); ++x) { | |
38 scanline[x] = srcScanLine[x] && ((x+y) & 0x1) ? 0xFF : 0x00; | |
39 } | |
40 scanline += dst->fRowBytes; | |
41 srcScanLine += src.fRowBytes; | |
42 } | |
43 } | |
44 | |
45 return true; | |
46 } | |
47 | |
48 #ifndef SK_IGNORE_TO_STRING | |
49 void SkStippleMaskFilter::toString(SkString* str) const { | |
50 str->append("SkStippleMaskFilter: ()"); | |
51 } | |
52 #endif | |
OLD | NEW |