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

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

Issue 1014533004: SkPaint::FilterLevel -> SkFilterQuality (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/effects/SkBitmapSource.cpp ('k') | src/effects/SkPictureImageFilter.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 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"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkColorPriv.h" 12 #include "SkColorPriv.h"
13 #include "SkReadBuffer.h" 13 #include "SkReadBuffer.h"
14 #include "SkWriteBuffer.h" 14 #include "SkWriteBuffer.h"
15 #include "SkMatrix.h" 15 #include "SkMatrix.h"
16 #include "SkRect.h" 16 #include "SkRect.h"
17 17
18 SkMatrixImageFilter::SkMatrixImageFilter(const SkMatrix& transform, 18 SkMatrixImageFilter::SkMatrixImageFilter(const SkMatrix& transform,
19 SkPaint::FilterLevel filterLevel, 19 SkFilterQuality filterQuality,
20 SkImageFilter* input, 20 SkImageFilter* input,
21 uint32_t uniqueID) 21 uint32_t uniqueID)
22 : INHERITED(1, &input, NULL, uniqueID), 22 : INHERITED(1, &input, NULL, uniqueID),
23 fTransform(transform), 23 fTransform(transform),
24 fFilterLevel(filterLevel) { 24 fFilterQuality(filterQuality) {
25 } 25 }
26 26
27 SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform, 27 SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform,
28 SkPaint::FilterLevel filterLeve l, 28 SkFilterQuality filterQuality,
29 SkImageFilter* input, 29 SkImageFilter* input,
30 uint32_t uniqueID) { 30 uint32_t uniqueID) {
31 return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterLevel, input, uniqu eID)); 31 return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterQuality, input, uni queID));
32 } 32 }
33 33
34 SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) { 34 SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
35 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 35 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
36 SkMatrix matrix; 36 SkMatrix matrix;
37 buffer.readMatrix(&matrix); 37 buffer.readMatrix(&matrix);
38 SkPaint::FilterLevel level = static_cast<SkPaint::FilterLevel>(buffer.readIn t()); 38 SkFilterQuality quality = static_cast<SkFilterQuality>(buffer.readInt());
39 return Create(matrix, level, common.getInput(0), common.uniqueID()); 39 return Create(matrix, quality, common.getInput(0), common.uniqueID());
40 } 40 }
41 41
42 void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { 42 void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const {
43 this->INHERITED::flatten(buffer); 43 this->INHERITED::flatten(buffer);
44 buffer.writeMatrix(fTransform); 44 buffer.writeMatrix(fTransform);
45 buffer.writeInt(fFilterLevel); 45 buffer.writeInt(fFilterQuality);
46 } 46 }
47 47
48 SkMatrixImageFilter::~SkMatrixImageFilter() { 48 SkMatrixImageFilter::~SkMatrixImageFilter() {
49 } 49 }
50 50
51 bool SkMatrixImageFilter::onFilterImage(Proxy* proxy, 51 bool SkMatrixImageFilter::onFilterImage(Proxy* proxy,
52 const SkBitmap& source, 52 const SkBitmap& source,
53 const Context& ctx, 53 const Context& ctx,
54 SkBitmap* result, 54 SkBitmap* result,
55 SkIPoint* offset) const { 55 SkIPoint* offset) const {
(...skipping 21 matching lines...) Expand all
77 if (NULL == device.get()) { 77 if (NULL == device.get()) {
78 return false; 78 return false;
79 } 79 }
80 80
81 SkCanvas canvas(device.get()); 81 SkCanvas canvas(device.get());
82 canvas.translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y() )); 82 canvas.translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y() ));
83 canvas.concat(matrix); 83 canvas.concat(matrix);
84 SkPaint paint; 84 SkPaint paint;
85 85
86 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 86 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
87 paint.setFilterLevel(fFilterLevel); 87 paint.setFilterQuality(fFilterQuality);
88 canvas.drawBitmap(src, srcRect.x(), srcRect.y(), &paint); 88 canvas.drawBitmap(src, srcRect.x(), srcRect.y(), &paint);
89 89
90 *result = device.get()->accessBitmap(false); 90 *result = device.get()->accessBitmap(false);
91 offset->fX = dstBounds.fLeft; 91 offset->fX = dstBounds.fLeft;
92 offset->fY = dstBounds.fTop; 92 offset->fY = dstBounds.fTop;
93 return true; 93 return true;
94 } 94 }
95 95
96 void SkMatrixImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons t { 96 void SkMatrixImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons t {
97 SkRect bounds = src; 97 SkRect bounds = src;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 fTransform[SkMatrix::kMTransX], 135 fTransform[SkMatrix::kMTransX],
136 fTransform[SkMatrix::kMSkewY], 136 fTransform[SkMatrix::kMSkewY],
137 fTransform[SkMatrix::kMScaleY], 137 fTransform[SkMatrix::kMScaleY],
138 fTransform[SkMatrix::kMTransY], 138 fTransform[SkMatrix::kMTransY],
139 fTransform[SkMatrix::kMPersp0], 139 fTransform[SkMatrix::kMPersp0],
140 fTransform[SkMatrix::kMPersp1], 140 fTransform[SkMatrix::kMPersp1],
141 fTransform[SkMatrix::kMPersp2]); 141 fTransform[SkMatrix::kMPersp2]);
142 142
143 str->append("<dt>FilterLevel:</dt><dd>"); 143 str->append("<dt>FilterLevel:</dt><dd>");
144 static const char* gFilterLevelStrings[] = { "None", "Low", "Medium", "High" }; 144 static const char* gFilterLevelStrings[] = { "None", "Low", "Medium", "High" };
145 str->append(gFilterLevelStrings[fFilterLevel]); 145 str->append(gFilterLevelStrings[fFilterQuality]);
146 str->append("</dd>"); 146 str->append("</dd>");
147 147
148 str->appendf(")"); 148 str->appendf(")");
149 } 149 }
150 #endif 150 #endif
OLDNEW
« no previous file with comments | « src/effects/SkBitmapSource.cpp ('k') | src/effects/SkPictureImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698