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

Side by Side Diff: src/effects/SkPictureImageFilter.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/SkMatrixImageFilter.cpp ('k') | src/effects/SkTestImageFilters.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"
11 #include "SkReadBuffer.h" 11 #include "SkReadBuffer.h"
12 #include "SkSurfaceProps.h" 12 #include "SkSurfaceProps.h"
13 #include "SkWriteBuffer.h" 13 #include "SkWriteBuffer.h"
14 #include "SkValidationUtils.h" 14 #include "SkValidationUtils.h"
15 15
16 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, uint32_t un iqueID) 16 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, uint32_t un iqueID)
17 : INHERITED(0, 0, NULL, uniqueID) 17 : INHERITED(0, 0, NULL, uniqueID)
18 , fPicture(SkSafeRef(picture)) 18 , fPicture(SkSafeRef(picture))
19 , fCropRect(picture ? picture->cullRect() : SkRect::MakeEmpty()) 19 , fCropRect(picture ? picture->cullRect() : SkRect::MakeEmpty())
20 , fPictureResolution(kDeviceSpace_PictureResolution) 20 , fPictureResolution(kDeviceSpace_PictureResolution)
21 , fFilterLevel(SkPaint::kLow_FilterLevel) { 21 , fFilterQuality(kLow_SkFilterQuality) {
22 } 22 }
23 23
24 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, const SkRec t& cropRect, 24 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, const SkRec t& cropRect,
25 uint32_t uniqueID, PictureResolution pictureResolution, 25 uint32_t uniqueID, PictureResolution pictureResolution,
26 SkPaint::FilterLevel filterLevel) 26 SkFilterQuality filterQuality)
27 : INHERITED(0, 0, NULL, uniqueID) 27 : INHERITED(0, 0, NULL, uniqueID)
28 , fPicture(SkSafeRef(picture)) 28 , fPicture(SkSafeRef(picture))
29 , fCropRect(cropRect) 29 , fCropRect(cropRect)
30 , fPictureResolution(pictureResolution) 30 , fPictureResolution(pictureResolution)
31 , fFilterLevel(filterLevel) { 31 , fFilterQuality(filterQuality) {
32 } 32 }
33 33
34 SkPictureImageFilter::~SkPictureImageFilter() { 34 SkPictureImageFilter::~SkPictureImageFilter() {
35 SkSafeUnref(fPicture); 35 SkSafeUnref(fPicture);
36 } 36 }
37 37
38 SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) { 38 SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
39 SkAutoTUnref<SkPicture> picture; 39 SkAutoTUnref<SkPicture> picture;
40 SkRect cropRect; 40 SkRect cropRect;
41 41
(...skipping 10 matching lines...) Expand all
52 buffer.readRect(&cropRect); 52 buffer.readRect(&cropRect);
53 PictureResolution pictureResolution; 53 PictureResolution pictureResolution;
54 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) { 54 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) {
55 pictureResolution = kDeviceSpace_PictureResolution; 55 pictureResolution = kDeviceSpace_PictureResolution;
56 } else { 56 } else {
57 pictureResolution = (PictureResolution)buffer.readInt(); 57 pictureResolution = (PictureResolution)buffer.readInt();
58 } 58 }
59 59
60 if (kLocalSpace_PictureResolution == pictureResolution) { 60 if (kLocalSpace_PictureResolution == pictureResolution) {
61 //filterLevel is only serialized if pictureResolution is LocalSpace 61 //filterLevel is only serialized if pictureResolution is LocalSpace
62 SkPaint::FilterLevel filterLevel; 62 SkFilterQuality filterQuality;
63 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) { 63 if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) {
64 filterLevel = SkPaint::kLow_FilterLevel; 64 filterQuality = kLow_SkFilterQuality;
65 } else { 65 } else {
66 filterLevel = (SkPaint::FilterLevel)buffer.readInt(); 66 filterQuality = (SkFilterQuality)buffer.readInt();
67 } 67 }
68 return CreateForLocalSpace(picture, cropRect, filterLevel); 68 return CreateForLocalSpace(picture, cropRect, filterQuality);
69 } 69 }
70 return Create(picture, cropRect); 70 return Create(picture, cropRect);
71 } 71 }
72 72
73 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { 73 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
74 #ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS 74 #ifdef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
75 if (buffer.isCrossProcess()) { 75 if (buffer.isCrossProcess()) {
76 buffer.writeBool(false); 76 buffer.writeBool(false);
77 } else 77 } else
78 #endif 78 #endif
79 { 79 {
80 bool hasPicture = (fPicture != NULL); 80 bool hasPicture = (fPicture != NULL);
81 buffer.writeBool(hasPicture); 81 buffer.writeBool(hasPicture);
82 if (hasPicture) { 82 if (hasPicture) {
83 fPicture->flatten(buffer); 83 fPicture->flatten(buffer);
84 } 84 }
85 } 85 }
86 buffer.writeRect(fCropRect); 86 buffer.writeRect(fCropRect);
87 buffer.writeInt(fPictureResolution); 87 buffer.writeInt(fPictureResolution);
88 if (kLocalSpace_PictureResolution == fPictureResolution) { 88 if (kLocalSpace_PictureResolution == fPictureResolution) {
89 buffer.writeInt(fFilterLevel); 89 buffer.writeInt(fFilterQuality);
90 } 90 }
91 } 91 }
92 92
93 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co ntext& ctx, 93 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co ntext& ctx,
94 SkBitmap* result, SkIPoint* offset) con st { 94 SkBitmap* result, SkIPoint* offset) con st {
95 if (!fPicture) { 95 if (!fPicture) {
96 offset->fX = offset->fY = 0; 96 offset->fX = offset->fY = 0;
97 return true; 97 return true;
98 } 98 }
99 99
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 localCanvas.drawPicture(fPicture); 161 localCanvas.drawPicture(fPicture);
162 162
163 // Pass explicit surface props, as the simplified canvas constructor discard s device properties. 163 // Pass explicit surface props, as the simplified canvas constructor discard s device properties.
164 // FIXME: switch back to the public constructor (and unfriend) after 164 // FIXME: switch back to the public constructor (and unfriend) after
165 // https://code.google.com/p/skia/issues/detail?id=3142 is fixed. 165 // https://code.google.com/p/skia/issues/detail?id=3142 is fixed.
166 SkCanvas canvas(device, proxy->surfaceProps(), SkCanvas::kDefault_InitFlags) ; 166 SkCanvas canvas(device, proxy->surfaceProps(), SkCanvas::kDefault_InitFlags) ;
167 167
168 canvas.translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBo unds.fTop)); 168 canvas.translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBo unds.fTop));
169 canvas.concat(ctx.ctm()); 169 canvas.concat(ctx.ctm());
170 SkPaint paint; 170 SkPaint paint;
171 paint.setFilterLevel(fFilterLevel); 171 paint.setFilterQuality(fFilterQuality);
172 canvas.drawBitmap(localDevice.get()->accessBitmap(false), SkIntToScalar(loca lIBounds.fLeft), 172 canvas.drawBitmap(localDevice.get()->accessBitmap(false), SkIntToScalar(loca lIBounds.fLeft),
173 SkIntToScalar(localIBounds.fTop), &paint); 173 SkIntToScalar(localIBounds.fTop), &paint);
174 //canvas.drawPicture(fPicture); 174 //canvas.drawPicture(fPicture);
175 } 175 }
176 176
177 #ifndef SK_IGNORE_TO_STRING 177 #ifndef SK_IGNORE_TO_STRING
178 void SkPictureImageFilter::toString(SkString* str) const { 178 void SkPictureImageFilter::toString(SkString* str) const {
179 str->appendf("SkPictureImageFilter: ("); 179 str->appendf("SkPictureImageFilter: (");
180 str->appendf("crop: (%f,%f,%f,%f) ", 180 str->appendf("crop: (%f,%f,%f,%f) ",
181 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB ottom); 181 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB ottom);
182 if (fPicture) { 182 if (fPicture) {
183 str->appendf("picture: (%f,%f,%f,%f)", 183 str->appendf("picture: (%f,%f,%f,%f)",
184 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, 184 fPicture->cullRect().fLeft, fPicture->cullRect().fTop,
185 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); 185 fPicture->cullRect().fRight, fPicture->cullRect().fBottom);
186 } 186 }
187 str->append(")"); 187 str->append(")");
188 } 188 }
189 #endif 189 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMatrixImageFilter.cpp ('k') | src/effects/SkTestImageFilters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698