2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "SkStippleMaskFilter.h"
11 bool SkStippleMaskFilter::filterMask(SkMask* dst,
13 const SkMatrix& matrix,
14 SkIPoint* margin) const {
16 if (src.fFormat != SkMask::kA8_Format) {
20 dst->fBounds = src.fBounds;
21 dst->fRowBytes = dst->fBounds.width();
22 dst->fFormat = SkMask::kA8_Format;
25 if (NULL != src.fImage) {
26 size_t dstSize = dst->computeImageSize();
28 return false; // too big to allocate, abort
31 dst->fImage = SkMask::AllocImage(dstSize);
33 uint8_t* srcScanLine = src.fImage;
34 uint8_t* scanline = dst->fImage;
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;
40 scanline += dst->fRowBytes;
41 srcScanLine += src.fRowBytes;
48 #ifndef SK_IGNORE_TO_STRING
49 void SkStippleMaskFilter::toString(SkString* str) const {
50 str->append("SkStippleMaskFilter: ()");