Make SkImageFilter::asNewEffect() (and all derived-class overrides) protected.
R=bsalomon@google.com, bsalomon
Review URL: https://codereview.chromium.org/26937006
git-svn-id: http://skia.googlecode.com/svn/trunk@11847 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index a41a8f5..d34bd7a 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -262,10 +262,6 @@
SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale,
SkScalar kd, SkImageFilter* input, const CropRect* cropRect);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFilter)
-
-#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& matrix) const SK_OVERRIDE;
-#endif
SkScalar kd() const { return fKD; }
protected:
@@ -273,7 +269,9 @@
virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
-
+#if SK_SUPPORT_GPU
+ virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& matrix) const SK_OVERRIDE;
+#endif
private:
typedef SkLightingImageFilter INHERITED;
@@ -285,10 +283,6 @@
SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter)
-#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& matrix) const SK_OVERRIDE;
-#endif
-
SkScalar ks() const { return fKS; }
SkScalar shininess() const { return fShininess; }
@@ -297,6 +291,9 @@
virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
+#if SK_SUPPORT_GPU
+ virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& matrix) const SK_OVERRIDE;
+#endif
private:
typedef SkLightingImageFilter INHERITED;
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index e3d6efd..bef1e8d 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -184,6 +184,7 @@
GrContext* context,
const GrDrawTargetCaps&,
GrTexture** textures) {
+ GrTexture* texture = textures[0];
const int kMaxWidth = 200;
const int kMaxHeight = 200;
const int kMaxInset = 20;
@@ -191,15 +192,16 @@
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));
+ uint32_t inset = random->nextULessThan(kMaxInset);
- SkAutoTUnref<SkMagnifierImageFilter> filter(
- new SkMagnifierImageFilter(
- SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y),
- SkIntToScalar(width), SkIntToScalar(height)),
- inset));
- GrEffectRef* effect;
- filter->asNewEffect(&effect, textures[0], SkMatrix::I());
+ GrEffectRef* effect = GrMagnifierEffect::Create(
+ texture,
+ (float) width / texture->width(),
+ (float) height / texture->height(),
+ texture->width() / (float) x,
+ texture->height() / (float) y,
+ (float) inset / texture->width(),
+ (float) inset / texture->height());
SkASSERT(NULL != effect);
return effect;
}