Line data Source code
1 : /*
2 : * Copyright 2006 The Android Open Source Project
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 :
9 : #include "SkRasterizer.h"
10 : #include "SkDraw.h"
11 : #include "SkMaskFilter.h"
12 : #include "SkPath.h"
13 : #include "SkStrokeRec.h"
14 :
15 0 : bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix,
16 : const SkIRect* clipBounds, SkMaskFilter* filter,
17 : SkMask* mask, SkMask::CreateMode mode) const {
18 : SkIRect storage;
19 :
20 0 : if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode) {
21 : SkIPoint margin;
22 0 : SkMask srcM, dstM;
23 :
24 0 : srcM.fFormat = SkMask::kA8_Format;
25 0 : srcM.fBounds.set(0, 0, 1, 1);
26 0 : if (!filter->filterMask(&dstM, srcM, matrix, &margin)) {
27 0 : return false;
28 : }
29 0 : storage = clipBounds->makeOutset(margin.fX, margin.fY);
30 0 : clipBounds = &storage;
31 : }
32 :
33 0 : return this->onRasterize(fillPath, matrix, clipBounds, mask, mode);
34 : }
35 :
36 : /* Our default implementation of the virtual method just scan converts
37 : */
38 0 : bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix,
39 : const SkIRect* clipBounds,
40 : SkMask* mask, SkMask::CreateMode mode) const {
41 0 : SkPath devPath;
42 :
43 0 : fillPath.transform(matrix, &devPath);
44 : return SkDraw::DrawToMask(devPath, clipBounds, nullptr, nullptr, mask, mode,
45 0 : SkStrokeRec::kFill_InitStyle);
46 : }
|