1
/* libs/graphics/effects/Sk2DPathEffect.cpp
3
** Copyright 2006, The Android Open Source Project
5
** Licensed under the Apache License, Version 2.0 (the "License");
6
** you may not use this file except in compliance with the License.
7
** You may obtain a copy of the License at
9
** http://www.apache.org/licenses/LICENSE-2.0
11
** Unless required by applicable law or agreed to in writing, software
12
** distributed under the License is distributed on an "AS IS" BASIS,
13
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
** See the License for the specific language governing permissions and
15
** limitations under the License.
18
#include "Sk2DPathEffect.h"
19
#include "SkBlitter.h"
23
class Sk2DPathEffectBlitter : public SkBlitter {
25
Sk2DPathEffectBlitter(Sk2DPathEffect* pe, SkPath* dst)
28
virtual void blitH(int x, int y, int count)
30
fPE->nextSpan(x, y, count, fDst);
37
////////////////////////////////////////////////////////////////////////////////////
39
Sk2DPathEffect::Sk2DPathEffect(const SkMatrix& mat) : fMatrix(mat)
41
mat.invert(&fInverse);
44
bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
46
Sk2DPathEffectBlitter blitter(this, dst);
50
src.transform(fInverse, &tmp);
51
tmp.getBounds().round(&ir);
53
// need to pass a clip to fillpath, required for inverse filltypes,
54
// even though those do not make sense for this patheffect
58
SkScan::FillPath(tmp, clip, &blitter);
64
void Sk2DPathEffect::nextSpan(int x, int y, int count, SkPath* path)
66
const SkMatrix& mat = this->getMatrix();
69
src.set(SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf);
71
mat.mapPoints(&dst, &src, 1);
72
this->next(dst, x++, y, path);
74
} while (--count > 0);
77
void Sk2DPathEffect::begin(const SkIRect& uvBounds, SkPath* dst) {}
78
void Sk2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) {}
79
void Sk2DPathEffect::end(SkPath* dst) {}
81
////////////////////////////////////////////////////////////////////////////////
83
void Sk2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer)
85
buffer.writeMul4(&fMatrix, sizeof(fMatrix));
88
Sk2DPathEffect::Sk2DPathEffect(SkFlattenableReadBuffer& buffer)
90
buffer.read(&fMatrix, sizeof(fMatrix));
91
fMatrix.invert(&fInverse);
94
SkFlattenable::Factory Sk2DPathEffect::getFactory()
99
SkFlattenable* Sk2DPathEffect::CreateProc(SkFlattenableReadBuffer& buffer)
101
return SkNEW_ARGS(Sk2DPathEffect, (buffer));