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

Side by Side Diff: src/effects/SkBitmapSource.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 | « src/effects/SkBicubicImageFilter.cpp ('k') | src/effects/SkBlurImageFilter.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 "SkBitmapSource.h" 8 #include "SkBitmapSource.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix & matrix, 44 bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix & matrix,
45 SkBitmap* result, SkIPoint* offset) { 45 SkBitmap* result, SkIPoint* offset) {
46 SkRect bounds, dstRect; 46 SkRect bounds, dstRect;
47 fBitmap.getBounds(&bounds); 47 fBitmap.getBounds(&bounds);
48 matrix.mapRect(&dstRect, fDstRect); 48 matrix.mapRect(&dstRect, fDstRect);
49 if (fSrcRect == bounds && dstRect == bounds) { 49 if (fSrcRect == bounds && dstRect == bounds) {
50 // No regions cropped out or resized; return entire bitmap. 50 // No regions cropped out or resized; return entire bitmap.
51 *result = fBitmap; 51 *result = fBitmap;
52 offset->fX = offset->fY = 0;
52 return true; 53 return true;
53 } 54 }
54 SkIRect dstIRect; 55 SkIRect dstIRect;
55 dstRect.roundOut(&dstIRect); 56 dstRect.roundOut(&dstIRect);
56 57
57 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstIRect.width(), dstI Rect.height())); 58 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstIRect.width(), dstI Rect.height()));
58 if (NULL == device.get()) { 59 if (NULL == device.get()) {
59 return false; 60 return false;
60 } 61 }
61 62
62 SkCanvas canvas(device.get()); 63 SkCanvas canvas(device.get());
63 SkPaint paint; 64 SkPaint paint;
64 65
65 // Subtract off the integer component of the translation (will be applied in loc, below). 66 // Subtract off the integer component of the translation (will be applied in loc, below).
66 dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop) ); 67 dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop) );
67 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 68 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
68 // FIXME: this probably shouldn't be necessary, but drawBitmapRectToRect ass erts 69 // FIXME: this probably shouldn't be necessary, but drawBitmapRectToRect ass erts
69 // None filtering when it's translate-only 70 // None filtering when it's translate-only
70 paint.setFilterLevel( 71 paint.setFilterLevel(
71 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig ht() ? 72 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig ht() ?
72 SkPaint::kNone_FilterLevel : SkPaint::kMedium_FilterLevel); 73 SkPaint::kNone_FilterLevel : SkPaint::kMedium_FilterLevel);
73 canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint); 74 canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint);
74 75
75 *result = device.get()->accessBitmap(false); 76 *result = device.get()->accessBitmap(false);
76 offset->fX += dstIRect.fLeft; 77 offset->fX = dstIRect.fLeft;
77 offset->fY += dstIRect.fTop; 78 offset->fY = dstIRect.fTop;
78 return true; 79 return true;
79 } 80 }
OLDNEW
« no previous file with comments | « src/effects/SkBicubicImageFilter.cpp ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698