gfx/skia/trunk/include/utils/ios/SkStream_NSData.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/utils/ios/SkStream_NSData.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2011 Google Inc.
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +#ifndef SkStream_NSData_DEFINED
    1.12 +#define SkStream_NSData_DEFINED
    1.13 +
    1.14 +#import <UIKit/UIKit.h>
    1.15 +#include "SkStream.h"
    1.16 +
    1.17 +/** Returns an NSData with a copy of the stream's data. The caller must call
    1.18 +    retain if it intends to keep the data object beyond the current stack-frame
    1.19 +    (i.e. internally we're calling [NSData dataWithBytes...]
    1.20 + */
    1.21 +NSData* NSData_dataWithStream(SkStream* stream);
    1.22 +
    1.23 +/** Returns an NSData from the named resource (from main bundle).
    1.24 +    The caller must call retain if it intends to keep the data object beyond
    1.25 +    the current stack-frame
    1.26 +    (i.e. internally we're calling [NSData dataWithContentsOfMappedFile...]
    1.27 + */
    1.28 +NSData* NSData_dataFromResource(const char name[], const char suffix[]);
    1.29 +
    1.30 +/** Wrap a stream around NSData.
    1.31 + */
    1.32 +class SkStream_NSData : public SkMemoryStream {
    1.33 +public:
    1.34 +            SkStream_NSData(NSData* data);
    1.35 +    virtual ~SkStream_NSData();
    1.36 +
    1.37 +    static SkStream_NSData* CreateFromResource(const char name[],
    1.38 +                                               const char suffix[]);
    1.39 +
    1.40 +private:
    1.41 +    NSData* fNSData;
    1.42 +};
    1.43 +
    1.44 +#endif

mercurial