aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkStream.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/core/SkStream.h')
-rw-r--r--include/core/SkStream.h36
1 files changed, 16 insertions, 20 deletions
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 419ef7b723..10929a8343 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -12,6 +12,8 @@
#include "SkRefCnt.h"
#include "SkScalar.h"
+#include <memory.h>
+
class SkStream;
class SkStreamRewindable;
class SkStreamSeekable;
@@ -232,7 +234,6 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
-#include "SkString.h"
#include <stdio.h>
/** A stream that wraps a C FILE* file stream. */
@@ -241,28 +242,20 @@ public:
/** Initialize the stream by calling sk_fopen on the specified path.
* This internal stream will be closed in the destructor.
*/
- explicit SkFILEStream(const char path[] = NULL);
+ explicit SkFILEStream(const char path[] = nullptr);
- enum Ownership {
- kCallerPasses_Ownership,
- kCallerRetains_Ownership
- };
/** Initialize the stream with an existing C file stream.
- * While this stream exists, it assumes exclusive access to the C file stream.
- * The C file stream will be closed in the destructor unless the caller specifies
- * kCallerRetains_Ownership.
+ * The C file stream will be closed in the destructor.
*/
- explicit SkFILEStream(FILE* file, Ownership ownership = kCallerPasses_Ownership);
+ explicit SkFILEStream(FILE* file);
virtual ~SkFILEStream();
/** Returns true if the current path could be opened. */
- bool isValid() const { return fFILE != NULL; }
+ bool isValid() const { return fFILE != nullptr; }
- /** Close the current file, and open a new file with the specified path.
- * If path is NULL, just close the current file.
- */
- void setPath(const char path[]);
+ /** Close this SkFILEStream. */
+ void close();
size_t read(void* buffer, size_t size) override;
bool isAtEnd() const override;
@@ -280,11 +273,14 @@ public:
const void* getMemoryBase() override;
private:
- FILE* fFILE;
- SkString fName;
- Ownership fOwnership;
- // fData is lazilly initialized when needed.
- mutable sk_sp<SkData> fData;
+ explicit SkFILEStream(std::shared_ptr<FILE>, size_t size, size_t offset);
+ explicit SkFILEStream(std::shared_ptr<FILE>, size_t size, size_t offset, size_t originalOffset);
+
+ std::shared_ptr<FILE> fFILE;
+ // My own council will I keep on sizes and offsets.
+ size_t fSize;
+ size_t fOffset;
+ size_t fOriginalOffset;
typedef SkStreamAsset INHERITED;
};