| 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 "SkDevice.h" | 8 #include "SkDevice.h" |
| 9 #include "SkDeviceProperties.h" | 9 #include "SkDeviceProperties.h" |
| 10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
| 11 #include "SkDrawFilter.h" | 11 #include "SkDrawFilter.h" |
| 12 #include "SkImage_Base.h" | |
| 13 #include "SkMetaData.h" | 12 #include "SkMetaData.h" |
| 14 #include "SkPatchUtils.h" | 13 #include "SkPatchUtils.h" |
| 15 #include "SkPathMeasure.h" | 14 #include "SkPathMeasure.h" |
| 16 #include "SkRasterClip.h" | 15 #include "SkRasterClip.h" |
| 17 #include "SkShader.h" | 16 #include "SkShader.h" |
| 18 #include "SkTextBlob.h" | 17 #include "SkTextBlob.h" |
| 19 #include "SkTextToPathIter.h" | 18 #include "SkTextToPathIter.h" |
| 20 | 19 |
| 21 SkBaseDevice::SkBaseDevice() | 20 SkBaseDevice::SkBaseDevice() |
| 22 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega
cyLCD_InitType))) | 21 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega
cyLCD_InitType))) |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 SkFAIL("unhandled positioning mode"); | 158 SkFAIL("unhandled positioning mode"); |
| 160 } | 159 } |
| 161 | 160 |
| 162 if (drawFilter) { | 161 if (drawFilter) { |
| 163 // A draw filter may change the paint arbitrarily, so we must re-see
d in this case. | 162 // A draw filter may change the paint arbitrarily, so we must re-see
d in this case. |
| 164 runPaint = paint; | 163 runPaint = paint; |
| 165 } | 164 } |
| 166 } | 165 } |
| 167 } | 166 } |
| 168 | 167 |
| 169 void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar
x, SkScalar y, | |
| 170 const SkPaint& paint) { | |
| 171 // Default impl : turns everything into raster bitmap | |
| 172 SkBitmap bm; | |
| 173 if (as_IB(image)->getROPixels(&bm)) { | |
| 174 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); | |
| 175 } | |
| 176 } | |
| 177 | |
| 178 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
SkRect* src, | |
| 179 const SkRect& dst, const SkPaint& paint) { | |
| 180 // Default impl : turns everything into raster bitmap | |
| 181 SkBitmap bm; | |
| 182 if (as_IB(image)->getROPixels(&bm)) { | |
| 183 this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitm
apRectFlag); | |
| 184 } | |
| 185 } | |
| 186 | |
| 187 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt
es, int x, int y) { | 168 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt
es, int x, int y) { |
| 188 #ifdef SK_DEBUG | 169 #ifdef SK_DEBUG |
| 189 SkASSERT(info.width() > 0 && info.height() > 0); | 170 SkASSERT(info.width() > 0 && info.height() > 0); |
| 190 SkASSERT(dstP); | 171 SkASSERT(dstP); |
| 191 SkASSERT(rowBytes >= info.minRowBytes()); | 172 SkASSERT(rowBytes >= info.minRowBytes()); |
| 192 SkASSERT(x >= 0 && y >= 0); | 173 SkASSERT(x >= 0 && y >= 0); |
| 193 | 174 |
| 194 const SkImageInfo& srcInfo = this->imageInfo(); | 175 const SkImageInfo& srcInfo = this->imageInfo(); |
| 195 SkASSERT(x + info.width() <= srcInfo.width()); | 176 SkASSERT(x + info.width() <= srcInfo.width()); |
| 196 SkASSERT(y + info.height() <= srcInfo.height()); | 177 SkASSERT(y + info.height() <= srcInfo.height()); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() | 359 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() |
| 379 || this->onShouldDisableLCD(paint)) { | 360 || this->onShouldDisableLCD(paint)) { |
| 380 | 361 |
| 381 flags &= ~SkPaint::kLCDRenderText_Flag; | 362 flags &= ~SkPaint::kLCDRenderText_Flag; |
| 382 flags |= SkPaint::kGenA8FromLCD_Flag; | 363 flags |= SkPaint::kGenA8FromLCD_Flag; |
| 383 } | 364 } |
| 384 | 365 |
| 385 return flags; | 366 return flags; |
| 386 } | 367 } |
| 387 | 368 |
| OLD | NEW |