OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
985 | 985 |
986 SkSurface* SkCanvas::newSurface(const SkImageInfo& info) { | 986 SkSurface* SkCanvas::newSurface(const SkImageInfo& info) { |
987 return this->onNewSurface(info); | 987 return this->onNewSurface(info); |
988 } | 988 } |
989 | 989 |
990 SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info) { | 990 SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info) { |
991 SkBaseDevice* dev = this->getDevice(); | 991 SkBaseDevice* dev = this->getDevice(); |
992 return dev ? dev->newSurface(info) : NULL; | 992 return dev ? dev->newSurface(info) : NULL; |
993 } | 993 } |
994 | 994 |
995 SkImageInfo SkCanvas::imageInfo() const { | |
996 SkBaseDevice* dev = this->getDevice(); | |
997 if (dev) { | |
998 return dev->imageInfo(); | |
999 } else { | |
1000 // TODO: need a real unknown for alphatype it seems. | |
1001 SkAlphaType unknownAlphaType = kIgnore_SkAlphaType; | |
1002 return SkImageInfo::Make(0, 0, kUnknown_SkColorType, unknownAlphaType); | |
1003 } | |
1004 } | |
1005 | |
1006 const void* SkCanvas::peekPixels(SkImageInfo* info, size_t* rowBytes) { | |
1007 return this->onPeekPixels(info, rowBytes); | |
1008 } | |
1009 | |
1010 const void* SkCanvas::onPeekPixels(SkImageInfo* info, size_t* rowBytes) { | |
1011 SkBaseDevice* dev = this->getDevice(); | |
1012 return dev ? dev->peekPixels(info, rowBytes) : NULL; | |
1013 } | |
1014 | |
1015 SkAutoROCanvasPixels::SkAutoROCanvasPixels(SkCanvas* canvas) { | |
1016 #if 1 | |
1017 fAddr = canvas->peekPixels(&fInfo, &fRowBytes); | |
1018 if (NULL == fAddr) { | |
1019 fInfo = canvas->imageInfo(); | |
1020 if (!fBitmap.allocPixels(fInfo)) { | |
1021 return; // failure, fAddr is NULL | |
1022 } | |
1023 fBitmap.lockPixels(); | |
1024 if (!canvas->readPixels(&fBitmap, 0, 0)) { | |
1025 return; // failure, fAddr is NULL | |
1026 } | |
1027 fAddr = fBitmap.getPixels(); | |
1028 fRowBytes = fBitmap.rowBytes(); | |
1029 } | |
1030 SkASSERT(fAddr); // success | |
1031 #else | |
1032 const SkBitmap& bm = canvas->getDevice()->accessBitmap(false); | |
scroggo
2014/02/12 18:40:58
Is this just here for comparison?
reed2
2014/02/13 14:43:35
Just for local testing, will remove.
| |
1033 bm.lockPixels(); | |
1034 fAddr = bm.getPixels(); | |
1035 fInfo = bm.info(); | |
1036 fRowBytes = bm.rowBytes(); | |
1037 #endif | |
1038 } | |
1039 | |
995 ///////////////////////////////////////////////////////////////////////////// | 1040 ///////////////////////////////////////////////////////////////////////////// |
996 | 1041 |
997 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap, | 1042 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap, |
998 const SkMatrix& matrix, const SkPaint* paint) { | 1043 const SkMatrix& matrix, const SkPaint* paint) { |
999 if (bitmap.drawsNothing()) { | 1044 if (bitmap.drawsNothing()) { |
1000 return; | 1045 return; |
1001 } | 1046 } |
1002 | 1047 |
1003 SkLazyPaint lazy; | 1048 SkLazyPaint lazy; |
1004 if (NULL == paint) { | 1049 if (NULL == paint) { |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2232 return *paint; | 2277 return *paint; |
2233 } | 2278 } |
2234 | 2279 |
2235 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } | 2280 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } |
2236 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } | 2281 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } |
2237 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } | 2282 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } |
2238 | 2283 |
2239 /////////////////////////////////////////////////////////////////////////////// | 2284 /////////////////////////////////////////////////////////////////////////////// |
2240 | 2285 |
2241 SkCanvas::ClipVisitor::~ClipVisitor() { } | 2286 SkCanvas::ClipVisitor::~ClipVisitor() { } |
OLD | NEW |