Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/effects/SkMagnifierImageFilter.cpp

Issue 1266633003: Added registerChild; transforms, textures, glKey automatically handled. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: refactored to onGetGLProcessorKey; removed emitSamplers specialized template; fixed nits Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkLumaColorFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
OLDNEW
« no previous file with comments | « src/effects/SkLumaColorFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698