diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-19 20:11:25 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-19 20:11:25 +0000 |
commit | feb8cc870df055099c6fcdfebdd6c1486bd91b27 (patch) | |
tree | c7de0dd3283e393200b3b060dec69737484b6210 | |
parent | 6b7aee387d3b4b2df5894b51fa1c0baf649c6540 (diff) |
code style
git-svn-id: http://skia.googlecode.com/svn/trunk@1153 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/core/SkColorFilter.cpp | 44 | ||||
-rw-r--r-- | src/core/SkMaskFilter.cpp | 16 | ||||
-rw-r--r-- | src/core/SkPathEffect.cpp | 68 | ||||
-rw-r--r-- | src/core/SkRasterizer.cpp | 13 |
4 files changed, 60 insertions, 81 deletions
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp index 0508be78e6..6e0746f0f0 100644 --- a/src/core/SkColorFilter.cpp +++ b/src/core/SkColorFilter.cpp @@ -23,13 +23,13 @@ bool SkColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) { 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) { @@ -40,76 +40,66 @@ 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); diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp index 56fff9763e..a2782615a8 100644 --- a/src/core/SkMaskFilter.cpp +++ b/src/core/SkMaskFilter.cpp @@ -22,33 +22,31 @@ #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); diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp index 29058958e3..c3a24fc049 100644 --- a/src/core/SkPathEffect.cpp +++ b/src/core/SkPathEffect.cpp @@ -19,19 +19,17 @@ #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(); } @@ -39,62 +37,63 @@ SkPairPathEffect::~SkPairPathEffect() /* 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; } @@ -111,18 +110,15 @@ bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* wi 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); @@ -130,8 +126,7 @@ void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer) buffer.write8(fCap); } -SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) -{ +SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) { fWidth = buffer.readScalar(); fMiter = buffer.readScalar(); fStyle = buffer.readU8(); @@ -139,4 +134,3 @@ SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) fCap = buffer.readU8(); } - diff --git a/src/core/SkRasterizer.cpp b/src/core/SkRasterizer.cpp index f1d087df55..7701df5ea1 100644 --- a/src/core/SkRasterizer.cpp +++ b/src/core/SkRasterizer.cpp @@ -25,21 +25,19 @@ SkRasterizer::SkRasterizer(SkFlattenableReadBuffer&) {} 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; @@ -52,8 +50,7 @@ bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix, */ 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); |