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 24 matching lines...) Expand all Loading... |
35 xOffset, | 35 xOffset, |
36 yOffset, | 36 yOffset, |
37 xInvZoom, | 37 xInvZoom, |
38 yInvZoom, | 38 yInvZoom, |
39 xInvInset, | 39 xInvInset, |
40 yInvInset)); | 40 yInvInset)); |
41 } | 41 } |
42 | 42 |
43 virtual ~GrMagnifierEffect() {}; | 43 virtual ~GrMagnifierEffect() {}; |
44 | 44 |
45 virtual const char* name() const SK_OVERRIDE { return "Magnifier"; } | 45 const char* name() const SK_OVERRIDE { return "Magnifier"; } |
46 | 46 |
47 virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) cons
t SK_OVERRIDE; | 47 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVE
RRIDE; |
48 | 48 |
49 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; | 49 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; |
50 | 50 |
51 float x_offset() const { return fXOffset; } | 51 float x_offset() const { return fXOffset; } |
52 float y_offset() const { return fYOffset; } | 52 float y_offset() const { return fYOffset; } |
53 float x_inv_zoom() const { return fXInvZoom; } | 53 float x_inv_zoom() const { return fXInvZoom; } |
54 float y_inv_zoom() const { return fYInvZoom; } | 54 float y_inv_zoom() const { return fYInvZoom; } |
55 float x_inv_inset() const { return fXInvInset; } | 55 float x_inv_inset() const { return fXInvInset; } |
56 float y_inv_inset() const { return fYInvInset; } | 56 float y_inv_inset() const { return fYInvInset; } |
57 | 57 |
58 private: | 58 private: |
59 GrMagnifierEffect(GrTexture* texture, | 59 GrMagnifierEffect(GrTexture* texture, |
60 float xOffset, | 60 float xOffset, |
61 float yOffset, | 61 float yOffset, |
62 float xInvZoom, | 62 float xInvZoom, |
63 float yInvZoom, | 63 float yInvZoom, |
64 float xInvInset, | 64 float xInvInset, |
65 float yInvInset) | 65 float yInvInset) |
66 : GrSingleTextureEffect(texture, GrCoordTransform::MakeDivByTextureWHMat
rix(texture)) | 66 : GrSingleTextureEffect(texture, GrCoordTransform::MakeDivByTextureWHMat
rix(texture)) |
67 , fXOffset(xOffset) | 67 , fXOffset(xOffset) |
68 , fYOffset(yOffset) | 68 , fYOffset(yOffset) |
69 , fXInvZoom(xInvZoom) | 69 , fXInvZoom(xInvZoom) |
70 , fYInvZoom(yInvZoom) | 70 , fYInvZoom(yInvZoom) |
71 , fXInvInset(xInvInset) | 71 , fXInvInset(xInvInset) |
72 , fYInvInset(yInvInset) { | 72 , fYInvInset(yInvInset) { |
73 this->initClassID<GrMagnifierEffect>(); | 73 this->initClassID<GrMagnifierEffect>(); |
74 } | 74 } |
75 | 75 |
76 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; | 76 bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; |
77 | 77 |
78 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; | 78 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; |
79 | 79 |
80 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 80 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
81 | 81 |
82 float fXOffset; | 82 float fXOffset; |
83 float fYOffset; | 83 float fYOffset; |
84 float fXInvZoom; | 84 float fXInvZoom; |
85 float fYInvZoom; | 85 float fYInvZoom; |
86 float fXInvInset; | 86 float fXInvInset; |
87 float fYInvInset; | 87 float fYInvInset; |
88 | 88 |
89 typedef GrSingleTextureEffect INHERITED; | 89 typedef GrSingleTextureEffect INHERITED; |
90 }; | 90 }; |
91 | 91 |
92 // For brevity | 92 // For brevity |
93 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 93 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
94 | 94 |
95 class GrGLMagnifierEffect : public GrGLFragmentProcessor { | 95 class GrGLMagnifierEffect : public GrGLFragmentProcessor { |
96 public: | 96 public: |
97 GrGLMagnifierEffect(const GrProcessor&); | 97 GrGLMagnifierEffect(const GrProcessor&); |
98 | 98 |
99 virtual void emitCode(GrGLFPBuilder*, | 99 virtual void emitCode(GrGLFPBuilder*, |
100 const GrFragmentProcessor&, | 100 const GrFragmentProcessor&, |
101 const char* outputColor, | 101 const char* outputColor, |
102 const char* inputColor, | 102 const char* inputColor, |
103 const TransformedCoordsArray&, | 103 const TransformedCoordsArray&, |
104 const TextureSamplerArray&) SK_OVERRIDE; | 104 const TextureSamplerArray&) SK_OVERRIDE; |
105 | 105 |
106 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 106 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; |
107 | 107 |
108 private: | 108 private: |
109 UniformHandle fOffsetVar; | 109 UniformHandle fOffsetVar; |
110 UniformHandle fInvZoomVar; | 110 UniformHandle fInvZoomVar; |
111 UniformHandle fInvInsetVar; | 111 UniformHandle fInvInsetVar; |
112 | 112 |
113 typedef GrGLFragmentProcessor INHERITED; | 113 typedef GrGLFragmentProcessor INHERITED; |
114 }; | 114 }; |
115 | 115 |
116 GrGLMagnifierEffect::GrGLMagnifierEffect(const GrProcessor&) { | 116 GrGLMagnifierEffect::GrGLMagnifierEffect(const GrProcessor&) { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 360 |
361 #ifndef SK_IGNORE_TO_STRING | 361 #ifndef SK_IGNORE_TO_STRING |
362 void SkMagnifierImageFilter::toString(SkString* str) const { | 362 void SkMagnifierImageFilter::toString(SkString* str) const { |
363 str->appendf("SkMagnifierImageFilter: ("); | 363 str->appendf("SkMagnifierImageFilter: ("); |
364 str->appendf("src: (%f,%f,%f,%f) ", | 364 str->appendf("src: (%f,%f,%f,%f) ", |
365 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); | 365 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); |
366 str->appendf("inset: %f", fInset); | 366 str->appendf("inset: %f", fInset); |
367 str->append(")"); | 367 str->append(")"); |
368 } | 368 } |
369 #endif | 369 #endif |
OLD | NEW |