diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-15 14:36:41 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-15 14:36:41 +0000 |
commit | 5d8d18651a64f62dbb8881794e23f53bf22c9a23 (patch) | |
tree | f1de838dc1288635ea2cfb08ba01d808fd95a5f0 | |
parent | 5bdef29ae0f5a495381cd2c9787ce7c112e58354 (diff) |
Addressed Windows compiler complaints
http://codereview.appspot.com/6462062/
This CL will require re-baselining of the imagemagnifier GM
git-svn-id: http://skia.googlecode.com/svn/trunk@5108 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gm/typeface.cpp | 2 | ||||
-rw-r--r-- | src/core/SkPath.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkMagnifierImageFilter.cpp | 59 | ||||
-rw-r--r-- | src/gpu/GrClipMaskManager.h | 8 | ||||
-rw-r--r-- | src/gpu/GrGpu.cpp | 7 | ||||
-rw-r--r-- | tools/PictureRenderer.cpp | 4 |
6 files changed, 46 insertions, 36 deletions
diff --git a/gm/typeface.cpp b/gm/typeface.cpp index af04725a3f..9c7363091c 100644 --- a/gm/typeface.cpp +++ b/gm/typeface.cpp @@ -35,7 +35,7 @@ public: for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { fFaces[i]->unref(); } - delete fFaces; + delete [] fFaces; } protected: diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index a9937ab9a0..4be1c986fe 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -1816,7 +1816,7 @@ void SkPath::validate() const { SkRect bounds; bool isFinite = compute_pt_bounds(&bounds, fPts); - SkASSERT(fIsFinite == isFinite); + SkASSERT(SkToBool(fIsFinite) == isFinite); if (fPts.count() <= 1) { // if we're empty, fBounds may be empty but translated, so we can't diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 626de95e46..846fd28819 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -192,15 +192,16 @@ GrCustomStage* GrMagnifierEffect::TestCreate(SkRandom* random, const int kMaxWidth = 200; const int kMaxHeight = 200; const int kMaxInset = 20; - SkScalar width = random->nextULessThan(kMaxWidth); - SkScalar height = random->nextULessThan(kMaxHeight); - SkScalar x = random->nextULessThan(kMaxWidth - width); - SkScalar y = random->nextULessThan(kMaxHeight - height); - SkScalar inset = random->nextULessThan(kMaxInset); + uint32_t width = random->nextULessThan(kMaxWidth); + uint32_t height = random->nextULessThan(kMaxHeight); + uint32_t x = random->nextULessThan(kMaxWidth - width); + uint32_t y = random->nextULessThan(kMaxHeight - height); + SkScalar inset = SkIntToScalar(random->nextULessThan(kMaxInset)); SkAutoTUnref<SkImageFilter> filter( new SkMagnifierImageFilter( - SkRect::MakeXYWH(x, y, width, height), + SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), + SkIntToScalar(width), SkIntToScalar(height)), inset)); GrSamplerState sampler; GrCustomStage* stage; @@ -289,10 +290,10 @@ bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src, return false; } - float inv_inset = fInset > 0 ? 1.0f / SkScalarToFloat(fInset) : 1.0f; + SkScalar inv_inset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; - float inv_x_zoom = fSrcRect.width() / src.width(); - float inv_y_zoom = fSrcRect.height() / src.height(); + SkScalar inv_x_zoom = fSrcRect.width() / src.width(); + SkScalar inv_y_zoom = fSrcRect.height() / src.height(); dst->setConfig(src.config(), src.width(), src.height()); dst->allocPixels(); @@ -301,31 +302,35 @@ bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src, int width = src.width(), height = src.height(); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { - float x_dist = SkMinScalar(x, width - x - 1) * inv_inset; - float y_dist = SkMinScalar(y, height - y - 1) * inv_inset; - float weight = 0; + SkScalar x_dist = SkMin32(x, width - x - 1) * inv_inset; + SkScalar y_dist = SkMin32(y, height - y - 1) * inv_inset; + SkScalar weight = 0; + + static const SkScalar kScalar2 = SkScalar(2); // To create a smooth curve at the corners, we need to work on // a square twice the size of the inset. - if (x_dist < 2 && y_dist < 2) { - x_dist = 2 - x_dist; - y_dist = 2 - y_dist; - - float dist = sqrt(x_dist * x_dist + y_dist * y_dist); - dist = SkMaxScalar(2 - dist, 0.0f); - weight = SkMinScalar(dist * dist, 1.0f); + if (x_dist < kScalar2 && y_dist < kScalar2) { + x_dist = kScalar2 - x_dist; + y_dist = kScalar2 - y_dist; + + SkScalar dist = SkScalarSqrt(SkScalarSquare(x_dist) + + SkScalarSquare(y_dist)); + dist = SkMaxScalar(kScalar2 - dist, 0); + weight = SkMinScalar(SkScalarSquare(dist), SK_Scalar1); } else { - float sq_dist = SkMinScalar(x_dist * x_dist, y_dist * y_dist); - weight = SkMinScalar(sq_dist, 1.0f); + SkScalar sqDist = SkMinScalar(SkScalarSquare(x_dist), + SkScalarSquare(y_dist)); + weight = SkMinScalar(sqDist, SK_Scalar1); } - int x_val = weight * (fSrcRect.x() + x * inv_x_zoom) + - (1 - weight) * x; - int y_val = weight * (fSrcRect.y() + y * inv_y_zoom) + - (1 - weight) * y; + SkScalar x_interp = SkScalarMul(weight, (fSrcRect.x() + x * inv_x_zoom)) + + (SK_Scalar1 - weight) * x; + SkScalar y_interp = SkScalarMul(weight, (fSrcRect.y() + y * inv_y_zoom)) + + (SK_Scalar1 - weight) * y; - x_val = SkMin32(x_val, width - 1); - y_val = SkMin32(y_val, height - 1); + int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); + int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); *dptr = sptr[y_val * width + x_val]; dptr++; diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h index fed4205653..1187a0816c 100644 --- a/src/gpu/GrClipMaskManager.h +++ b/src/gpu/GrClipMaskManager.h @@ -264,8 +264,8 @@ class GrClipMaskManager : public GrNoncopyable { public: GR_DECLARE_RESOURCE_CACHE_DOMAIN(GetAlphaMaskDomain) - GrClipMaskManager(GrGpu* gpu) - : fGpu(gpu) + GrClipMaskManager() + : fGpu(NULL) , fCurrClipMaskType(kNone_ClipMaskType) { } @@ -299,6 +299,10 @@ public: return fAACache.getContext(); } + void setGpu(GrGpu* gpu) { + fGpu = gpu; + } + private: /** * Informs the helper function adjustStencilParams() about how the stencil diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index a9306f49e4..c159f5e735 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -29,8 +29,7 @@ extern void gr_run_unittests(); #define DEBUG_INVAL_START_IDX -1 GrGpu::GrGpu() - : fClipMaskManager(this) - , fContext(NULL) + : fContext(NULL) , fResetTimestamp(kExpiredTimestamp+1) , fVertexPool(NULL) , fIndexPool(NULL) @@ -41,10 +40,12 @@ GrGpu::GrGpu() , fContextIsDirty(true) , fResourceHead(NULL) { + fClipMaskManager.setGpu(this); + #if GR_DEBUG //gr_run_unittests(); #endif - + fGeomPoolStateStack.push_back(); #if GR_DEBUG GeometryPoolState& poolState = fGeomPoolStateStack.back(); diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index 6af12181f7..f0aba9fc6a 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -76,10 +76,10 @@ void TiledPictureRenderer::init(SkPicture* pict) { this->INHERITED::init(pict); if (fTileWidthPercentage > 0) { - fTileWidth = sk_float_ceil2int(fTileWidthPercentage * fPicture->width() / 100); + fTileWidth = sk_float_ceil2int(float(fTileWidthPercentage * fPicture->width() / 100)); } if (fTileHeightPercentage > 0) { - fTileHeight = sk_float_ceil2int(fTileHeightPercentage * fPicture->height() / 100); + fTileHeight = sk_float_ceil2int(float(fTileHeightPercentage * fPicture->height() / 100)); } this->setupTiles(); |