| 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 xInvZoom, | 40 xInvZoom, |
| 41 yInvZoom, | 41 yInvZoom, |
| 42 xInvInset, | 42 xInvInset, |
| 43 yInvInset)); | 43 yInvInset)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual ~GrMagnifierEffect() {}; | 46 virtual ~GrMagnifierEffect() {}; |
| 47 | 47 |
| 48 const char* name() const override { return "Magnifier"; } | 48 const char* name() const override { return "Magnifier"; } |
| 49 | 49 |
| 50 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; | |
| 51 | |
| 52 GrGLFragmentProcessor* createGLInstance() const override; | 50 GrGLFragmentProcessor* createGLInstance() const override; |
| 53 | 51 |
| 54 const SkRect& bounds() const { return fBounds; } // Bounds of source imag
e. | 52 const SkRect& bounds() const { return fBounds; } // Bounds of source imag
e. |
| 55 // Offset to apply to zoomed pixels, (srcRect position / texture size). | 53 // Offset to apply to zoomed pixels, (srcRect position / texture size). |
| 56 float x_offset() const { return fXOffset; } | 54 float x_offset() const { return fXOffset; } |
| 57 float y_offset() const { return fYOffset; } | 55 float y_offset() const { return fYOffset; } |
| 58 | 56 |
| 59 // Scale to apply to zoomed pixels (srcRect size / bounds size). | 57 // Scale to apply to zoomed pixels (srcRect size / bounds size). |
| 60 float x_inv_zoom() const { return fXInvZoom; } | 58 float x_inv_zoom() const { return fXInvZoom; } |
| 61 float y_inv_zoom() const { return fYInvZoom; } | 59 float y_inv_zoom() const { return fYInvZoom; } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 78 , fBounds(bounds) | 76 , fBounds(bounds) |
| 79 , fXOffset(xOffset) | 77 , fXOffset(xOffset) |
| 80 , fYOffset(yOffset) | 78 , fYOffset(yOffset) |
| 81 , fXInvZoom(xInvZoom) | 79 , fXInvZoom(xInvZoom) |
| 82 , fYInvZoom(yInvZoom) | 80 , fYInvZoom(yInvZoom) |
| 83 , fXInvInset(xInvInset) | 81 , fXInvInset(xInvInset) |
| 84 , fYInvInset(yInvInset) { | 82 , fYInvInset(yInvInset) { |
| 85 this->initClassID<GrMagnifierEffect>(); | 83 this->initClassID<GrMagnifierEffect>(); |
| 86 } | 84 } |
| 87 | 85 |
| 86 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; |
| 87 |
| 88 bool onIsEqual(const GrFragmentProcessor&) const override; | 88 bool onIsEqual(const GrFragmentProcessor&) const override; |
| 89 | 89 |
| 90 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 90 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
| 91 | 91 |
| 92 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 92 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 93 | 93 |
| 94 SkRect fBounds; | 94 SkRect fBounds; |
| 95 float fXOffset; | 95 float fXOffset; |
| 96 float fYOffset; | 96 float fYOffset; |
| 97 float fXInvZoom; | 97 float fXInvZoom; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>(); | 183 const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>(); |
| 184 pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset()); | 184 pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset()); |
| 185 pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom()); | 185 pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom()); |
| 186 pdman.set2f(fInvInsetVar, zoom.x_inv_inset(), zoom.y_inv_inset()); | 186 pdman.set2f(fInvInsetVar, zoom.x_inv_inset(), zoom.y_inv_inset()); |
| 187 pdman.set4f(fBoundsVar, zoom.bounds().x(), zoom.bounds().y(), | 187 pdman.set4f(fBoundsVar, zoom.bounds().x(), zoom.bounds().y(), |
| 188 zoom.bounds().width(), zoom.bounds().height()); | 188 zoom.bounds().width(), zoom.bounds().height()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 ///////////////////////////////////////////////////////////////////// | 191 ///////////////////////////////////////////////////////////////////// |
| 192 | 192 |
| 193 void GrMagnifierEffect::getGLProcessorKey(const GrGLSLCaps& caps, | 193 void GrMagnifierEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 194 GrProcessorKeyBuilder* b) const { | 194 GrProcessorKeyBuilder* b) const { |
| 195 GrGLMagnifierEffect::GenKey(*this, caps, b); | 195 GrGLMagnifierEffect::GenKey(*this, caps, b); |
| 196 } | 196 } |
| 197 | 197 |
| 198 GrGLFragmentProcessor* GrMagnifierEffect::createGLInstance() const { | 198 GrGLFragmentProcessor* GrMagnifierEffect::createGLInstance() const { |
| 199 return SkNEW_ARGS(GrGLMagnifierEffect, (*this)); | 199 return SkNEW_ARGS(GrGLMagnifierEffect, (*this)); |
| 200 } | 200 } |
| 201 | 201 |
| 202 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect); | 202 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect); |
| 203 | 203 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 379 |
| 380 #ifndef SK_IGNORE_TO_STRING | 380 #ifndef SK_IGNORE_TO_STRING |
| 381 void SkMagnifierImageFilter::toString(SkString* str) const { | 381 void SkMagnifierImageFilter::toString(SkString* str) const { |
| 382 str->appendf("SkMagnifierImageFilter: ("); | 382 str->appendf("SkMagnifierImageFilter: ("); |
| 383 str->appendf("src: (%f,%f,%f,%f) ", | 383 str->appendf("src: (%f,%f,%f,%f) ", |
| 384 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); | 384 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); |
| 385 str->appendf("inset: %f", fInset); | 385 str->appendf("inset: %f", fInset); |
| 386 str->append(")"); | 386 str->append(")"); |
| 387 } | 387 } |
| 388 #endif | 388 #endif |
| OLD | NEW |