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

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

Issue 1823573003: Change signatures of filter bounds methods to return a rect. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Hide legacy API behind #ifdef; switch callers to new API Created 4 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
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"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 84 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
85 paint.setFilterQuality(fFilterQuality); 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 SkRect SkMatrixImageFilter::computeFastBounds(const SkRect& src) const {
95 SkRect bounds = src; 95 SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src ) : src;
96 if (getInput(0)) { 96 SkRect dst;
97 getInput(0)->computeFastBounds(src, &bounds); 97 fTransform.mapRect(&dst, bounds);
98 } 98 return dst;
99 fTransform.mapRect(dst, bounds);
100 } 99 }
101 100
102 void SkMatrixImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, 101 SkIRect SkMatrixImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatr ix& ctm,
103 SkIRect* dst, MapDirection directio n) const { 102 MapDirection direction) const {
104 SkMatrix matrix; 103 SkMatrix matrix;
105 if (!ctm.invert(&matrix)) { 104 if (!ctm.invert(&matrix)) {
106 *dst = src; 105 return src;
107 return;
108 } 106 }
109 if (kForward_MapDirection == direction) { 107 if (kForward_MapDirection == direction) {
110 matrix.postConcat(fTransform); 108 matrix.postConcat(fTransform);
111 } else { 109 } else {
112 SkMatrix transformInverse; 110 SkMatrix transformInverse;
113 if (!fTransform.invert(&transformInverse)) { 111 if (!fTransform.invert(&transformInverse)) {
114 *dst = src; 112 return src;
115 return;
116 } 113 }
117 matrix.postConcat(transformInverse); 114 matrix.postConcat(transformInverse);
118 } 115 }
119 matrix.postConcat(ctm); 116 matrix.postConcat(ctm);
120 SkRect floatBounds; 117 SkRect floatBounds;
121 matrix.mapRect(&floatBounds, SkRect::Make(src)); 118 matrix.mapRect(&floatBounds, SkRect::Make(src));
122 SkIRect bounds = floatBounds.roundOut(); 119 return floatBounds.roundOut();
123 *dst = bounds;
124 } 120 }
125 121
126 #ifndef SK_IGNORE_TO_STRING 122 #ifndef SK_IGNORE_TO_STRING
127 void SkMatrixImageFilter::toString(SkString* str) const { 123 void SkMatrixImageFilter::toString(SkString* str) const {
128 str->appendf("SkMatrixImageFilter: ("); 124 str->appendf("SkMatrixImageFilter: (");
129 125
130 str->appendf("transform: (%f %f %f %f %f %f %f %f %f)", 126 str->appendf("transform: (%f %f %f %f %f %f %f %f %f)",
131 fTransform[SkMatrix::kMScaleX], 127 fTransform[SkMatrix::kMScaleX],
132 fTransform[SkMatrix::kMSkewX], 128 fTransform[SkMatrix::kMSkewX],
133 fTransform[SkMatrix::kMTransX], 129 fTransform[SkMatrix::kMTransX],
134 fTransform[SkMatrix::kMSkewY], 130 fTransform[SkMatrix::kMSkewY],
135 fTransform[SkMatrix::kMScaleY], 131 fTransform[SkMatrix::kMScaleY],
136 fTransform[SkMatrix::kMTransY], 132 fTransform[SkMatrix::kMTransY],
137 fTransform[SkMatrix::kMPersp0], 133 fTransform[SkMatrix::kMPersp0],
138 fTransform[SkMatrix::kMPersp1], 134 fTransform[SkMatrix::kMPersp1],
139 fTransform[SkMatrix::kMPersp2]); 135 fTransform[SkMatrix::kMPersp2]);
140 136
141 str->append("<dt>FilterLevel:</dt><dd>"); 137 str->append("<dt>FilterLevel:</dt><dd>");
142 static const char* gFilterLevelStrings[] = { "None", "Low", "Medium", "High" }; 138 static const char* gFilterLevelStrings[] = { "None", "Low", "Medium", "High" };
143 str->append(gFilterLevelStrings[fFilterQuality]); 139 str->append(gFilterLevelStrings[fFilterQuality]);
144 str->append("</dd>"); 140 str->append("</dd>");
145 141
146 str->appendf(")"); 142 str->appendf(")");
147 } 143 }
148 #endif 144 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698