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

Unified Diff: src/image/SkImage.cpp

Issue 1199473002: change old picture serialization to really handle images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix check in new_array function Created 5 years, 6 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/core/SkWriteBuffer.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 66756cb512d99beb8dbf6708536194c588e939e2..5e7d1b91506142804d886d245f7cba142686c9ee 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -7,6 +7,7 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
+#include "SkData.h"
#include "SkImageGenerator.h"
#include "SkImagePriv.h"
#include "SkImage_Base.h"
@@ -64,12 +65,16 @@ SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const {
return NULL;
}
-SkImage* SkImage::NewFromData(SkData* data) {
- if (NULL == data) {
+SkData* SkImage::refEncoded() const {
+ return as_IB(this)->onRefEncoded();
+}
+
+SkImage* SkImage::NewFromEncoded(SkData* encoded, const SkIRect* subset) {
+ if (NULL == encoded || 0 == encoded->size()) {
return NULL;
}
- SkImageGenerator* generator = SkImageGenerator::NewFromData(data);
- return generator ? SkImage::NewFromGenerator(generator) : NULL;
+ SkImageGenerator* generator = SkImageGenerator::NewFromData(encoded);
+ return generator ? SkImage::NewFromGenerator(generator, subset) : NULL;
}
SkSurface* SkImage::newSurface(const SkImageInfo& info, const SkSurfaceProps* props) const {
@@ -201,7 +206,26 @@ SkImage* SkImage_Base::onNewImage(int newWidth, int newHeight, const SkIRect* su
return surface->newImageSnapshot();
}
-//////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+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) const {
+ return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
#if !SK_SUPPORT_GPU
« no previous file with comments | « src/core/SkWriteBuffer.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698