1 :
2 : /*
3 : * Copyright 2006 The Android Open Source Project
4 : *
5 : * Use of this source code is governed by a BSD-style license that can be
6 : * found in the LICENSE file.
7 : */
8 :
9 :
10 : #include "SkRasterizer.h"
11 : #include "SkDraw.h"
12 : #include "SkMaskFilter.h"
13 : #include "SkPath.h"
14 :
15 : // do nothing for now, since we don't store anything at flatten time
16 0 : SkRasterizer::SkRasterizer(SkFlattenableReadBuffer&) {}
17 :
18 0 : bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix,
19 : const SkIRect* clipBounds, SkMaskFilter* filter,
20 : SkMask* mask, SkMask::CreateMode mode) {
21 : SkIRect storage;
22 :
23 0 : if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode) {
24 : SkIPoint margin;
25 : SkMask srcM, dstM;
26 :
27 0 : srcM.fFormat = SkMask::kA8_Format;
28 0 : srcM.fBounds.set(0, 0, 1, 1);
29 0 : srcM.fImage = NULL;
30 0 : if (!filter->filterMask(&dstM, srcM, matrix, &margin)) {
31 0 : return false;
32 : }
33 0 : storage = *clipBounds;
34 0 : storage.inset(-margin.fX, -margin.fY);
35 0 : clipBounds = &storage;
36 : }
37 :
38 0 : return this->onRasterize(fillPath, matrix, clipBounds, mask, mode);
39 : }
40 :
41 : /* Our default implementation of the virtual method just scan converts
42 : */
43 0 : bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix,
44 : const SkIRect* clipBounds,
45 : SkMask* mask, SkMask::CreateMode mode) {
46 0 : SkPath devPath;
47 :
48 0 : fillPath.transform(matrix, &devPath);
49 0 : return SkDraw::DrawToMask(devPath, clipBounds, NULL, NULL, mask, mode);
50 : }
51 :
|