OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 "SkColorFilter.h" | 8 #include "SkColorFilter.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
11 #include "SkDrawFilter.h" | 11 #include "SkDrawFilter.h" |
12 #include "SkImage_Base.h" | 12 #include "SkImage_Base.h" |
13 #include "SkImageFilter.h" | 13 #include "SkImageFilter.h" |
14 #include "SkImageFilterCache.h" | 14 #include "SkImageFilterCache.h" |
| 15 #include "SkImagePriv.h" |
15 #include "SkLatticeIter.h" | 16 #include "SkLatticeIter.h" |
16 #include "SkMetaData.h" | 17 #include "SkMetaData.h" |
17 #include "SkPatchUtils.h" | 18 #include "SkPatchUtils.h" |
18 #include "SkPathMeasure.h" | 19 #include "SkPathMeasure.h" |
19 #include "SkRasterClip.h" | 20 #include "SkRasterClip.h" |
20 #include "SkRSXform.h" | 21 #include "SkRSXform.h" |
21 #include "SkShader.h" | 22 #include "SkShader.h" |
22 #include "SkSpecialImage.h" | 23 #include "SkSpecialImage.h" |
23 #include "SkTextBlobRunIterator.h" | 24 #include "SkTextBlobRunIterator.h" |
24 #include "SkTextToPathIter.h" | 25 #include "SkTextToPathIter.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 146 |
146 void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar
x, SkScalar y, | 147 void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar
x, SkScalar y, |
147 const SkPaint& paint) { | 148 const SkPaint& paint) { |
148 // Default impl : turns everything into raster bitmap | 149 // Default impl : turns everything into raster bitmap |
149 SkBitmap bm; | 150 SkBitmap bm; |
150 if (as_IB(image)->getROPixels(&bm)) { | 151 if (as_IB(image)->getROPixels(&bm)) { |
151 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); | 152 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); |
152 } | 153 } |
153 } | 154 } |
154 | 155 |
155 void SkBaseDevice::drawImageLattice(const SkDraw& draw, const SkImage* image, | |
156 const SkCanvas::Lattice& lattice, const SkRe
ct& dst, | |
157 const SkPaint& paint) { | |
158 SkLatticeIter iter(image->width(), image->height(), lattice, dst); | |
159 | |
160 SkRect srcR, dstR; | |
161 while (iter.next(&srcR, &dstR)) { | |
162 this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_S
rcRectConstraint); | |
163 } | |
164 } | |
165 | |
166 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
SkRect* src, | 156 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
SkRect* src, |
167 const SkRect& dst, const SkPaint& paint, | 157 const SkRect& dst, const SkPaint& paint, |
168 SkCanvas::SrcRectConstraint constraint) { | 158 SkCanvas::SrcRectConstraint constraint) { |
169 // Default impl : turns everything into raster bitmap | 159 // Default impl : turns everything into raster bitmap |
170 SkBitmap bm; | 160 SkBitmap bm; |
171 if (as_IB(image)->getROPixels(&bm)) { | 161 if (as_IB(image)->getROPixels(&bm)) { |
172 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); | 162 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); |
173 } | 163 } |
174 } | 164 } |
175 | 165 |
(...skipping 10 matching lines...) Expand all Loading... |
186 void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, co
nst SkIRect& center, | 176 void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, co
nst SkIRect& center, |
187 const SkRect& dst, const SkPaint& paint) { | 177 const SkRect& dst, const SkPaint& paint) { |
188 SkLatticeIter iter(bitmap.width(), bitmap.height(), center, dst); | 178 SkLatticeIter iter(bitmap.width(), bitmap.height(), center, dst); |
189 | 179 |
190 SkRect srcR, dstR; | 180 SkRect srcR, dstR; |
191 while (iter.next(&srcR, &dstR)) { | 181 while (iter.next(&srcR, &dstR)) { |
192 this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kStrict
_SrcRectConstraint); | 182 this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kStrict
_SrcRectConstraint); |
193 } | 183 } |
194 } | 184 } |
195 | 185 |
| 186 void SkBaseDevice::drawImageLattice(const SkDraw& draw, const SkImage* image, |
| 187 const SkCanvas::Lattice& lattice, const SkRe
ct& dst, |
| 188 const SkPaint& paint) { |
| 189 SkLatticeIter iter(image->width(), image->height(), lattice, dst); |
| 190 |
| 191 SkRect srcR, dstR; |
| 192 while (iter.next(&srcR, &dstR)) { |
| 193 this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_S
rcRectConstraint); |
| 194 } |
| 195 } |
| 196 |
| 197 void SkBaseDevice::drawBitmapLattice(const SkDraw& draw, const SkBitmap& bitmap, |
| 198 const SkCanvas::Lattice& lattice, const SkR
ect& dst, |
| 199 const SkPaint& paint) { |
| 200 SkLatticeIter iter(bitmap.width(), bitmap.height(), lattice, dst); |
| 201 |
| 202 SkRect srcR, dstR; |
| 203 while (iter.next(&srcR, &dstR)) { |
| 204 this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kStrict
_SrcRectConstraint); |
| 205 } |
| 206 } |
| 207 |
196 void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR
SXform xform[], | 208 void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR
SXform xform[], |
197 const SkRect tex[], const SkColor colors[], int cou
nt, | 209 const SkRect tex[], const SkColor colors[], int cou
nt, |
198 SkXfermode::Mode mode, const SkPaint& paint) { | 210 SkXfermode::Mode mode, const SkPaint& paint) { |
199 SkPath path; | 211 SkPath path; |
200 path.setIsVolatile(true); | 212 path.setIsVolatile(true); |
201 | 213 |
202 for (int i = 0; i < count; ++i) { | 214 for (int i = 0; i < count; ++i) { |
203 SkPoint quad[4]; | 215 SkPoint quad[4]; |
204 xform[i].toQuad(tex[i].width(), tex[i].height(), quad); | 216 xform[i].toQuad(tex[i].width(), tex[i].height(), quad); |
205 | 217 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 535 |
524 // Also log filter quality independent scale factor. | 536 // Also log filter quality independent scale factor. |
525 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor, | 537 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor, |
526 kLast_ScaleFactor + 1); | 538 kLast_ScaleFactor + 1); |
527 | 539 |
528 // Also log an overall histogram of filter quality. | 540 // Also log an overall histogram of filter quality. |
529 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali
ty + 1); | 541 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali
ty + 1); |
530 #endif | 542 #endif |
531 } | 543 } |
532 | 544 |
OLD | NEW |