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

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

Issue 1388113002: Bye bye processor data manager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove files Created 5 years, 2 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/SkMatrixConvolutionImageFilter.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"
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 "GrInvariantOutput.h" 17 #include "GrInvariantOutput.h"
18 #include "effects/GrSingleTextureEffect.h" 18 #include "effects/GrSingleTextureEffect.h"
19 #include "gl/GrGLFragmentProcessor.h" 19 #include "gl/GrGLFragmentProcessor.h"
20 #include "gl/GrGLTexture.h" 20 #include "gl/GrGLTexture.h"
21 #include "gl/builders/GrGLProgramBuilder.h" 21 #include "gl/builders/GrGLProgramBuilder.h"
22 22
23 class GrMagnifierEffect : public GrSingleTextureEffect { 23 class GrMagnifierEffect : public GrSingleTextureEffect {
24 24
25 public: 25 public:
26 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, 26 static GrFragmentProcessor* Create(GrTexture* texture,
27 GrTexture* texture,
28 const SkRect& bounds, 27 const SkRect& bounds,
29 float xOffset, 28 float xOffset,
30 float yOffset, 29 float yOffset,
31 float xInvZoom, 30 float xInvZoom,
32 float yInvZoom, 31 float yInvZoom,
33 float xInvInset, 32 float xInvInset,
34 float yInvInset) { 33 float yInvInset) {
35 return new GrMagnifierEffect(procDataManager, texture, bounds, xOffset, yOffset, xInvZoom, 34 return new GrMagnifierEffect(texture, bounds, xOffset, yOffset, xInvZoom , yInvZoom, xInvInset,
36 yInvZoom, xInvInset, yInvInset); 35 yInvInset);
37 } 36 }
38 37
39 virtual ~GrMagnifierEffect() {}; 38 virtual ~GrMagnifierEffect() {};
40 39
41 const char* name() const override { return "Magnifier"; } 40 const char* name() const override { return "Magnifier"; }
42 41
43 const SkRect& bounds() const { return fBounds; } // Bounds of source imag e. 42 const SkRect& bounds() const { return fBounds; } // Bounds of source imag e.
44 // Offset to apply to zoomed pixels, (srcRect position / texture size). 43 // Offset to apply to zoomed pixels, (srcRect position / texture size).
45 float x_offset() const { return fXOffset; } 44 float x_offset() const { return fXOffset; }
46 float y_offset() const { return fYOffset; } 45 float y_offset() const { return fYOffset; }
47 46
48 // Scale to apply to zoomed pixels (srcRect size / bounds size). 47 // Scale to apply to zoomed pixels (srcRect size / bounds size).
49 float x_inv_zoom() const { return fXInvZoom; } 48 float x_inv_zoom() const { return fXInvZoom; }
50 float y_inv_zoom() const { return fYInvZoom; } 49 float y_inv_zoom() const { return fYInvZoom; }
51 50
52 // 1/radius over which to transition from unzoomed to zoomed pixels (bounds size / inset). 51 // 1/radius over which to transition from unzoomed to zoomed pixels (bounds size / inset).
53 float x_inv_inset() const { return fXInvInset; } 52 float x_inv_inset() const { return fXInvInset; }
54 float y_inv_inset() const { return fYInvInset; } 53 float y_inv_inset() const { return fYInvInset; }
55 54
56 private: 55 private:
57 GrMagnifierEffect(GrProcessorDataManager* procDataManager, 56 GrMagnifierEffect(GrTexture* texture,
58 GrTexture* texture,
59 const SkRect& bounds, 57 const SkRect& bounds,
60 float xOffset, 58 float xOffset,
61 float yOffset, 59 float yOffset,
62 float xInvZoom, 60 float xInvZoom,
63 float yInvZoom, 61 float yInvZoom,
64 float xInvInset, 62 float xInvInset,
65 float yInvInset) 63 float yInvInset)
66 : INHERITED(procDataManager, texture, GrCoordTransform::MakeDivByTexture WHMatrix(texture)) 64 : INHERITED(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture) )
67 , fBounds(bounds) 65 , fBounds(bounds)
68 , fXOffset(xOffset) 66 , fXOffset(xOffset)
69 , fYOffset(yOffset) 67 , fYOffset(yOffset)
70 , fXInvZoom(xInvZoom) 68 , fXInvZoom(xInvZoom)
71 , fYInvZoom(yInvZoom) 69 , fYInvZoom(yInvZoom)
72 , fXInvInset(xInvInset) 70 , fXInvInset(xInvInset)
73 , fYInvInset(yInvInset) { 71 , fYInvInset(yInvInset) {
74 this->initClassID<GrMagnifierEffect>(); 72 this->initClassID<GrMagnifierEffect>();
75 } 73 }
76 74
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 const int kMaxWidth = 200; 198 const int kMaxWidth = 200;
201 const int kMaxHeight = 200; 199 const int kMaxHeight = 200;
202 const int kMaxInset = 20; 200 const int kMaxInset = 20;
203 uint32_t width = d->fRandom->nextULessThan(kMaxWidth); 201 uint32_t width = d->fRandom->nextULessThan(kMaxWidth);
204 uint32_t height = d->fRandom->nextULessThan(kMaxHeight); 202 uint32_t height = d->fRandom->nextULessThan(kMaxHeight);
205 uint32_t x = d->fRandom->nextULessThan(kMaxWidth - width); 203 uint32_t x = d->fRandom->nextULessThan(kMaxWidth - width);
206 uint32_t y = d->fRandom->nextULessThan(kMaxHeight - height); 204 uint32_t y = d->fRandom->nextULessThan(kMaxHeight - height);
207 uint32_t inset = d->fRandom->nextULessThan(kMaxInset); 205 uint32_t inset = d->fRandom->nextULessThan(kMaxInset);
208 206
209 GrFragmentProcessor* effect = GrMagnifierEffect::Create( 207 GrFragmentProcessor* effect = GrMagnifierEffect::Create(
210 d->fProcDataManager,
211 texture, 208 texture,
212 SkRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight)), 209 SkRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight)),
213 (float) width / texture->width(), 210 (float) width / texture->width(),
214 (float) height / texture->height(), 211 (float) height / texture->height(),
215 texture->width() / (float) x, 212 texture->width() / (float) x,
216 texture->height() / (float) y, 213 texture->height() / (float) y,
217 (float) inset / texture->width(), 214 (float) inset / texture->width(),
218 (float) inset / texture->height()); 215 (float) inset / texture->height());
219 SkASSERT(effect); 216 SkASSERT(effect);
220 return effect; 217 return effect;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 253
257 254
258 SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i nset, 255 SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i nset,
259 SkImageFilter* input) 256 SkImageFilter* input)
260 : INHERITED(1, &input), fSrcRect(srcRect), fInset(inset) { 257 : INHERITED(1, &input), fSrcRect(srcRect), fInset(inset) {
261 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); 258 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
262 } 259 }
263 260
264 #if SK_SUPPORT_GPU 261 #if SK_SUPPORT_GPU
265 bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, 262 bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp,
266 GrProcessorDataManager* procDat aManager,
267 GrTexture* texture, const SkMat rix&, 263 GrTexture* texture, const SkMat rix&,
268 const SkIRect&bounds) const { 264 const SkIRect&bounds) const {
269 if (fp) { 265 if (fp) {
270 SkScalar yOffset = texture->origin() == kTopLeft_GrSurfaceOrigin ? fSrcR ect.y() : 266 SkScalar yOffset = texture->origin() == kTopLeft_GrSurfaceOrigin ? fSrcR ect.y() :
271 texture->height() - fSrcRect.height() * texture->height() / bounds.he ight() 267 texture->height() - fSrcRect.height() * texture->height() / bounds.he ight()
272 - fSrcRect.y(); 268 - fSrcRect.y();
273 int boundsY = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? bounds.y () : 269 int boundsY = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? bounds.y () :
274 (texture->height() - bounds.height()); 270 (texture->height() - bounds.height());
275 SkRect effectBounds = SkRect::MakeXYWH( 271 SkRect effectBounds = SkRect::MakeXYWH(
276 SkIntToScalar(bounds.x()) / texture->width(), 272 SkIntToScalar(bounds.x()) / texture->width(),
277 SkIntToScalar(boundsY) / texture->height(), 273 SkIntToScalar(boundsY) / texture->height(),
278 SkIntToScalar(texture->width()) / bounds.width(), 274 SkIntToScalar(texture->width()) / bounds.width(),
279 SkIntToScalar(texture->height()) / bounds.height()); 275 SkIntToScalar(texture->height()) / bounds.height());
280 SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; 276 SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1;
281 *fp = GrMagnifierEffect::Create(procDataManager, 277 *fp = GrMagnifierEffect::Create(texture,
282 texture,
283 effectBounds, 278 effectBounds,
284 fSrcRect.x() / texture->width(), 279 fSrcRect.x() / texture->width(),
285 yOffset / texture->height(), 280 yOffset / texture->height(),
286 fSrcRect.width() / bounds.width(), 281 fSrcRect.width() / bounds.width(),
287 fSrcRect.height() / bounds.height(), 282 fSrcRect.height() / bounds.height(),
288 bounds.width() * invInset, 283 bounds.width() * invInset,
289 bounds.height() * invInset); 284 bounds.height() * invInset);
290 } 285 }
291 return true; 286 return true;
292 } 287 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 368
374 #ifndef SK_IGNORE_TO_STRING 369 #ifndef SK_IGNORE_TO_STRING
375 void SkMagnifierImageFilter::toString(SkString* str) const { 370 void SkMagnifierImageFilter::toString(SkString* str) const {
376 str->appendf("SkMagnifierImageFilter: ("); 371 str->appendf("SkMagnifierImageFilter: (");
377 str->appendf("src: (%f,%f,%f,%f) ", 372 str->appendf("src: (%f,%f,%f,%f) ",
378 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m); 373 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m);
379 str->appendf("inset: %f", fInset); 374 str->appendf("inset: %f", fInset);
380 str->append(")"); 375 str->append(")");
381 } 376 }
382 #endif 377 #endif
OLDNEW
« no previous file with comments | « src/effects/SkLumaColorFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698