| Index: src/core/SkSecureReader32.h
|
| diff --git a/src/core/SkSecureReader32.h b/src/core/SkSecureReader32.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..381cbd80d4591cb8c64cd1a069c37bbe798a0b98
|
| --- /dev/null
|
| +++ b/src/core/SkSecureReader32.h
|
| @@ -0,0 +1,74 @@
|
| +/*
|
| + * 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 SkSecureReader32_DEFINED
|
| +#define SkSecureReader32_DEFINED
|
| +
|
| +#include "SkMatrix.h"
|
| +#include "SkPath.h"
|
| +#include "SkRegion.h"
|
| +#include "SkRRect.h"
|
| +#include "SkScalar.h"
|
| +
|
| +class SkString;
|
| +
|
| +class SkSecureReader32 : SkNoncopyable {
|
| +public:
|
| + SkSecureReader32();
|
| + SkSecureReader32(const void* data, size_t size);
|
| +
|
| + void setMemory(const void* data, size_t size);
|
| +
|
| + uint32_t size() const;
|
| + uint32_t offset() const;
|
| + bool eof() const;
|
| + const void* base() const;
|
| + const void* peek() const;
|
| +
|
| + bool readBool();
|
| +
|
| + int32_t readInt();
|
| +
|
| + SkScalar readScalar();
|
| +
|
| + const void* skip(size_t size);
|
| +
|
| + int32_t readS32();
|
| + uint32_t readU32();
|
| +
|
| + void readPath(SkPath* path);
|
| +
|
| + void readMatrix(SkMatrix* matrix);
|
| +
|
| + void readRegion(SkRegion* rgn);
|
| +
|
| + /**
|
| + * Read the length of a string (written by SkWriter32::writeString) into
|
| + * len (if len is not NULL) and return the null-ternimated address of the
|
| + * string within the reader's buffer.
|
| + */
|
| + const char* readString(size_t* len = NULL);
|
| +
|
| + void setError() { fError = true; }
|
| + bool getError() const { return fError; }
|
| +
|
| +private:
|
| + bool isAvailable(uint32_t size) const;
|
| +
|
| + // these are always 4-byte aligned
|
| + const char* fCurr; // current position within buffer
|
| + const char* fStop; // end of buffer
|
| + const char* fBase; // beginning of buffer
|
| + bool fError;
|
| +
|
| + static bool ptr_align_4(const void* ptr) {
|
| + return (((const char*)ptr - (const char*)NULL) & 3) == 0;
|
| + }
|
| +};
|
| +
|
| +#endif
|
|
|