• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
SkRasterizer(SkFlattenableReadBuffer &)16 SkRasterizer::SkRasterizer(SkFlattenableReadBuffer&) {}
17 
rasterize(const SkPath & fillPath,const SkMatrix & matrix,const SkIRect * clipBounds,SkMaskFilter * filter,SkMask * mask,SkMask::CreateMode mode)18 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     if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode) {
24         SkIPoint    margin;
25         SkMask      srcM, dstM;
26 
27         srcM.fFormat = SkMask::kA8_Format;
28         srcM.fBounds.set(0, 0, 1, 1);
29         srcM.fImage = NULL;
30         if (!filter->filterMask(&dstM, srcM, matrix, &margin)) {
31             return false;
32         }
33         storage = *clipBounds;
34         storage.inset(-margin.fX, -margin.fY);
35         clipBounds = &storage;
36     }
37 
38     return this->onRasterize(fillPath, matrix, clipBounds, mask, mode);
39 }
40 
41 /*  Our default implementation of the virtual method just scan converts
42 */
onRasterize(const SkPath & fillPath,const SkMatrix & matrix,const SkIRect * clipBounds,SkMask * mask,SkMask::CreateMode mode)43 bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix,
44                              const SkIRect* clipBounds,
45                              SkMask* mask, SkMask::CreateMode mode) {
46     SkPath  devPath;
47 
48     fillPath.transform(matrix, &devPath);
49     return SkDraw::DrawToMask(devPath, clipBounds, NULL, NULL, mask, mode);
50 }
51 
52