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 14 matching lines...) Expand all Loading... |
25 class GrMagnifierEffect : public GrSingleTextureEffect { | 25 class GrMagnifierEffect : public GrSingleTextureEffect { |
26 | 26 |
27 public: | 27 public: |
28 static GrEffectRef* Create(GrTexture* texture, | 28 static GrEffectRef* Create(GrTexture* texture, |
29 float xOffset, | 29 float xOffset, |
30 float yOffset, | 30 float yOffset, |
31 float xInvZoom, | 31 float xInvZoom, |
32 float yInvZoom, | 32 float yInvZoom, |
33 float xInvInset, | 33 float xInvInset, |
34 float yInvInset) { | 34 float yInvInset) { |
35 AutoEffectUnref effect(SkNEW_ARGS(GrMagnifierEffect, (texture, | 35 return SkNEW_ARGS(GrMagnifierEffect, (texture, |
36 xOffset, | 36 xOffset, |
37 yOffset, | 37 yOffset, |
38 xInvZoom, | 38 xInvZoom, |
39 yInvZoom, | 39 yInvZoom, |
40 xInvInset, | 40 xInvInset, |
41 yInvInset))); | 41 yInvInset)); |
42 return CreateEffectRef(effect); | |
43 } | 42 } |
44 | 43 |
45 virtual ~GrMagnifierEffect() {}; | 44 virtual ~GrMagnifierEffect() {}; |
46 | 45 |
47 static const char* Name() { return "Magnifier"; } | 46 static const char* Name() { return "Magnifier"; } |
48 | 47 |
49 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | 48 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
50 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 49 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
51 | 50 |
52 float x_offset() const { return fXOffset; } | 51 float x_offset() const { return fXOffset; } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 340 |
342 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 341 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
343 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 342 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
344 | 343 |
345 *dptr = sptr[y_val * width + x_val]; | 344 *dptr = sptr[y_val * width + x_val]; |
346 dptr++; | 345 dptr++; |
347 } | 346 } |
348 } | 347 } |
349 return true; | 348 return true; |
350 } | 349 } |
OLD | NEW |