epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 8 | #ifndef SkStream_NSData_DEFINED |
| 9 | #define SkStream_NSData_DEFINED |
| 10 | |
| 11 | #import <UIKit/UIKit.h> |
| 12 | #include "SkStream.h" |
| 13 | |
| 14 | /** Returns an NSData with a copy of the stream's data. The caller must call |
| 15 | retain if it intends to keep the data object beyond the current stack-frame |
| 16 | (i.e. internally we're calling [NSData dataWithBytes...] |
| 17 | */ |
| 18 | NSData* NSData_dataWithStream(SkStream* stream); |
| 19 | |
| 20 | /** Returns an NSData from the named resource (from main bundle). |
| 21 | The caller must call retain if it intends to keep the data object beyond |
| 22 | the current stack-frame |
| 23 | (i.e. internally we're calling [NSData dataWithContentsOfMappedFile...] |
| 24 | */ |
| 25 | NSData* NSData_dataFromResource(const char name[], const char suffix[]); |
| 26 | |
| 27 | /** Wrap a stream around NSData. |
| 28 | */ |
| 29 | class SkStream_NSData : public SkMemoryStream { |
| 30 | public: |
| 31 | SkStream_NSData(NSData* data); |
| 32 | virtual ~SkStream_NSData(); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 33 | |
yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 34 | static SkStream_NSData* CreateFromResource(const char name[], |
| 35 | const char suffix[]); |
| 36 | |
| 37 | private: |
| 38 | NSData* fNSData; |
| 39 | }; |
| 40 | |
| 41 | #endif |