本文整理汇总了C++中SkStream::unref方法的典型用法代码示例。如果您正苦于以下问题:C++ SkStream::unref方法的具体用法?C++ SkStream::unref怎么用?C++ SkStream::unref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkStream
的用法示例。
在下文中一共展示了SkStream::unref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: iter
ImageDirView() {
SkImageRef_GlobalPool::SetRAMBudget(320 * 1024);
#ifdef SPECIFIC_IMAGE
fBitmaps = new SkBitmap[3];
fStrings = new SkString[3];
fBitmapCount = 3;
const SkBitmap::Config configs[] = {
SkBitmap::kARGB_8888_Config,
SkBitmap::kRGB_565_Config,
SkBitmap::kARGB_4444_Config
};
for (int i = 0; i < fBitmapCount; i++) {
#if 1
SkStream* stream = new SkFILEStream(SPECIFIC_IMAGE);
SetImageRef(&fBitmaps[i], stream, configs[i], SPECIFIC_IMAGE);
stream->unref();
#else
SkImageDecoder::DecodeFile(SPECIFIC_IMAGE, &fBitmaps[i]);
#endif
}
#else
int i, N = 0;
SkOSFile::Iter iter(IMAGE_DIR, IMAGE_SUFFIX);
SkString name;
while (iter.next(&name)) {
N += 1;
}
fBitmaps = new SkBitmap[N];
fStrings = new SkString[N];
iter.reset(IMAGE_DIR, IMAGE_SUFFIX);
for (i = 0; i < N; i++) {
iter.next(&name);
SkString path(IMAGE_DIR);
path.append(name);
SkStream* stream = new SkFILEStream(path.c_str());
SetImageRef(&fBitmaps[i], stream, SkBitmap::kNo_Config,
name.c_str());
stream->unref();
fStrings[i] = name;
}
fBitmapCount = N;
#endif
fCurrIndex = 0;
fDX = fDY = 0;
fSaturation = SK_Scalar1;
fAngle = 0;
fScale = SK_Scalar1;
}
示例2: Serialize
void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
SkFontDescriptor descriptor;
{
SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
descriptor.setFamilyName(find_family_name(face));
descriptor.setStyle(face->style());
descriptor.setFontFileName(((FamilyTypeface*)face)->getUniqueString());
}
descriptor.serialize(stream);
const bool isCustomFont = !((FamilyTypeface*)face)->isSysFont();
if (isCustomFont) {
// store the entire font in the fontData
SkStream* fontStream = ((FamilyTypeface*)face)->openStream();
const uint32_t length = fontStream->getLength();
stream->writePackedUInt(length);
stream->writeStream(fontStream, length);
fontStream->unref();
} else {
stream->writePackedUInt(0);
}
}
示例3: NativeDecodeStream
ECode Movie::NativeDecodeStream(
/* [in] */ IInputStream* istream,
/* [out] */IMovie** movie)
{
VALIDATE_NOT_NULL(movie);
// NPE_CHECK_RETURN_ZERO(env, istream);
if (istream == NULL) {
*movie = NULL;
return NOERROR;
}
AutoPtr<ArrayOf<Byte> > byteArray = ArrayOf<Byte>::Alloc(16*1024);
// ScopedLocalRef<jbyteArray> scoper(env, byteArray);
SkStream* strm = CreateInputStreamAdaptor(istream, byteArray);
if (NULL == strm) {
*movie = NULL;
return NOERROR;
}
// Need to buffer enough input to be able to rewind as much as might be read by a decoder
// trying to determine the stream's format. The only decoder for movies is GIF, which
// will only read 6.
// FIXME: Get this number from SkImageDecoder
SkAutoTUnref<SkStreamRewindable> bufferedStream(SkFrontBufferedStream::Create(strm, 6));
SkASSERT(bufferedStream.get() != NULL);
SkMovie* moov = SkMovie::DecodeStream(bufferedStream);
strm->unref();
return CreateMovie(moov, movie);
}
示例4: NativeAddFontFromAsset
Boolean FontFamily::NativeAddFontFromAsset(
/* [in] */ Int64 familyPtr,
/* [in] */ IAssetManager* assetMgr,
/* [in] */ const String& path)
{
if (assetMgr == NULL || path.IsNull()) {
return FALSE;
}
android::AssetManager* mgr = (android::AssetManager*)((CAssetManager*)assetMgr)->Ni();
if (NULL == mgr) {
return FALSE;
}
android::Asset* asset = mgr->open(path.string(), android::Asset::ACCESS_BUFFER);
if (NULL == asset) {
return FALSE;
}
SkStream* stream = new AssetStreamAdaptor(asset,
AssetStreamAdaptor::kYes_OwnAsset,
AssetStreamAdaptor::kYes_HasMemoryBase);
SkTypeface* face = SkTypeface::CreateFromStream(stream);
// Note: SkTypeface::CreateFromStream holds its own reference to the stream
stream->unref();
if (face == NULL) {
Logger::E(String("FontFamily"), String("addFontFromAsset failed to create font %s"), path.string());
return FALSE;
}
android::FontFamily* fontFamily = reinterpret_cast<android::FontFamily*>(familyPtr);
return addSkTypeface(fontFamily, face);
}
示例5: Typeface_createFromAsset
static SkTypeface* Typeface_createFromAsset(JNIEnv* env, jobject,
jobject jassetMgr,
jstring jpath) {
NPE_CHECK_RETURN_ZERO(env, jassetMgr);
NPE_CHECK_RETURN_ZERO(env, jpath);
AssetManager* mgr = assetManagerForJavaObject(env, jassetMgr);
if (NULL == mgr) {
return NULL;
}
AutoJavaStringToUTF8 str(env, jpath);
Asset* asset = mgr->open(str.c_str(), Asset::ACCESS_BUFFER);
if (NULL == asset) {
return NULL;
}
SkStream* stream = new AssetStreamAdaptor(asset,
AssetStreamAdaptor::kYes_OwnAsset,
AssetStreamAdaptor::kYes_HasMemoryBase);
SkTypeface* face = SkTypeface::CreateFromStream(stream);
// SkTypeFace::CreateFromStream calls ref() on the stream, so we
// need to unref it here or it won't be freed later on
stream->unref();
return face;
}
示例6: CreateTypefaceFromFile
SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
SkStream* stream = SkNEW_ARGS(SkMMAPStream, (path));
SkTypeface* face = SkFontHost::CreateTypefaceFromStream(stream);
// since we created the stream, we let go of our ref() here
stream->unref();
return face;
}
示例7: OpenStream
SkStream* SkFontHost::OpenStream(uint32_t fontID) {
SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
FamilyTypeface* tf = (FamilyTypeface*)find_from_uniqueID(fontID);
SkStream* stream = tf ? tf->openStream() : NULL;
if (stream && stream->getLength() == 0) {
stream->unref();
stream = NULL;
}
return stream;
}
示例8: nativeDecodeStreamScaled
static jobject nativeDecodeStreamScaled(JNIEnv* env, jobject clazz, jobject is, jbyteArray storage,
jobject padding, jobject options, jboolean applyScale, jfloat scale) {
jobject bitmap = NULL;
SkStream* stream = CreateJavaInputStreamAdaptor(env, is, storage, 0);
if (stream) {
// for now we don't allow purgeable with java inputstreams
bitmap = doDecode(env, stream, padding, options, false, false, applyScale, scale);
stream->unref();
}
return bitmap;
}
示例9: movie_decodeStream
static jobject movie_decodeStream(JNIEnv* env, jobject clazz, jobject istream) {
NPE_CHECK_RETURN_ZERO(env, istream);
// what is the lifetime of the array? Can the skstream hold onto it?
jbyteArray byteArray = env->NewByteArray(16*1024);
SkStream* strm = CreateJavaInputStreamAdaptor(env, istream, byteArray);
if (NULL == strm) {
return 0;
}
SkMovie* moov = SkMovie::DecodeStream(strm);
strm->unref();
return create_jmovie(env, moov);
}
示例10: nativeNewInstanceFromStream
static jobject nativeNewInstanceFromStream(JNIEnv* env, jobject clazz,
jobject is, // InputStream
jbyteArray storage, // byte[]
jboolean isShareable) {
jobject largeBitmap = NULL;
SkStream* stream = CreateJavaInputStreamAdaptor(env, is, storage, 1024);
if (stream) {
// for now we don't allow shareable with java inputstreams
SkMemoryStream *mStream = buildSkMemoryStream(stream);
largeBitmap = doBuildTileIndex(env, mStream);
stream->unref();
}
return largeBitmap;
}
示例11: nativeDecodeStream
static jobject nativeDecodeStream(JNIEnv* env, jobject clazz,
jobject is, // InputStream
jbyteArray storage, // byte[]
jobject padding,
jobject options) { // BitmapFactory$Options
jobject bitmap = NULL;
SkStream* stream = CreateJavaInputStreamAdaptor(env, is, storage, 0);
if (stream) {
// for now we don't allow purgeable with java inputstreams
bitmap = doDecode(env, stream, padding, options, false);
stream->unref();
}
return bitmap;
}
示例12: createFontCustomPlatformData
FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
{
// pass true until we know how we can share the data, and not have to
// make a copy of it.
SkStream* stream = new SkMemoryStream(buffer->data(), buffer->size(), true);
SkTypeface* face = SkTypeface::CreateFromStream(stream);
// Release the stream.
stream->unref();
if (0 == face) {
SkDebugf("--------- SkTypeface::CreateFromBuffer failed %d\n",
buffer->size());
return NULL;
}
SkAutoUnref aur(face);
return new FontCustomPlatformData(face);
}
示例13: Serialize
void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
SkStream* fontStream = ((FamilyTypeface*)face)->openStream();
// store the length of the custom font
uint32_t len = fontStream->getLength();
stream->write32(len);
// store the entire font in the serialized stream
void* fontData = malloc(len);
fontStream->read(fontData, len);
stream->write(fontData, len);
fontStream->unref();
free(fontData);
// sk_throw();
}
示例14: movie_decodeStream
static jobject movie_decodeStream(JNIEnv* env, jobject clazz, jobject istream) {
NPE_CHECK_RETURN_ZERO(env, istream);
jbyteArray byteArray = env->NewByteArray(16*1024);
ScopedLocalRef<jbyteArray> scoper(env, byteArray);
SkStream* strm = CreateJavaInputStreamAdaptor(env, istream, byteArray);
if (NULL == strm) {
return 0;
}
// Need to buffer enough input to be able to rewind as much as might be read by a decoder
// trying to determine the stream's format. The only decoder for movies is GIF, which
// will only read 6.
// FIXME: Get this number from SkImageDecoder
SkAutoTUnref<SkStreamRewindable> bufferedStream(SkFrontBufferedStream::Create(strm, 6));
SkASSERT(bufferedStream.get() != NULL);
SkMovie* moov = SkMovie::DecodeStream(bufferedStream);
strm->unref();
return create_jmovie(env, moov);
}
示例15:
~SkFaceRec() {
fSkStream->unref();
}