aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkStreamPriv.h
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2014-06-27 11:36:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-27 11:36:20 -0700
commit67ec1f8eecfb48bc0a6ba04c0057f103c1c9696f (patch)
tree44826f6816c7d0ca8f1fdd7f92e2a70f0dd33e1d /src/core/SkStreamPriv.h
parent89443aba5bfa2b040dc9fd24938b7d0b3decd737 (diff)
Switch SkPDFStream's internal storage from SkStream to SkData
Motivation: This makes SkPDFStream thread-safe for two threads serializing it at once, since a SkStream has an internal position. Updated SkPDFFont, SkPDFGraphicState, and SkPDFPage's use of SkPDFStream to use the SkData constructor rather than the SkStream constructor (saving a memcpy). BUG=skia:2683 Committed: https://skia.googlesource.com/skia/+/c1dfa14b645ae274780f026dd86c9b633fbdad06 R=mtklein@google.com, djsollen@google.com, rmistry@google.com, robertphillips@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/340783013
Diffstat (limited to 'src/core/SkStreamPriv.h')
-rw-r--r--src/core/SkStreamPriv.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/core/SkStreamPriv.h b/src/core/SkStreamPriv.h
new file mode 100644
index 0000000000..5b5a73adef
--- /dev/null
+++ b/src/core/SkStreamPriv.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkStreamPriv_DEFINED
+#define SkStreamPriv_DEFINED
+
+class SkAutoMalloc;
+class SkStream;
+class SkData;
+
+/**
+ * Copy the provided stream to memory allocated by storage.
+ * Used by SkImageDecoder_libbmp and SkImageDecoder_libico.
+ * @param storage Allocator to hold the memory. Will be reset to be large
+ * enough to hold the entire stream. Upon successful return,
+ * storage->get() will point to data holding the SkStream's entire
+ * contents.
+ * @param stream SkStream to be copied into storage.
+ * @return size_t Total number of bytes in the SkStream, which is also the
+ * number of bytes pointed to by storage->get(). Returns 0 on failure.
+ */
+size_t SkCopyStreamToStorage(SkAutoMalloc* storage, SkStream* stream);
+
+/**
+ * Copy the provided stream to an SkData variable.
+ * @param stream SkStream to be copied into data.
+ * @return SkData* The resulting SkData after the copy. This data
+ * will have a ref count of one upon return and belongs to the
+ * caller. Returns NULL on failure.
+ */
+SkData *SkCopyStreamToData(SkStream* stream);
+
+#endif // SkStreamPriv_DEFINED