OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The Android Open Source Project | 2 * Copyright 2014 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 "SkMatrixImageFilter.h" | 8 #include "SkMatrixImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 matrix.postConcat(fTransform); | 69 matrix.postConcat(fTransform); |
70 matrix.postConcat(ctx.ctm()); | 70 matrix.postConcat(ctx.ctm()); |
71 matrix.mapRect(&dstRect, srcRect); | 71 matrix.mapRect(&dstRect, srcRect); |
72 dstRect.roundOut(&dstBounds); | 72 dstRect.roundOut(&dstBounds); |
73 | 73 |
74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dst
Bounds.height())); | 74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dst
Bounds.height())); |
75 if (NULL == device.get()) { | 75 if (NULL == device.get()) { |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
| 79 SkPaint paint; |
| 80 paint.setFilterQuality(fFilterQuality); |
| 81 paint.setAntiAlias(true); // since we may be rotated, we definitely want a
smooth edge |
| 82 |
79 SkCanvas canvas(device.get()); | 83 SkCanvas canvas(device.get()); |
80 canvas.translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y()
)); | 84 canvas.translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y()
)); |
81 canvas.concat(matrix); | 85 canvas.concat(matrix); |
82 SkPaint paint; | |
83 | |
84 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | |
85 paint.setFilterQuality(fFilterQuality); | |
86 canvas.drawBitmap(src, srcRect.x(), srcRect.y(), &paint); | 86 canvas.drawBitmap(src, srcRect.x(), srcRect.y(), &paint); |
87 | 87 |
88 *result = device.get()->accessBitmap(false); | 88 *result = device.get()->accessBitmap(false); |
89 offset->fX = dstBounds.fLeft; | 89 offset->fX = dstBounds.fLeft; |
90 offset->fY = dstBounds.fTop; | 90 offset->fY = dstBounds.fTop; |
91 return true; | 91 return true; |
92 } | 92 } |
93 | 93 |
94 void SkMatrixImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons
t { | 94 void SkMatrixImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons
t { |
95 SkRect bounds = src; | 95 SkRect bounds = src; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 fTransform[SkMatrix::kMPersp2]); | 139 fTransform[SkMatrix::kMPersp2]); |
140 | 140 |
141 str->append("<dt>FilterLevel:</dt><dd>"); | 141 str->append("<dt>FilterLevel:</dt><dd>"); |
142 static const char* gFilterLevelStrings[] = { "None", "Low", "Medium", "High"
}; | 142 static const char* gFilterLevelStrings[] = { "None", "Low", "Medium", "High"
}; |
143 str->append(gFilterLevelStrings[fFilterQuality]); | 143 str->append(gFilterLevelStrings[fFilterQuality]); |
144 str->append("</dd>"); | 144 str->append("</dd>"); |
145 | 145 |
146 str->appendf(")"); | 146 str->appendf(")"); |
147 } | 147 } |
148 #endif | 148 #endif |
OLD | NEW |