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 "SkDevice.h" | 9 #include "SkDevice.h" |
9 #include "SkDeviceProperties.h" | 10 #include "SkDeviceProperties.h" |
10 #include "SkDraw.h" | 11 #include "SkDraw.h" |
11 #include "SkDrawFilter.h" | 12 #include "SkDrawFilter.h" |
12 #include "SkImage_Base.h" | 13 #include "SkImage_Base.h" |
13 #include "SkMetaData.h" | 14 #include "SkMetaData.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" |
| 18 #include "SkRSXform.h" |
17 #include "SkShader.h" | 19 #include "SkShader.h" |
18 #include "SkTextBlob.h" | 20 #include "SkTextBlob.h" |
19 #include "SkTextToPathIter.h" | 21 #include "SkTextToPathIter.h" |
20 | 22 |
21 SkBaseDevice::SkBaseDevice() | 23 SkBaseDevice::SkBaseDevice() |
22 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega
cyLCD_InitType))) | 24 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega
cyLCD_InitType))) |
23 #ifdef SK_DEBUG | 25 #ifdef SK_DEBUG |
24 , fAttachedToCanvas(false) | 26 , fAttachedToCanvas(false) |
25 #endif | 27 #endif |
26 { | 28 { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 175 |
174 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
SkRect* src, | 176 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
SkRect* src, |
175 const SkRect& dst, const SkPaint& paint) { | 177 const SkRect& dst, const SkPaint& paint) { |
176 // Default impl : turns everything into raster bitmap | 178 // Default impl : turns everything into raster bitmap |
177 SkBitmap bm; | 179 SkBitmap bm; |
178 if (as_IB(image)->getROPixels(&bm)) { | 180 if (as_IB(image)->getROPixels(&bm)) { |
179 this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitm
apRectFlag); | 181 this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitm
apRectFlag); |
180 } | 182 } |
181 } | 183 } |
182 | 184 |
| 185 void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR
SXform xform[], |
| 186 const SkRect tex[], const SkColor colors[], int cou
nt, |
| 187 const SkPaint& paint) { |
| 188 SkPath path; |
| 189 for (int i = 0; i < count; ++i) { |
| 190 SkPoint quad[4]; |
| 191 xform[i].toQuad(tex[i].width(), tex[i].height(), quad); |
| 192 |
| 193 SkMatrix localM; |
| 194 localM.setRSXform(xform[i]); |
| 195 localM.preTranslate(-tex[i].left(), -tex[i].top()); |
| 196 |
| 197 SkPaint pnt(paint); |
| 198 pnt.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kCla
mp_TileMode, |
| 199 &localM))->unref(); |
| 200 if (colors) { |
| 201 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(color
s[i], |
| 202 SkXfermode::k
Modulate_Mode)); |
| 203 pnt.setColorFilter(cf); |
| 204 } |
| 205 |
| 206 path.rewind(); |
| 207 path.addPoly(quad, 4, true); |
| 208 this->drawPath(draw, path, pnt, NULL, true); |
| 209 } |
| 210 } |
| 211 |
| 212 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 213 |
183 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt
es, int x, int y) { | 214 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt
es, int x, int y) { |
184 #ifdef SK_DEBUG | 215 #ifdef SK_DEBUG |
185 SkASSERT(info.width() > 0 && info.height() > 0); | 216 SkASSERT(info.width() > 0 && info.height() > 0); |
186 SkASSERT(dstP); | 217 SkASSERT(dstP); |
187 SkASSERT(rowBytes >= info.minRowBytes()); | 218 SkASSERT(rowBytes >= info.minRowBytes()); |
188 SkASSERT(x >= 0 && y >= 0); | 219 SkASSERT(x >= 0 && y >= 0); |
189 | 220 |
190 const SkImageInfo& srcInfo = this->imageInfo(); | 221 const SkImageInfo& srcInfo = this->imageInfo(); |
191 SkASSERT(x + info.width() <= srcInfo.width()); | 222 SkASSERT(x + info.width() <= srcInfo.width()); |
192 SkASSERT(y + info.height() <= srcInfo.height()); | 223 SkASSERT(y + info.height() <= srcInfo.height()); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() | 405 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() |
375 || this->onShouldDisableLCD(paint)) { | 406 || this->onShouldDisableLCD(paint)) { |
376 | 407 |
377 flags &= ~SkPaint::kLCDRenderText_Flag; | 408 flags &= ~SkPaint::kLCDRenderText_Flag; |
378 flags |= SkPaint::kGenA8FromLCD_Flag; | 409 flags |= SkPaint::kGenA8FromLCD_Flag; |
379 } | 410 } |
380 | 411 |
381 return flags; | 412 return flags; |
382 } | 413 } |
383 | 414 |
OLD | NEW |