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

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

Issue 27471002: Implement crop rect support for SkMatrixConvolutionImageFilter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix style issue Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | src/effects/SkMagnifierImageFilter.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 "SkLightingImageFilter.h" 8 #include "SkLightingImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 SkScalar kd, SkImageFilter* input, const CropRe ct* cropRect); 263 SkScalar kd, SkImageFilter* input, const CropRe ct* cropRect);
264 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFi lter) 264 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFi lter)
265 SkScalar kd() const { return fKD; } 265 SkScalar kd() const { return fKD; }
266 266
267 protected: 267 protected:
268 explicit SkDiffuseLightingImageFilter(SkFlattenableReadBuffer& buffer); 268 explicit SkDiffuseLightingImageFilter(SkFlattenableReadBuffer& buffer);
269 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; 269 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE;
270 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, 270 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
271 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; 271 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
272 #if SK_SUPPORT_GPU 272 #if SK_SUPPORT_GPU
273 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m atrix) const SK_OVERRIDE; 273 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m atrix, const SkIRect& bounds) const SK_OVERRIDE;
274 #endif 274 #endif
275 275
276 private: 276 private:
277 typedef SkLightingImageFilter INHERITED; 277 typedef SkLightingImageFilter INHERITED;
278 SkScalar fKD; 278 SkScalar fKD;
279 }; 279 };
280 280
281 class SkSpecularLightingImageFilter : public SkLightingImageFilter { 281 class SkSpecularLightingImageFilter : public SkLightingImageFilter {
282 public: 282 public:
283 SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScala r ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect); 283 SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScala r ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect);
284 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageF ilter) 284 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageF ilter)
285 285
286 SkScalar ks() const { return fKS; } 286 SkScalar ks() const { return fKS; }
287 SkScalar shininess() const { return fShininess; } 287 SkScalar shininess() const { return fShininess; }
288 288
289 protected: 289 protected:
290 explicit SkSpecularLightingImageFilter(SkFlattenableReadBuffer& buffer); 290 explicit SkSpecularLightingImageFilter(SkFlattenableReadBuffer& buffer);
291 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; 291 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE;
292 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, 292 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
293 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; 293 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
294 #if SK_SUPPORT_GPU 294 #if SK_SUPPORT_GPU
295 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m atrix) const SK_OVERRIDE; 295 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m atrix, const SkIRect& bounds) const SK_OVERRIDE;
296 #endif 296 #endif
297 297
298 private: 298 private:
299 typedef SkLightingImageFilter INHERITED; 299 typedef SkLightingImageFilter INHERITED;
300 SkScalar fKS; 300 SkScalar fKS;
301 SkScalar fShininess; 301 SkScalar fShininess;
302 }; 302 };
303 303
304 #if SK_SUPPORT_GPU 304 #if SK_SUPPORT_GPU
305 305
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 lightBitmap<DiffuseLightingType, SkSpotLight>(lightingType, transfor medLight, src, dst, surfaceScale(), bounds); 950 lightBitmap<DiffuseLightingType, SkSpotLight>(lightingType, transfor medLight, src, dst, surfaceScale(), bounds);
951 break; 951 break;
952 } 952 }
953 953
954 offset->fX += bounds.left(); 954 offset->fX += bounds.left();
955 offset->fY += bounds.top(); 955 offset->fY += bounds.top();
956 return true; 956 return true;
957 } 957 }
958 958
959 #if SK_SUPPORT_GPU 959 #if SK_SUPPORT_GPU
960 bool SkDiffuseLightingImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkMatrix& matrix) const { 960 bool SkDiffuseLightingImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkMatrix& matrix, const SkIRect&) const {
961 if (effect) { 961 if (effect) {
962 SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255)); 962 SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
963 *effect = GrDiffuseLightingEffect::Create(texture, light(), scale, matri x, kd()); 963 *effect = GrDiffuseLightingEffect::Create(texture, light(), scale, matri x, kd());
964 } 964 }
965 return true; 965 return true;
966 } 966 }
967 #endif 967 #endif
968 968
969 /////////////////////////////////////////////////////////////////////////////// 969 ///////////////////////////////////////////////////////////////////////////////
970 970
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 case SkLight::kSpot_LightType: 1026 case SkLight::kSpot_LightType:
1027 lightBitmap<SpecularLightingType, SkSpotLight>(lightingType, transfo rmedLight, src, dst, surfaceScale(), bounds); 1027 lightBitmap<SpecularLightingType, SkSpotLight>(lightingType, transfo rmedLight, src, dst, surfaceScale(), bounds);
1028 break; 1028 break;
1029 } 1029 }
1030 offset->fX += bounds.left(); 1030 offset->fX += bounds.left();
1031 offset->fY += bounds.top(); 1031 offset->fY += bounds.top();
1032 return true; 1032 return true;
1033 } 1033 }
1034 1034
1035 #if SK_SUPPORT_GPU 1035 #if SK_SUPPORT_GPU
1036 bool SkSpecularLightingImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkMatrix& matrix) const { 1036 bool SkSpecularLightingImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkMatrix& matrix, const SkIRect&) const {
1037 if (effect) { 1037 if (effect) {
1038 SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255)); 1038 SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
1039 *effect = GrSpecularLightingEffect::Create(texture, light(), scale, matr ix, ks(), shininess()); 1039 *effect = GrSpecularLightingEffect::Create(texture, light(), scale, matr ix, ks(), shininess());
1040 } 1040 }
1041 return true; 1041 return true;
1042 } 1042 }
1043 #endif 1043 #endif
1044 1044
1045 /////////////////////////////////////////////////////////////////////////////// 1045 ///////////////////////////////////////////////////////////////////////////////
1046 1046
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 1570
1571 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); 1571 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight);
1572 } 1572 }
1573 1573
1574 #endif 1574 #endif
1575 1575
1576 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) 1576 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
1577 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) 1577 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
1578 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) 1578 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
1579 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1579 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | src/effects/SkMagnifierImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698