michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "SkRasterizer.h" michael@0: #include "SkDraw.h" michael@0: #include "SkMaskFilter.h" michael@0: #include "SkPath.h" michael@0: michael@0: bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix, michael@0: const SkIRect* clipBounds, SkMaskFilter* filter, michael@0: SkMask* mask, SkMask::CreateMode mode) const { michael@0: SkIRect storage; michael@0: michael@0: if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode) { michael@0: SkIPoint margin; michael@0: SkMask srcM, dstM; michael@0: michael@0: srcM.fFormat = SkMask::kA8_Format; michael@0: srcM.fBounds.set(0, 0, 1, 1); michael@0: srcM.fImage = NULL; michael@0: if (!filter->filterMask(&dstM, srcM, matrix, &margin)) { michael@0: return false; michael@0: } michael@0: storage = *clipBounds; michael@0: storage.inset(-margin.fX, -margin.fY); michael@0: clipBounds = &storage; michael@0: } michael@0: michael@0: return this->onRasterize(fillPath, matrix, clipBounds, mask, mode); michael@0: } michael@0: michael@0: /* Our default implementation of the virtual method just scan converts michael@0: */ michael@0: bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix, michael@0: const SkIRect* clipBounds, michael@0: SkMask* mask, SkMask::CreateMode mode) const { michael@0: SkPath devPath; michael@0: michael@0: fillPath.transform(matrix, &devPath); michael@0: return SkDraw::DrawToMask(devPath, clipBounds, NULL, NULL, mask, mode, michael@0: SkPaint::kFill_Style); michael@0: }