| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkMagnifierImageFilter.h" | 9 #include "SkMagnifierImageFilter.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 yInvZoom, | 40 yInvZoom, |
| 41 xInvInset, | 41 xInvInset, |
| 42 yInvInset)); | 42 yInvInset)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual ~GrMagnifierEffect() {}; | 45 virtual ~GrMagnifierEffect() {}; |
| 46 | 46 |
| 47 static const char* Name() { return "Magnifier"; } | 47 static const char* Name() { return "Magnifier"; } |
| 48 | 48 |
| 49 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 49 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
| 50 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | |
| 51 | |
| 52 float x_offset() const { return fXOffset; } | 50 float x_offset() const { return fXOffset; } |
| 53 float y_offset() const { return fYOffset; } | 51 float y_offset() const { return fYOffset; } |
| 54 float x_inv_zoom() const { return fXInvZoom; } | 52 float x_inv_zoom() const { return fXInvZoom; } |
| 55 float y_inv_zoom() const { return fYInvZoom; } | 53 float y_inv_zoom() const { return fYInvZoom; } |
| 56 float x_inv_inset() const { return fXInvInset; } | 54 float x_inv_inset() const { return fXInvInset; } |
| 57 float y_inv_inset() const { return fYInvInset; } | 55 float y_inv_inset() const { return fYInvInset; } |
| 58 | 56 |
| 59 typedef GrGLMagnifierEffect GLProcessor; | 57 typedef GrGLMagnifierEffect GLProcessor; |
| 60 | 58 |
| 61 private: | 59 private: |
| 62 GrMagnifierEffect(GrTexture* texture, | 60 GrMagnifierEffect(GrTexture* texture, |
| 63 float xOffset, | 61 float xOffset, |
| 64 float yOffset, | 62 float yOffset, |
| 65 float xInvZoom, | 63 float xInvZoom, |
| 66 float yInvZoom, | 64 float yInvZoom, |
| 67 float xInvInset, | 65 float xInvInset, |
| 68 float yInvInset) | 66 float yInvInset) |
| 69 : GrSingleTextureEffect(texture, GrCoordTransform::MakeDivByTextureWHMat
rix(texture)) | 67 : GrSingleTextureEffect(texture, GrCoordTransform::MakeDivByTextureWHMat
rix(texture)) |
| 70 , fXOffset(xOffset) | 68 , fXOffset(xOffset) |
| 71 , fYOffset(yOffset) | 69 , fYOffset(yOffset) |
| 72 , fXInvZoom(xInvZoom) | 70 , fXInvZoom(xInvZoom) |
| 73 , fYInvZoom(yInvZoom) | 71 , fYInvZoom(yInvZoom) |
| 74 , fXInvInset(xInvInset) | 72 , fXInvInset(xInvInset) |
| 75 , fYInvInset(yInvInset) {} | 73 , fYInvInset(yInvInset) {} |
| 76 | 74 |
| 77 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; | 75 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
| 78 | 76 |
| 77 virtual void onGetConstantColorComponents(GrColor* color, uint32_t* validFla
gs, |
| 78 bool* isSingleComponent) const SK_
OVERRIDE; |
| 79 |
| 79 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 80 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 80 | 81 |
| 81 float fXOffset; | 82 float fXOffset; |
| 82 float fYOffset; | 83 float fYOffset; |
| 83 float fXInvZoom; | 84 float fXInvZoom; |
| 84 float fYInvZoom; | 85 float fYInvZoom; |
| 85 float fXInvInset; | 86 float fXInvInset; |
| 86 float fYInvInset; | 87 float fYInvInset; |
| 87 | 88 |
| 88 typedef GrSingleTextureEffect INHERITED; | 89 typedef GrSingleTextureEffect INHERITED; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 const GrMagnifierEffect& s = sBase.cast<GrMagnifierEffect>(); | 221 const GrMagnifierEffect& s = sBase.cast<GrMagnifierEffect>(); |
| 221 return (this->texture(0) == s.texture(0) && | 222 return (this->texture(0) == s.texture(0) && |
| 222 this->fXOffset == s.fXOffset && | 223 this->fXOffset == s.fXOffset && |
| 223 this->fYOffset == s.fYOffset && | 224 this->fYOffset == s.fYOffset && |
| 224 this->fXInvZoom == s.fXInvZoom && | 225 this->fXInvZoom == s.fXInvZoom && |
| 225 this->fYInvZoom == s.fYInvZoom && | 226 this->fYInvZoom == s.fYInvZoom && |
| 226 this->fXInvInset == s.fXInvInset && | 227 this->fXInvInset == s.fXInvInset && |
| 227 this->fYInvInset == s.fYInvInset); | 228 this->fYInvInset == s.fYInvInset); |
| 228 } | 229 } |
| 229 | 230 |
| 230 void GrMagnifierEffect::getConstantColorComponents(GrColor* color, uint32_t* val
idFlags) const { | 231 void GrMagnifierEffect::onGetConstantColorComponents(GrColor* color, uint32_t* v
alidFlags, |
| 232 bool* isSingleComponent) co
nst { |
| 231 this->updateConstantColorComponentsForModulation(color, validFlags); | 233 this->updateConstantColorComponentsForModulation(color, validFlags); |
| 232 } | 234 } |
| 233 | 235 |
| 234 #endif | 236 #endif |
| 235 | 237 |
| 236 //////////////////////////////////////////////////////////////////////////////// | 238 //////////////////////////////////////////////////////////////////////////////// |
| 237 | 239 |
| 238 SkImageFilter* SkMagnifierImageFilter::Create(const SkRect& srcRect, SkScalar in
set, | 240 SkImageFilter* SkMagnifierImageFilter::Create(const SkRect& srcRect, SkScalar in
set, |
| 239 SkImageFilter* input) { | 241 SkImageFilter* input) { |
| 240 | 242 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 367 |
| 366 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 368 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
| 367 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 369 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
| 368 | 370 |
| 369 *dptr = sptr[y_val * width + x_val]; | 371 *dptr = sptr[y_val * width + x_val]; |
| 370 dptr++; | 372 dptr++; |
| 371 } | 373 } |
| 372 } | 374 } |
| 373 return true; | 375 return true; |
| 374 } | 376 } |
| OLD | NEW |