diff options
author | skia.committer@gmail.com <skia.committer@gmail.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-13 07:00:56 +0000 |
---|---|---|
committer | skia.committer@gmail.com <skia.committer@gmail.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-13 07:00:56 +0000 |
commit | fa1bd5f86ceea6cfa8303594730125ad2853d87b (patch) | |
tree | 8a15059b32d12472bf59f40aa17cefe2f8a9546d | |
parent | f4db3a0db827e68eead577041ba74c4bd0414e72 (diff) |
Sanitizing source files in Housekeeper-Nightly
git-svn-id: http://skia.googlecode.com/svn/trunk@10059 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gm/downsamplebitmap.cpp | 12 | ||||
-rw-r--r-- | src/core/SkBitmapFilter.cpp | 6 | ||||
-rw-r--r-- | src/core/SkBitmapFilter.h | 2 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 106 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.h | 12 | ||||
-rw-r--r-- | src/gpu/GrAAHairLinePathRenderer.cpp | 1 | ||||
-rw-r--r-- | tests/FitsInTest.cpp | 1 | ||||
-rw-r--r-- | tests/UtilsTest.cpp | 2 |
8 files changed, 70 insertions, 72 deletions
diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp index ad77dd68d4..a59e5b85df 100644 --- a/gm/downsamplebitmap.cpp +++ b/gm/downsamplebitmap.cpp @@ -22,7 +22,7 @@ public: SkBitmap fBM; SkString fName; bool fBitmapMade; - + DownsampleBitmapGM() { this->setBGColor(0xFFDDDDDD); @@ -42,7 +42,7 @@ protected: make_bitmap_wrapper(); return SkISize::Make(4 * fBM.width(), fBM.height()); } - + void make_bitmap_wrapper() { if (!fBitmapMade) { fBitmapMade = true; @@ -54,15 +54,15 @@ protected: virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { make_bitmap_wrapper(); - + int curX = 0; int curWidth; float curScale = 1; do { - + SkMatrix matrix; matrix.setScale( curScale, curScale ); - + SkPaint paint; paint.setFilterBitmap(true); paint.setFlags( paint.getFlags() | SkPaint::kHighQualityFilterBitmap_Flag ); @@ -71,7 +71,7 @@ protected: canvas->translate( (SkScalar) curX, 0.f ); canvas->drawBitmapMatrix( fBM, matrix, &paint ); canvas->restore(); - + curWidth = (int) (fBM.width() * curScale + 2); curX += curWidth; curScale *= 0.75f; diff --git a/src/core/SkBitmapFilter.cpp b/src/core/SkBitmapFilter.cpp index 91c2beae40..434ea9a536 100644 --- a/src/core/SkBitmapFilter.cpp +++ b/src/core/SkBitmapFilter.cpp @@ -152,7 +152,7 @@ SkBitmapProcState::chooseBitmapFilterProc() { if (fFilterQuality != kHQ_BitmapFilter) { return NULL; } - + if (fAlphaScale != 256) { return NULL; } @@ -200,7 +200,7 @@ static void divideByWeights(SkScalar *sums, SkScalar *weights, SkBitmap *dst) { static void upScaleHorizTranspose(const SkBitmap *src, SkBitmap *dst, float scale, SkBitmapFilter *filter) { for (int y = 0 ; y < dst->height() ; y++) { for (int x = 0 ; x < dst->width() ; x++) { - float sx = (y + 0.5f) / scale - 0.5f; + float sx = (y + 0.5f) / scale - 0.5f; int x0 = SkClampMax(sk_float_ceil2int(sx-filter->width()), src->width()-1); int x1 = SkClampMax(sk_float_floor2int(sx+filter->width()), src->width()-1); @@ -226,7 +226,7 @@ static void upScaleHorizTranspose(const SkBitmap *src, SkBitmap *dst, float scal int g = SkClampMax(SkScalarRoundToInt(fg), a); int b = SkClampMax(SkScalarRoundToInt(fb), a); - *dst->getAddr32(x,y) = SkPackARGB32(a, r, g, b); + *dst->getAddr32(x,y) = SkPackARGB32(a, r, g, b); } } } diff --git a/src/core/SkBitmapFilter.h b/src/core/SkBitmapFilter.h index 1a002b09ee..38c2448c69 100644 --- a/src/core/SkBitmapFilter.h +++ b/src/core/SkBitmapFilter.h @@ -51,7 +51,7 @@ class SkBitmapFilter { protected: float fWidth; float fInvWidth; - + float fLookupMultiplier; mutable bool fPrecomputed; diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 0567cf3990..61972886da 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -92,7 +92,7 @@ static bool valid_for_filtering(unsigned dimension) { // TODO -- we may want to pass the clip into this function so we only scale // the portion of the image that we're going to need. This will complicate -// the interface to the cache, but might be well worth it. +// the interface to the cache, but might be well worth it. void SkBitmapProcState::possiblyScaleImage() { @@ -102,68 +102,68 @@ void SkBitmapProcState::possiblyScaleImage() { // STEP 1: UPSAMPLE? - // Check to see if the transformation matrix is scaling up, and if - // the matrix is simple, and if we're doing high quality scaling. + // Check to see if the transformation matrix is scaling up, and if + // the matrix is simple, and if we're doing high quality scaling. // If so, do the bitmap scale here and remove the scaling component from the matrix. - + if (fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) && (fInvMatrix.getScaleX() < 1 || fInvMatrix.getScaleY() < 1) && fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) { - + // All the criteria are met; let's make a new bitmap. - fScaledBitmap.setConfig(SkBitmap::kARGB_8888_Config, - (int)(fOrigBitmap.width() / fInvMatrix.getScaleX()), + fScaledBitmap.setConfig(SkBitmap::kARGB_8888_Config, + (int)(fOrigBitmap.width() / fInvMatrix.getScaleX()), (int)(fOrigBitmap.height() / fInvMatrix.getScaleY())); fScaledBitmap.allocPixels(); fOrigBitmap.scale(&fScaledBitmap); fBitmap = &fScaledBitmap; - + // set the inv matrix type to translate-only; - fInvMatrix.setTranslate( 1/fInvMatrix.getScaleX() * fInvMatrix.getTranslateX(), + fInvMatrix.setTranslate( 1/fInvMatrix.getScaleX() * fInvMatrix.getTranslateX(), 1/fInvMatrix.getScaleY() * fInvMatrix.getTranslateY() ); - + // no need for any further filtering; we just did it! - + fFilterQuality = kNone_BitmapFilter; - + return; - } - - if (!fOrigBitmap.hasMipMap()) { - + } + + if (!fOrigBitmap.hasMipMap()) { + // STEP 2: DOWNSAMPLE - + // Check to see if the transformation matrix is scaling *down*. - // If so, automatically build mipmaps. - + // If so, automatically build mipmaps. + SkPoint v1, v2; - - // conservatively estimate if the matrix is scaling down by seeing + + // conservatively estimate if the matrix is scaling down by seeing // what its upper left 2x2 portion does to two unit vectors. - + v1.fX = fInvMatrix.getScaleX(); v1.fY = fInvMatrix.getSkewY(); - + v2.fX = fInvMatrix.getSkewX(); v2.fY = fInvMatrix.getScaleY(); - + if (v1.fX * v1.fX + v1.fY * v1.fY > 1 || v2.fX * v2.fX + v2.fY * v2.fY > 1) { fOrigBitmap.buildMipMap(); // Now that we've built the mipmaps and we know we're downsampling, // downgrade to bilinear interpolation for the mip level. - + fFilterQuality = kBilerp_BitmapFilter; - } - } - + } + } + if (fOrigBitmap.hasMipMap()) { - + // STEP 3: We've got mipmaps, let's choose the closest level as our render // source and adjust the matrix accordingly. - + int shift = fOrigBitmap.extractMipLevel(&fScaledBitmap, SkScalarToFixed(fInvMatrix.getScaleX()), SkScalarToFixed(fInvMatrix.getSkewY())); @@ -197,11 +197,11 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { } fBitmap = &fOrigBitmap; - + // initialize our filter quality to the one requested by the caller. // We may downgrade it later if we determine that we either don't need // or can't provide as high a quality filtering as the user requested. - + fFilterQuality = kNone_BitmapFilter; if (paint.isFilterBitmap()) { if (paint.getFlags() & SkPaint::kHighQualityFilterBitmap_Flag) { @@ -213,19 +213,19 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { #ifndef SK_IGNORE_IMAGE_PRESCALE // possiblyScaleImage will look to see if it can rescale the image as a - // preprocess; either by scaling up to the target size, or by selecting + // preprocess; either by scaling up to the target size, or by selecting // a nearby mipmap level. If it does, it will adjust the working // matrix as well as the working bitmap. It may also adjust the filter // quality to avoid re-filtering an already perfectly scaled image. - + this->possiblyScaleImage(); #endif - + // Now that all possible changes to the matrix have taken place, check // to see if we're really close to a no-scale matrix. If so, explicitly // set it to be so. Subsequent code may inspect this matrix to choose // a faster path in this case. - + // This code will only execute if the matrix has some scale component; // if it's already pure translate then we won't do this inversion. @@ -237,7 +237,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { SkScalar tx = -SkScalarRoundToScalar(forward.getTranslateX()); SkScalar ty = -SkScalarRoundToScalar(forward.getTranslateY()); fInvMatrix.setTranslate(tx, ty); - + } } } @@ -250,15 +250,15 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY()); fAlphaScale = SkAlpha255To256(paint.getAlpha()); - + fShaderProc32 = NULL; fShaderProc16 = NULL; fSampleProc32 = NULL; fSampleProc16 = NULL; - + // recompute the triviality of the matrix here because we may have // changed it! - + trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; if (kHQ_BitmapFilter == fFilterQuality) { @@ -266,31 +266,31 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { // but couldn't do it as a preprocess. Let's try to install // the scanline version of the HQ sampler. If that process fails, // downgrade to bilerp. - + // NOTE: Might need to be careful here in the future when we want // to have the platform proc have a shot at this; it's possible that - // the chooseBitmapFilterProc will fail to install a shader but a - // platform-specific one might succeed, so it might be premature here + // the chooseBitmapFilterProc will fail to install a shader but a + // platform-specific one might succeed, so it might be premature here // to fall back to bilerp. This needs thought. - + SkASSERT(fInvType > SkMatrix::kTranslate_Mask); fShaderProc32 = this->chooseBitmapFilterProc(); if (!fShaderProc32) { fFilterQuality = kBilerp_BitmapFilter; - } + } } - + if (kBilerp_BitmapFilter == fFilterQuality) { // Only try bilerp if the matrix is "interesting" and // the image has a suitable size. - + if (fInvType < SkMatrix::kTranslate_Mask || !valid_for_filtering(fBitmap->width() | fBitmap->height())) { fFilterQuality = kNone_BitmapFilter; } } - + // At this point, we know exactly what kind of sampling the per-scanline // shader will perform. @@ -301,12 +301,12 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { /////////////////////////////////////////////////////////////////////// - // No need to do this if we're doing HQ sampling; if filter quality is - // still set to HQ by the time we get here, then we must have installed + // No need to do this if we're doing HQ sampling; if filter quality is + // still set to HQ by the time we get here, then we must have installed // the shader proc above and can skip all this. if (fFilterQuality < kHQ_BitmapFilter) { - + int index = 0; if (fAlphaScale < 256) { // note: this distinction is not used for D16 index |= 1; @@ -702,8 +702,8 @@ SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) { - if (kNone_BitmapFilter == fFilterQuality && - fInvType <= SkMatrix::kTranslate_Mask && + if (kNone_BitmapFilter == fFilterQuality && + fInvType <= SkMatrix::kTranslate_Mask && !this->setupForTranslate()) { return DoNothing_shaderproc; } diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h index be8818c6d9..a644dd1e02 100644 --- a/src/core/SkBitmapProcState.h +++ b/src/core/SkBitmapProcState.h @@ -33,7 +33,7 @@ class SkPaint; struct SkBitmapProcState { - + SkBitmapProcState(): fBitmapFilter(NULL) {} ~SkBitmapProcState() { SkDELETE(fBitmapFilter); @@ -86,10 +86,10 @@ struct SkBitmapProcState { uint8_t fInvType; // chooseProcs uint8_t fTileModeX; // CONSTRUCTOR uint8_t fTileModeY; // CONSTRUCTOR - - enum { - kNone_BitmapFilter, - kBilerp_BitmapFilter, + + enum { + kNone_BitmapFilter, + kBilerp_BitmapFilter, kHQ_BitmapFilter } fFilterQuality; // chooseProcs @@ -157,7 +157,7 @@ private: MatrixProc chooseMatrixProc(bool trivial_matrix); bool chooseProcs(const SkMatrix& inv, const SkPaint&); ShaderProc32 chooseShaderProc32(); - + void possiblyScaleImage(); SkBitmapFilter *fBitmapFilter; diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp index 332c6bb5a1..9f083879c0 100644 --- a/src/gpu/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/GrAAHairLinePathRenderer.cpp @@ -1194,4 +1194,3 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, return true; } - diff --git a/tests/FitsInTest.cpp b/tests/FitsInTest.cpp index 68ee8e94e4..97ef67d991 100644 --- a/tests/FitsInTest.cpp +++ b/tests/FitsInTest.cpp @@ -74,4 +74,3 @@ static void FitsInTest(skiatest::Reporter* reporter) { #include "TestClassDef.h" DEFINE_TESTCLASS("FitsIn", FitsInTestClass, FitsInTest) - diff --git a/tests/UtilsTest.cpp b/tests/UtilsTest.cpp index 63b905aff2..33d5c97112 100644 --- a/tests/UtilsTest.cpp +++ b/tests/UtilsTest.cpp @@ -71,7 +71,7 @@ static void test_autostarray(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, 0 == tmp.count()); REPORTER_ASSERT(reporter, 1 == obj0.getRefCnt()); REPORTER_ASSERT(reporter, 1 == obj1.getRefCnt()); - + tmp.reset(2); // this should use the preexisting allocation REPORTER_ASSERT(reporter, 2 == tmp.count()); tmp[0] = &obj0; |