1 /* libs/graphics/sgl/SkMaskFilter.cpp
2 **
3 ** Copyright 2006, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18 #include "SkMaskFilter.h"
19 #include "SkBlitter.h"
20 #include "SkBounder.h"
21 #include "SkBuffer.h"
22 #include "SkDraw.h"
23 #include "SkRegion.h"
24
filterMask(SkMask *,const SkMask &,const SkMatrix &,SkIPoint *)25 bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*)
26 {
27 return false;
28 }
29
filterPath(const SkPath & devPath,const SkMatrix & matrix,const SkRegion & clip,SkBounder * bounder,SkBlitter * blitter)30 bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
31 const SkRegion& clip, SkBounder* bounder,
32 SkBlitter* blitter)
33 {
34 SkMask srcM, dstM;
35
36 if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), this, &matrix, &srcM,
37 SkMask::kComputeBoundsAndRenderImage_CreateMode))
38 {
39 return false;
40 }
41
42 SkAutoMaskImage autoSrc(&srcM, false);
43
44 if (!this->filterMask(&dstM, srcM, matrix, NULL))
45 return false;
46
47 SkAutoMaskImage autoDst(&dstM, false);
48 SkRegion::Cliperator clipper(clip, dstM.fBounds);
49
50 if (!clipper.done() && (bounder == NULL || bounder->doIRect(dstM.fBounds)))
51 {
52 const SkIRect& cr = clipper.rect();
53 do {
54 blitter->blitMask(dstM, cr);
55 clipper.next();
56 } while (!clipper.done());
57 }
58
59 return true;
60 }
61
62
63