aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-06-11 16:25:43 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-12 13:56:33 +0000
commitefd99cc92817710117db9924772943b8b78c2fe5 (patch)
tree255256584f7d3d326736c3cc345b9d6c2850bdb2 /src
parente73d7d84d7702d4b3d4a938f8b18d12924889d7b (diff)
clean up SkPicture include
Get SkPicture.h ready for documenting. - remove private methods - move private forward declarations - name parameters R=reed@google.com, bsalomon@google.com Bug: skia:6898 Change-Id: I28829111203d8ae2a4661cf02c99023403aa0df0 Reviewed-on: https://skia-review.googlesource.com/134120 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPicture.cpp16
-rw-r--r--src/core/SkPictureData.cpp5
-rw-r--r--src/core/SkPicturePriv.h39
-rw-r--r--src/core/SkReadBuffer.h2
-rw-r--r--src/core/SkWriteBuffer.h2
-rw-r--r--src/effects/SkPictureImageFilter.cpp5
-rw-r--r--src/shaders/SkPictureShader.cpp6
7 files changed, 58 insertions, 17 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 2325fde864..34fa558ef5 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -8,10 +8,10 @@
#include "SkAtomics.h"
#include "SkImageGenerator.h"
#include "SkMathPriv.h"
-#include "SkPicture.h"
#include "SkPictureCommon.h"
#include "SkPictureData.h"
#include "SkPicturePlayback.h"
+#include "SkPicturePriv.h"
#include "SkPictureRecord.h"
#include "SkPictureRecorder.h"
#include "SkSerialProcs.h"
@@ -198,9 +198,9 @@ sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, const SkDeserialPro
return nullptr;
}
-sk_sp<SkPicture> SkPicture::MakeFromBuffer(SkReadBuffer& buffer) {
+sk_sp<SkPicture> SkPicturePriv::MakeFromBuffer(SkReadBuffer& buffer) {
SkPictInfo info;
- if (!BufferIsSKP(&buffer, &info)) {
+ if (!SkPicture::BufferIsSKP(&buffer, &info)) {
return nullptr;
}
// size should be 0, 1, or negative
@@ -218,7 +218,7 @@ sk_sp<SkPicture> SkPicture::MakeFromBuffer(SkReadBuffer& buffer) {
return nullptr;
}
std::unique_ptr<SkPictureData> data(SkPictureData::CreateFromBuffer(buffer, info));
- return Forwardport(info, data.get(), &buffer);
+ return SkPicture::Forwardport(info, data.get(), &buffer);
}
SkPictureData* SkPicture::backport() const {
@@ -296,15 +296,15 @@ void SkPicture::serialize(SkWStream* stream, const SkSerialProcs* procsPtr,
}
}
-void SkPicture::flatten(SkWriteBuffer& buffer) const {
- SkPictInfo info = this->createHeader();
- std::unique_ptr<SkPictureData> data(this->backport());
+void SkPicturePriv::Flatten(const sk_sp<const SkPicture> picture, SkWriteBuffer& buffer) {
+ SkPictInfo info = picture->createHeader();
+ std::unique_ptr<SkPictureData> data(picture->backport());
buffer.writeByteArray(&info.fMagic, sizeof(info.fMagic));
buffer.writeUInt(info.getVersion());
buffer.writeRect(info.fCullRect);
- if (auto custom = custom_serialize(this, buffer.fProcs)) {
+ if (auto custom = custom_serialize(picture.get(), buffer.fProcs)) {
int32_t size = SkToS32(custom->size());
buffer.write32(-size); // negative for custom format
buffer.writePad32(custom->data(), size);
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 4d927380cc..3d34b27bf6 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -12,6 +12,7 @@
#include "SkMakeUnique.h"
#include "SkPictureData.h"
#include "SkPictureRecord.h"
+#include "SkPicturePriv.h"
#include "SkReadBuffer.h"
#include "SkTextBlob.h"
#include "SkTypeface.h"
@@ -232,7 +233,7 @@ void SkPictureData::flatten(SkWriteBuffer& buffer) const {
if (!fPictures.empty()) {
write_tag_size(buffer, SK_PICT_PICTURE_TAG, fPictures.count());
for (const auto& pic : fPictures) {
- pic->flatten(buffer);
+ SkPicturePriv::Flatten(pic, buffer);
}
}
@@ -440,7 +441,7 @@ void SkPictureData::parseBufferTag(SkReadBuffer& buffer, uint32_t tag, uint32_t
fOpData = std::move(data);
} break;
case SK_PICT_PICTURE_TAG:
- new_array_from_buffer(buffer, size, fPictures, SkPicture::MakeFromBuffer);
+ new_array_from_buffer(buffer, size, fPictures, SkPicturePriv::MakeFromBuffer);
break;
case SK_PICT_DRAWABLE_TAG:
new_array_from_buffer(buffer, size, fDrawables, create_drawable_from_buffer);
diff --git a/src/core/SkPicturePriv.h b/src/core/SkPicturePriv.h
new file mode 100644
index 0000000000..5c772fc9df
--- /dev/null
+++ b/src/core/SkPicturePriv.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPicturePriv_DEFINED
+#define SkPicturePriv_DEFINED
+
+#include "SkPicture.h"
+
+class SkReadBuffer;
+class SkWriteBuffer;
+
+class SkPicturePriv {
+public:
+ /**
+ * Recreate a picture that was serialized into a buffer. If the creation requires bitmap
+ * decoding, the decoder must be set on the SkReadBuffer parameter by calling
+ * SkReadBuffer::setBitmapDecoder() before calling SkPicture::MakeFromBuffer().
+ * @param buffer Serialized picture data.
+ * @return A new SkPicture representing the serialized data, or NULL if the buffer is
+ * invalid.
+ */
+ static sk_sp<SkPicture> MakeFromBuffer(SkReadBuffer& buffer);
+
+ /**
+ * Serialize to a buffer.
+ */
+ static void Flatten(const sk_sp<const SkPicture> , SkWriteBuffer& buffer);
+
+ // Returns NULL if this is not an SkBigPicture.
+ static const SkBigPicture* AsSkBigPicture(const sk_sp<const SkPicture> picture) {
+ return picture->asSkBigPicture();
+ }
+};
+
+#endif
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 5f459cecef..baf8ea143f 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -292,7 +292,7 @@ private:
SkTHashMap<SkString, SkFlattenable::Factory> fCustomFactory;
SkDeserialProcs fProcs;
- friend class SkPicture;
+ friend class SkPicturePriv;
#ifdef DEBUG_NON_DETERMINISTIC_ASSERT
// Debugging counter to keep track of how many bitmaps we
diff --git a/src/core/SkWriteBuffer.h b/src/core/SkWriteBuffer.h
index c3d6f570bf..7be1794c2d 100644
--- a/src/core/SkWriteBuffer.h
+++ b/src/core/SkWriteBuffer.h
@@ -67,7 +67,7 @@ protected:
SkDeduper* fDeduper = nullptr;
SkSerialProcs fProcs;
- friend class SkPicture; // fProcs
+ friend class SkPicturePriv; // fProcs
};
/**
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index df11e6c0df..b9c298dbac 100644
--- a/src/effects/SkPictureImageFilter.cpp
+++ b/src/effects/SkPictureImageFilter.cpp
@@ -12,6 +12,7 @@
#include "SkColorSpaceXformer.h"
#include "SkFlattenablePriv.h"
#include "SkImageSource.h"
+#include "SkPicturePriv.h"
#include "SkReadBuffer.h"
#include "SkSpecialImage.h"
#include "SkSpecialSurface.h"
@@ -58,7 +59,7 @@ sk_sp<SkFlattenable> SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
SkRect cropRect;
if (buffer.readBool()) {
- picture = SkPicture::MakeFromBuffer(buffer);
+ picture = SkPicturePriv::MakeFromBuffer(buffer);
}
buffer.readRect(&cropRect);
@@ -77,7 +78,7 @@ void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
bool hasPicture = (fPicture != nullptr);
buffer.writeBool(hasPicture);
if (hasPicture) {
- fPicture->flatten(buffer);
+ SkPicturePriv::Flatten(fPicture, buffer);
}
buffer.writeRect(fCropRect);
}
diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp
index 576598bfe6..6ff4a0eb12 100644
--- a/src/shaders/SkPictureShader.cpp
+++ b/src/shaders/SkPictureShader.cpp
@@ -15,7 +15,7 @@
#include "SkImage.h"
#include "SkImageShader.h"
#include "SkMatrixUtils.h"
-#include "SkPicture.h"
+#include "SkPicturePriv.h"
#include "SkPictureImageGenerator.h"
#include "SkReadBuffer.h"
#include "SkResourceCache.h"
@@ -157,7 +157,7 @@ sk_sp<SkFlattenable> SkPictureShader::CreateProc(SkReadBuffer& buffer) {
bool didSerialize = buffer.readBool();
if (didSerialize) {
- picture = SkPicture::MakeFromBuffer(buffer);
+ picture = SkPicturePriv::MakeFromBuffer(buffer);
}
return SkPictureShader::Make(picture, mx, my, &lm, &tile);
}
@@ -169,7 +169,7 @@ void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
buffer.writeRect(fTile);
buffer.writeBool(true);
- fPicture->flatten(buffer);
+ SkPicturePriv::Flatten(fPicture, buffer);
}
// Returns a cached image shader, which wraps a single picture tile at the given