aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-15 14:36:41 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-15 14:36:41 +0000
commit5d8d18651a64f62dbb8881794e23f53bf22c9a23 (patch)
treef1de838dc1288635ea2cfb08ba01d808fd95a5f0 /src
parent5bdef29ae0f5a495381cd2c9787ce7c112e58354 (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
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPath.cpp2
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp59
-rw-r--r--src/gpu/GrClipMaskManager.h8
-rw-r--r--src/gpu/GrGpu.cpp7
4 files changed, 43 insertions, 33 deletions
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();