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" |
11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
13 #include "SkValidationUtils.h" | 13 #include "SkValidationUtils.h" |
14 | 14 |
15 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
16 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
17 #include "effects/GrSingleTextureEffect.h" | 17 #include "effects/GrSingleTextureEffect.h" |
18 #include "gl/GrGLProcessor.h" | 18 #include "gl/GrGLProcessor.h" |
19 #include "gl/builders/GrGLProgramBuilder.h" | 19 #include "gl/builders/GrGLProgramBuilder.h" |
20 #include "gl/GrGLSL.h" | 20 #include "gl/GrGLSL.h" |
21 #include "gl/GrGLTexture.h" | 21 #include "gl/GrGLTexture.h" |
| 22 #include "GrInvariantOutput.h" |
22 #include "GrTBackendProcessorFactory.h" | 23 #include "GrTBackendProcessorFactory.h" |
23 | 24 |
24 class GrGLMagnifierEffect; | 25 class GrGLMagnifierEffect; |
25 | 26 |
26 class GrMagnifierEffect : public GrSingleTextureEffect { | 27 class GrMagnifierEffect : public GrSingleTextureEffect { |
27 | 28 |
28 public: | 29 public: |
29 static GrFragmentProcessor* Create(GrTexture* texture, | 30 static GrFragmentProcessor* Create(GrTexture* texture, |
30 float xOffset, | 31 float xOffset, |
31 float yOffset, | 32 float yOffset, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 : GrSingleTextureEffect(texture, GrCoordTransform::MakeDivByTextureWHMat
rix(texture)) | 68 : GrSingleTextureEffect(texture, GrCoordTransform::MakeDivByTextureWHMat
rix(texture)) |
68 , fXOffset(xOffset) | 69 , fXOffset(xOffset) |
69 , fYOffset(yOffset) | 70 , fYOffset(yOffset) |
70 , fXInvZoom(xInvZoom) | 71 , fXInvZoom(xInvZoom) |
71 , fYInvZoom(yInvZoom) | 72 , fYInvZoom(yInvZoom) |
72 , fXInvInset(xInvInset) | 73 , fXInvInset(xInvInset) |
73 , fYInvInset(yInvInset) {} | 74 , fYInvInset(yInvInset) {} |
74 | 75 |
75 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; | 76 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; |
76 | 77 |
77 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; | 78 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; |
78 | 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 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 bool GrMagnifierEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 220 bool GrMagnifierEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
220 const GrMagnifierEffect& s = sBase.cast<GrMagnifierEffect>(); | 221 const GrMagnifierEffect& s = sBase.cast<GrMagnifierEffect>(); |
221 return (this->fXOffset == s.fXOffset && | 222 return (this->fXOffset == s.fXOffset && |
222 this->fYOffset == s.fYOffset && | 223 this->fYOffset == s.fYOffset && |
223 this->fXInvZoom == s.fXInvZoom && | 224 this->fXInvZoom == s.fXInvZoom && |
224 this->fYInvZoom == s.fYInvZoom && | 225 this->fYInvZoom == s.fYInvZoom && |
225 this->fXInvInset == s.fXInvInset && | 226 this->fXInvInset == s.fXInvInset && |
226 this->fYInvInset == s.fYInvInset); | 227 this->fYInvInset == s.fYInvInset); |
227 } | 228 } |
228 | 229 |
229 void GrMagnifierEffect::onComputeInvariantOutput(InvariantOutput* inout) const { | 230 void GrMagnifierEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
230 this->updateInvariantOutputForModulation(inout); | 231 this->updateInvariantOutputForModulation(inout); |
231 } | 232 } |
232 | 233 |
233 #endif | 234 #endif |
234 | 235 |
235 //////////////////////////////////////////////////////////////////////////////// | 236 //////////////////////////////////////////////////////////////////////////////// |
236 | 237 |
237 SkImageFilter* SkMagnifierImageFilter::Create(const SkRect& srcRect, SkScalar in
set, | 238 SkImageFilter* SkMagnifierImageFilter::Create(const SkRect& srcRect, SkScalar in
set, |
238 SkImageFilter* input) { | 239 SkImageFilter* input) { |
239 | 240 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 365 |
365 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 366 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
366 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 367 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
367 | 368 |
368 *dptr = sptr[y_val * width + x_val]; | 369 *dptr = sptr[y_val * width + x_val]; |
369 dptr++; | 370 dptr++; |
370 } | 371 } |
371 } | 372 } |
372 return true; | 373 return true; |
373 } | 374 } |
OLD | NEW |