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

Side by Side Diff: src/effects/SkPictureImageFilter.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/SkOffsetImageFilter.cpp ('k') | src/effects/SkRectShaderImageFilter.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 2013 The Android Open Source Project 2 * Copyright 2013 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 "SkPictureImageFilter.h" 8 #include "SkPictureImageFilter.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 28 matching lines...) Expand all
39 39
40 void SkPictureImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { 40 void SkPictureImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
41 this->INHERITED::flatten(buffer); 41 this->INHERITED::flatten(buffer);
42 // FIXME: flatten picture here. 42 // FIXME: flatten picture here.
43 buffer.writeRect(fRect); 43 buffer.writeRect(fRect);
44 } 44 }
45 45
46 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk Matrix& matrix, 46 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk Matrix& matrix,
47 SkBitmap* result, SkIPoint* offset) { 47 SkBitmap* result, SkIPoint* offset) {
48 if (!fPicture) { 48 if (!fPicture) {
49 offset->fX = offset->fY = 0;
49 return true; 50 return true;
50 } 51 }
51 52
52 SkRect floatBounds; 53 SkRect floatBounds;
53 SkIRect bounds; 54 SkIRect bounds;
54 matrix.mapRect(&floatBounds, fRect); 55 matrix.mapRect(&floatBounds, fRect);
55 floatBounds.roundOut(&bounds); 56 floatBounds.roundOut(&bounds);
56 57
57 if (bounds.isEmpty()) { 58 if (bounds.isEmpty()) {
59 offset->fX = offset->fY = 0;
58 return true; 60 return true;
59 } 61 }
60 62
61 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height())); 63 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
62 if (NULL == device.get()) { 64 if (NULL == device.get()) {
63 return false; 65 return false;
64 } 66 }
65 67
66 SkCanvas canvas(device.get()); 68 SkCanvas canvas(device.get());
67 SkPaint paint; 69 SkPaint paint;
68 70
69 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); 71 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));
70 canvas.concat(matrix); 72 canvas.concat(matrix);
71 canvas.drawPicture(*fPicture); 73 canvas.drawPicture(*fPicture);
72 74
73 *result = device.get()->accessBitmap(false); 75 *result = device.get()->accessBitmap(false);
74 offset->fX += bounds.fLeft; 76 offset->fX = bounds.fLeft;
75 offset->fY += bounds.fTop; 77 offset->fY = bounds.fTop;
76 return true; 78 return true;
77 } 79 }
OLDNEW
« no previous file with comments | « src/effects/SkOffsetImageFilter.cpp ('k') | src/effects/SkRectShaderImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698