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

Side by Side Diff: src/core/SkCanvas.cpp

Issue 112803004: Make SkImageFilter crop rects relative to the primitive origin, instead of relative to their parent (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated to ToT Created 6 years, 11 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 | « include/core/SkImageFilter.h ('k') | src/core/SkImageFilter.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 /* 2 /*
3 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 991
992 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) 992 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
993 while (iter.next()) { 993 while (iter.next()) {
994 SkBaseDevice* dstDev = iter.fDevice; 994 SkBaseDevice* dstDev = iter.fDevice;
995 paint = &looper.paint(); 995 paint = &looper.paint();
996 SkImageFilter* filter = paint->getImageFilter(); 996 SkImageFilter* filter = paint->getImageFilter();
997 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 997 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
998 if (filter && !dstDev->canHandleImageFilter(filter)) { 998 if (filter && !dstDev->canHandleImageFilter(filter)) {
999 SkDeviceImageFilterProxy proxy(dstDev); 999 SkDeviceImageFilterProxy proxy(dstDev);
1000 SkBitmap dst; 1000 SkBitmap dst;
1001 SkIPoint offset = SkIPoint::Make(0, 0);
1001 const SkBitmap& src = srcDev->accessBitmap(false); 1002 const SkBitmap& src = srcDev->accessBitmap(false);
1002 SkMatrix matrix = *iter.fMatrix; 1003 SkMatrix matrix = *iter.fMatrix;
1003 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); 1004 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
1004 if (filter->filterImage(&proxy, src, matrix, &dst, &pos)) { 1005 if (filter->filterImage(&proxy, src, matrix, &dst, &offset)) {
1005 SkPaint tmpUnfiltered(*paint); 1006 SkPaint tmpUnfiltered(*paint);
1006 tmpUnfiltered.setImageFilter(NULL); 1007 tmpUnfiltered.setImageFilter(NULL);
1007 dstDev->drawSprite(iter, dst, pos.x(), pos.y(), tmpUnfiltered); 1008 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of fset.y(),
1009 tmpUnfiltered);
1008 } 1010 }
1009 } else { 1011 } else {
1010 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); 1012 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint);
1011 } 1013 }
1012 } 1014 }
1013 LOOPER_END 1015 LOOPER_END
1014 } 1016 }
1015 1017
1016 void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, 1018 void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
1017 const SkPaint* paint) { 1019 const SkPaint* paint) {
(...skipping 11 matching lines...) Expand all
1029 1031
1030 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) 1032 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
1031 1033
1032 while (iter.next()) { 1034 while (iter.next()) {
1033 paint = &looper.paint(); 1035 paint = &looper.paint();
1034 SkImageFilter* filter = paint->getImageFilter(); 1036 SkImageFilter* filter = paint->getImageFilter();
1035 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1037 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1036 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { 1038 if (filter && !iter.fDevice->canHandleImageFilter(filter)) {
1037 SkDeviceImageFilterProxy proxy(iter.fDevice); 1039 SkDeviceImageFilterProxy proxy(iter.fDevice);
1038 SkBitmap dst; 1040 SkBitmap dst;
1041 SkIPoint offset = SkIPoint::Make(0, 0);
1039 SkMatrix matrix = *iter.fMatrix; 1042 SkMatrix matrix = *iter.fMatrix;
1040 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); 1043 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
1041 if (filter->filterImage(&proxy, bitmap, matrix, &dst, &pos)) { 1044 if (filter->filterImage(&proxy, bitmap, matrix, &dst, &offset)) {
1042 SkPaint tmpUnfiltered(*paint); 1045 SkPaint tmpUnfiltered(*paint);
1043 tmpUnfiltered.setImageFilter(NULL); 1046 tmpUnfiltered.setImageFilter(NULL);
1044 iter.fDevice->drawSprite(iter, dst, pos.x(), pos.y(), 1047 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y( ) + offset.y(),
1045 tmpUnfiltered); 1048 tmpUnfiltered);
1046 } 1049 }
1047 } else { 1050 } else {
1048 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); 1051 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint);
1049 } 1052 }
1050 } 1053 }
1051 LOOPER_END 1054 LOOPER_END
1052 } 1055 }
1053 1056
1054 ///////////////////////////////////////////////////////////////////////////// 1057 /////////////////////////////////////////////////////////////////////////////
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 return *paint; 2188 return *paint;
2186 } 2189 }
2187 2190
2188 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } 2191 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); }
2189 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } 2192 int SkCanvas::LayerIter::x() const { return fImpl->getX(); }
2190 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } 2193 int SkCanvas::LayerIter::y() const { return fImpl->getY(); }
2191 2194
2192 /////////////////////////////////////////////////////////////////////////////// 2195 ///////////////////////////////////////////////////////////////////////////////
2193 2196
2194 SkCanvas::ClipVisitor::~ClipVisitor() { } 2197 SkCanvas::ClipVisitor::~ClipVisitor() { }
OLDNEW
« no previous file with comments | « include/core/SkImageFilter.h ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698