michael@0: michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #ifndef SkStream_NSData_DEFINED michael@0: #define SkStream_NSData_DEFINED michael@0: michael@0: #import michael@0: #include "SkStream.h" michael@0: michael@0: /** Returns an NSData with a copy of the stream's data. The caller must call michael@0: retain if it intends to keep the data object beyond the current stack-frame michael@0: (i.e. internally we're calling [NSData dataWithBytes...] michael@0: */ michael@0: NSData* NSData_dataWithStream(SkStream* stream); michael@0: michael@0: /** Returns an NSData from the named resource (from main bundle). michael@0: The caller must call retain if it intends to keep the data object beyond michael@0: the current stack-frame michael@0: (i.e. internally we're calling [NSData dataWithContentsOfMappedFile...] michael@0: */ michael@0: NSData* NSData_dataFromResource(const char name[], const char suffix[]); michael@0: michael@0: /** Wrap a stream around NSData. michael@0: */ michael@0: class SkStream_NSData : public SkMemoryStream { michael@0: public: michael@0: SkStream_NSData(NSData* data); michael@0: virtual ~SkStream_NSData(); michael@0: michael@0: static SkStream_NSData* CreateFromResource(const char name[], michael@0: const char suffix[]); michael@0: michael@0: private: michael@0: NSData* fNSData; michael@0: }; michael@0: michael@0: #endif