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

Unified Diff: src/core/SkReadBuffer.cpp

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test for writeImage Created 4 years, 3 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
Index: src/core/SkReadBuffer.cpp
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 43eaf2026134c7832aa0213c50424ca5d33ff008..4b9d5987a173607c8d530d44400f7398165f2897 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -6,6 +6,7 @@
*/
#include "SkBitmap.h"
+#include "SkDeduper.h"
#include "SkErrorInternals.h"
#include "SkImage.h"
#include "SkImageDeserializer.h"
@@ -258,6 +259,11 @@ sk_sp<SkImage> SkReadBuffer::readBitmapAsImage() {
}
sk_sp<SkImage> SkReadBuffer::readImage() {
+ if (fInflator) {
+ SkImage* img = fInflator->getImage(this->read32());
+ return img ? sk_ref_sp(img) : nullptr;
+ }
+
int width = this->read32();
int height = this->read32();
if (width <= 0 || height <= 0) { // SkImage never has a zero dimension
@@ -298,6 +304,10 @@ sk_sp<SkImage> SkReadBuffer::readImage() {
}
sk_sp<SkTypeface> SkReadBuffer::readTypeface() {
+ if (fInflator) {
+ return sk_ref_sp(fInflator->getTypeface(this->read32()));
+ }
+
uint32_t index = fReader.readU32();
if (0 == index || index > (unsigned)fTFCount) {
return nullptr;
@@ -314,7 +324,12 @@ SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) {
SkFlattenable::Factory factory = nullptr;
- if (fFactoryCount > 0) {
+ if (fInflator) {
+ factory = fInflator->getFactory(this->read32());
+ if (!factory) {
+ return nullptr;
+ }
+ } else if (fFactoryCount > 0) {
int32_t index = fReader.readU32();
if (0 == index) {
return nullptr; // writer failed to give us the flattenable
« src/core/SkPipe.h ('K') | « src/core/SkReadBuffer.h ('k') | src/core/SkWriteBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698