1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/core/SkRasterizer.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#include "SkRasterizer.h" 1.14 +#include "SkDraw.h" 1.15 +#include "SkMaskFilter.h" 1.16 +#include "SkPath.h" 1.17 + 1.18 +bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix, 1.19 + const SkIRect* clipBounds, SkMaskFilter* filter, 1.20 + SkMask* mask, SkMask::CreateMode mode) const { 1.21 + SkIRect storage; 1.22 + 1.23 + if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode) { 1.24 + SkIPoint margin; 1.25 + SkMask srcM, dstM; 1.26 + 1.27 + srcM.fFormat = SkMask::kA8_Format; 1.28 + srcM.fBounds.set(0, 0, 1, 1); 1.29 + srcM.fImage = NULL; 1.30 + if (!filter->filterMask(&dstM, srcM, matrix, &margin)) { 1.31 + return false; 1.32 + } 1.33 + storage = *clipBounds; 1.34 + storage.inset(-margin.fX, -margin.fY); 1.35 + clipBounds = &storage; 1.36 + } 1.37 + 1.38 + return this->onRasterize(fillPath, matrix, clipBounds, mask, mode); 1.39 +} 1.40 + 1.41 +/* Our default implementation of the virtual method just scan converts 1.42 +*/ 1.43 +bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix, 1.44 + const SkIRect* clipBounds, 1.45 + SkMask* mask, SkMask::CreateMode mode) const { 1.46 + SkPath devPath; 1.47 + 1.48 + fillPath.transform(matrix, &devPath); 1.49 + return SkDraw::DrawToMask(devPath, clipBounds, NULL, NULL, mask, mode, 1.50 + SkPaint::kFill_Style); 1.51 +}