Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Unified Diff: src/image/SkImage.cpp

Issue 1784563002: unify peekPixels around pixmap parameter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update GrUploadPixmapToTexture to know about the new desc if readPixels was called Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage.cpp
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 07279501a38df3db1b7e4f5d48d771690f3729d3..5e7cb07226125d0277a2ed31c6b9b8c177e7c192 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -36,17 +36,29 @@ SkImage::SkImage(int width, int height, uint32_t uniqueID)
SkASSERT(height > 0);
}
-const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const {
- SkImageInfo infoStorage;
- size_t rowBytesStorage;
- if (nullptr == info) {
- info = &infoStorage;
+bool SkImage::peekPixels(SkPixmap* pm) const {
+ SkPixmap tmp;
+ if (!pm) {
+ pm = &tmp;
}
- if (nullptr == rowBytes) {
- rowBytes = &rowBytesStorage;
+ return as_IB(this)->onPeekPixels(pm);
+}
+
+#ifdef SK_SUPPORT_LEGACY_PEEKPIXELS_PARMS
+const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const {
+ SkPixmap pm;
+ if (this->peekPixels(&pm)) {
+ if (info) {
+ *info = pm.info();
+ }
+ if (rowBytes) {
+ *rowBytes = pm.rowBytes();
+ }
+ return pm.addr();
}
- return as_IB(this)->onPeekPixels(info, rowBytes);
+ return nullptr;
}
+#endif
bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
int srcX, int srcY, CachingHint chint) const {
@@ -241,19 +253,6 @@ bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, siz
///////////////////////////////////////////////////////////////////////////////////////////////////
-bool SkImage::peekPixels(SkPixmap* pmap) const {
- SkImageInfo info;
- size_t rowBytes;
- const void* pixels = this->peekPixels(&info, &rowBytes);
- if (pixels) {
- if (pmap) {
- pmap->reset(info, pixels, rowBytes);
- }
- return true;
- }
- return false;
-}
-
bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY, CachingHint chint) const {
return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY, chint);
}
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698