return false;
}
-void SkColorFilter::filterSpan16(const uint16_t s[], int count, uint16_t d[])
-{
+void SkColorFilter::filterSpan16(const uint16_t s[], int count, uint16_t d[]) {
SkASSERT(this->getFlags() & SkColorFilter::kHasFilter16_Flag);
SkASSERT(!"missing implementation of SkColorFilter::filterSpan16");
- if (d != s)
+ if (d != s) {
memcpy(d, s, count * sizeof(uint16_t));
+ }
}
SkColor SkColorFilter::filterColor(SkColor c) {
///////////////////////////////////////////////////////////////////////////////
-SkFilterShader::SkFilterShader(SkShader* shader, SkColorFilter* filter)
-{
+SkFilterShader::SkFilterShader(SkShader* shader, SkColorFilter* filter) {
fShader = shader; shader->ref();
fFilter = filter; filter->ref();
}
SkFilterShader::SkFilterShader(SkFlattenableReadBuffer& buffer) :
- INHERITED(buffer)
-{
+ INHERITED(buffer) {
fShader = static_cast<SkShader*>(buffer.readFlattenable());
fFilter = static_cast<SkColorFilter*>(buffer.readFlattenable());
}
-SkFilterShader::~SkFilterShader()
-{
+SkFilterShader::~SkFilterShader() {
fFilter->unref();
fShader->unref();
}
-void SkFilterShader::beginSession()
-{
+void SkFilterShader::beginSession() {
this->INHERITED::beginSession();
fShader->beginSession();
}
-void SkFilterShader::endSession()
-{
+void SkFilterShader::endSession() {
fShader->endSession();
this->INHERITED::endSession();
}
-void SkFilterShader::flatten(SkFlattenableWriteBuffer& buffer)
-{
+void SkFilterShader::flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fShader);
buffer.writeFlattenable(fFilter);
}
-uint32_t SkFilterShader::getFlags()
-{
+uint32_t SkFilterShader::getFlags() {
uint32_t shaderF = fShader->getFlags();
uint32_t filterF = fFilter->getFlags();
// if the filter doesn't support 16bit, clear the matching bit in the shader
- if (!(filterF & SkColorFilter::kHasFilter16_Flag))
+ if (!(filterF & SkColorFilter::kHasFilter16_Flag)) {
shaderF &= ~SkShader::kHasSpan16_Flag;
-
+ }
// if the filter might change alpha, clear the opaque flag in the shader
- if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag))
+ if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) {
shaderF &= ~(SkShader::kOpaqueAlpha_Flag | SkShader::kHasSpan16_Flag);
-
+ }
return shaderF;
}
bool SkFilterShader::setContext(const SkBitmap& device,
const SkPaint& paint,
- const SkMatrix& matrix)
-{
+ const SkMatrix& matrix) {
return this->INHERITED::setContext(device, paint, matrix) &&
fShader->setContext(device, paint, matrix);
}
-void SkFilterShader::shadeSpan(int x, int y, SkPMColor result[], int count)
-{
+void SkFilterShader::shadeSpan(int x, int y, SkPMColor result[], int count) {
fShader->shadeSpan(x, y, result, count);
fFilter->filterSpan(result, count, result);
}
-void SkFilterShader::shadeSpan16(int x, int y, uint16_t result[], int count)
-{
+void SkFilterShader::shadeSpan16(int x, int y, uint16_t result[], int count) {
SkASSERT(fShader->getFlags() & SkShader::kHasSpan16_Flag);
SkASSERT(fFilter->getFlags() & SkColorFilter::kHasFilter16_Flag);
#include "SkDraw.h"
#include "SkRegion.h"
-bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*)
-{
+bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&,
+ SkIPoint*) {
return false;
}
bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
const SkRegion& clip, SkBounder* bounder,
- SkBlitter* blitter)
-{
+ SkBlitter* blitter) {
SkMask srcM, dstM;
if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), this, &matrix, &srcM,
- SkMask::kComputeBoundsAndRenderImage_CreateMode))
- {
+ SkMask::kComputeBoundsAndRenderImage_CreateMode)) {
return false;
}
SkAutoMaskImage autoSrc(&srcM, false);
- if (!this->filterMask(&dstM, srcM, matrix, NULL))
+ if (!this->filterMask(&dstM, srcM, matrix, NULL)) {
return false;
+ }
SkAutoMaskImage autoDst(&dstM, false);
SkRegion::Cliperator clipper(clip, dstM.fBounds);
- if (!clipper.done() && (bounder == NULL || bounder->doIRect(dstM.fBounds)))
- {
+ if (!clipper.done() && (bounder == NULL || bounder->doIRect(dstM.fBounds))) {
const SkIRect& cr = clipper.rect();
do {
blitter->blitMask(dstM, cr);
#include "SkPath.h"
#include "SkBuffer.h"
-//////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1)
- : fPE0(pe0), fPE1(pe1)
-{
+ : fPE0(pe0), fPE1(pe1) {
SkASSERT(pe0);
SkASSERT(pe1);
fPE0->ref();
fPE1->ref();
}
-SkPairPathEffect::~SkPairPathEffect()
-{
+SkPairPathEffect::~SkPairPathEffect() {
fPE0->unref();
fPE1->unref();
}
/*
Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
*/
-void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer)
-{
+void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
buffer.writeFlattenable(fPE0);
buffer.writeFlattenable(fPE1);
}
-SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer)
-{
+SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer) {
fPE0 = (SkPathEffect*)buffer.readFlattenable();
fPE1 = (SkPathEffect*)buffer.readFlattenable();
}
-//////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
-bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
-{
+bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
+ SkScalar* width) {
SkPath tmp;
const SkPath* ptr = &src;
- if (fPE1->filterPath(&tmp, src, width))
+ if (fPE1->filterPath(&tmp, src, width)) {
ptr = &tmp;
+ }
return fPE0->filterPath(dst, *ptr, width);
}
-//////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
-bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
-{
+bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
+ SkScalar* width) {
// use bit-or so that we always call both, even if the first one succeeds
return fPE0->filterPath(dst, src, width) | fPE1->filterPath(dst, src, width);
}
-/////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
#include "SkStroke.h"
SkStrokePathEffect::SkStrokePathEffect(const SkPaint& paint)
: fWidth(paint.getStrokeWidth()), fMiter(paint.getStrokeMiter()),
- fStyle(SkToU8(paint.getStyle())), fJoin(SkToU8(paint.getStrokeJoin())), fCap(SkToU8(paint.getStrokeCap()))
-{
+ fStyle(SkToU8(paint.getStyle())), fJoin(SkToU8(paint.getStrokeJoin())),
+ fCap(SkToU8(paint.getStrokeCap())) {
}
-SkStrokePathEffect::SkStrokePathEffect(SkScalar width, SkPaint::Style style, SkPaint::Join join, SkPaint::Cap cap, SkScalar miter)
- : fWidth(width), fMiter(miter), fStyle(SkToU8(style)), fJoin(SkToU8(join)), fCap(SkToU8(cap))
-{
- if (miter < 0) // signal they want the default
+SkStrokePathEffect::SkStrokePathEffect(SkScalar width, SkPaint::Style style,
+ SkPaint::Join join, SkPaint::Cap cap, SkScalar miter)
+ : fWidth(width), fMiter(miter), fStyle(SkToU8(style)),
+ fJoin(SkToU8(join)), fCap(SkToU8(cap)) {
+ if (miter < 0) { // signal they want the default
fMiter = SK_DefaultMiterLimit;
+ }
}
-bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
-{
- if (fWidth < 0 || fStyle == SkPaint::kFill_Style)
+bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src,
+ SkScalar* width) {
+ if (fWidth < 0 || fStyle == SkPaint::kFill_Style) {
return false;
+ }
- if (fStyle == SkPaint::kStroke_Style && fWidth == 0) // hairline
- {
+ if (fStyle == SkPaint::kStroke_Style && fWidth == 0) { // hairline
*width = 0;
return true;
}
return true;
}
-SkFlattenable::Factory SkStrokePathEffect::getFactory()
-{
+SkFlattenable::Factory SkStrokePathEffect::getFactory() {
return CreateProc;
}
-SkFlattenable* SkStrokePathEffect::CreateProc(SkFlattenableReadBuffer& buffer)
-{
+SkFlattenable* SkStrokePathEffect::CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkStrokePathEffect, (buffer));
}
-void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer)
-{
+void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
buffer.writeScalar(fWidth);
buffer.writeScalar(fMiter);
buffer.write8(fStyle);
buffer.write8(fCap);
}
-SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer)
-{
+SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) {
fWidth = buffer.readScalar();
fMiter = buffer.readScalar();
fStyle = buffer.readU8();
fCap = buffer.readU8();
}
-
bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix,
const SkIRect* clipBounds, SkMaskFilter* filter,
- SkMask* mask, SkMask::CreateMode mode)
-{
+ SkMask* mask, SkMask::CreateMode mode) {
SkIRect storage;
- if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode)
- {
+ if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode) {
SkIPoint margin;
SkMask srcM, dstM;
srcM.fFormat = SkMask::kA8_Format;
srcM.fBounds.set(0, 0, 1, 1);
srcM.fImage = NULL;
- if (!filter->filterMask(&dstM, srcM, matrix, &margin))
+ if (!filter->filterMask(&dstM, srcM, matrix, &margin)) {
return false;
-
+ }
storage = *clipBounds;
storage.inset(-margin.fX, -margin.fY);
clipBounds = &storage;
*/
bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix,
const SkIRect* clipBounds,
- SkMask* mask, SkMask::CreateMode mode)
-{
+ SkMask* mask, SkMask::CreateMode mode) {
SkPath devPath;
fillPath.transform(matrix, &devPath);