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 "SkMetaData.h" | 13 #include "SkMetaData.h" |
| 14 #include "SkNinePatchIter.h" |
14 #include "SkPatchUtils.h" | 15 #include "SkPatchUtils.h" |
15 #include "SkPathMeasure.h" | 16 #include "SkPathMeasure.h" |
16 #include "SkRasterClip.h" | 17 #include "SkRasterClip.h" |
17 #include "SkRSXform.h" | 18 #include "SkRSXform.h" |
18 #include "SkShader.h" | 19 #include "SkShader.h" |
19 #include "SkTextBlob.h" | 20 #include "SkTextBlob.h" |
20 #include "SkTextToPathIter.h" | 21 #include "SkTextToPathIter.h" |
21 | 22 |
22 SkBaseDevice::SkBaseDevice(const SkSurfaceProps& surfaceProps) | 23 SkBaseDevice::SkBaseDevice(const SkSurfaceProps& surfaceProps) |
23 : fSurfaceProps(surfaceProps) | 24 : fSurfaceProps(surfaceProps) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 155 |
155 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, |
156 const SkRect& dst, const SkPaint& paint) { | 157 const SkRect& dst, const SkPaint& paint) { |
157 // Default impl : turns everything into raster bitmap | 158 // Default impl : turns everything into raster bitmap |
158 SkBitmap bm; | 159 SkBitmap bm; |
159 if (as_IB(image)->getROPixels(&bm)) { | 160 if (as_IB(image)->getROPixels(&bm)) { |
160 this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitm
apRectFlag); | 161 this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitm
apRectFlag); |
161 } | 162 } |
162 } | 163 } |
163 | 164 |
| 165 void SkBaseDevice::drawImageNine(const SkDraw& draw, const SkImage* image, const
SkIRect& center, |
| 166 const SkRect& dst, const SkPaint& paint) { |
| 167 SkNinePatchIter iter(image->width(), image->height(), center, dst); |
| 168 |
| 169 SkRect srcR, dstR; |
| 170 while (iter.next(&srcR, &dstR)) { |
| 171 this->drawImageRect(draw, image, &srcR, dstR, paint); |
| 172 } |
| 173 } |
| 174 |
| 175 void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, co
nst SkIRect& center, |
| 176 const SkRect& dst, const SkPaint& paint) { |
| 177 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst); |
| 178 |
| 179 SkRect srcR, dstR; |
| 180 while (iter.next(&srcR, &dstR)) { |
| 181 this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kNone_D
rawBitmapRectFlag); |
| 182 } |
| 183 } |
| 184 |
164 void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR
SXform xform[], | 185 void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR
SXform xform[], |
165 const SkRect tex[], const SkColor colors[], int cou
nt, | 186 const SkRect tex[], const SkColor colors[], int cou
nt, |
166 SkXfermode::Mode mode, const SkPaint& paint) { | 187 SkXfermode::Mode mode, const SkPaint& paint) { |
167 SkPath path; | 188 SkPath path; |
168 path.setIsVolatile(true); | 189 path.setIsVolatile(true); |
169 | 190 |
170 for (int i = 0; i < count; ++i) { | 191 for (int i = 0; i < count; ++i) { |
171 SkPoint quad[4]; | 192 SkPoint quad[4]; |
172 xform[i].toQuad(tex[i].width(), tex[i].height(), quad); | 193 xform[i].toQuad(tex[i].width(), tex[i].height(), quad); |
173 | 194 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() | 407 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() |
387 || this->onShouldDisableLCD(paint)) { | 408 || this->onShouldDisableLCD(paint)) { |
388 | 409 |
389 flags &= ~SkPaint::kLCDRenderText_Flag; | 410 flags &= ~SkPaint::kLCDRenderText_Flag; |
390 flags |= SkPaint::kGenA8FromLCD_Flag; | 411 flags |= SkPaint::kGenA8FromLCD_Flag; |
391 } | 412 } |
392 | 413 |
393 return flags; | 414 return flags; |
394 } | 415 } |
395 | 416 |
OLD | NEW |