diff options
author | 2017-03-10 13:08:15 -0500 | |
---|---|---|
committer | 2017-03-10 19:58:46 +0000 | |
commit | 4d1955c43aaab045511b74a495dfbea4ef0057c5 (patch) | |
tree | 23d0f457f69b98bde35dc9a3afa32451ee5f6694 /include/core/SkStream.h | |
parent | dc9f0dbe4cdcdf6fead5fc28532d58f7d998a447 (diff) |
Fix SkFILEStream.
Change-Id: I8c66e4e3e857227aed3d0bc497982f4c0d96d917
Reviewed-on: https://skia-review.googlesource.com/9498
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'include/core/SkStream.h')
-rw-r--r-- | include/core/SkStream.h | 36 |
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; }; |