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

Unified Diff: src/core/SkReadBuffer.cpp

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: drawVertices and drawTextOnPath Created 4 years, 4 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 5356d4a6b1f47ab27db1ba9d7eb9743403e77da4..2a7096d32c3f0b4a05ca8c83a0ac0552f80eec52 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,7 +304,10 @@ sk_sp<SkImage> SkReadBuffer::readImage() {
}
SkTypeface* SkReadBuffer::readTypeface() {
-
+ if (fInflator) {
+ return SkSafeRef(fInflator->getTypeface(this->read32()));
+ }
+
uint32_t index = fReader.readU32();
if (0 == index || index > (unsigned)fTFCount) {
return nullptr;
@@ -315,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

Powered by Google App Engine
This is Rietveld 408576698