本文整理汇总了C++中sk_throw函数的典型用法代码示例。如果您正苦于以下问题:C++ sk_throw函数的具体用法?C++ sk_throw怎么用?C++ sk_throw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sk_throw函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vm2env
void AndroidPixelRef::globalRef(void* localref) {
if (fWrappedPixelRef) {
// delegate java obj management to the wrapped ref
fWrappedPixelRef->globalRef(localref);
// Note: we only ref and unref the wrapped AndroidPixelRef so that
// bitmap->pixelRef()->globalRef() and globalUnref() can be used in a pair, even if
// the bitmap has its underlying AndroidPixelRef swapped out/wrapped
return;
}
if (fOnJavaHeap && sk_atomic_inc(&fGlobalRefCnt) == 0) {
JNIEnv *env = vm2env(fVM);
// If JNI ref was passed, it is always used
if (localref) fStorageObj = (jbyteArray) localref;
if (fStorageObj == NULL) {
SkDebugf("No valid local ref to create a JNI global ref\n");
sk_throw();
}
if (fHasGlobalRef) {
// This should never happen
SkDebugf("Already holding a JNI global ref");
sk_throw();
}
fStorageObj = (jbyteArray) env->NewGlobalRef(fStorageObj);
// TODO: Check for failure here
fHasGlobalRef = true;
}
ref();
}
示例2: ref_ft_face
static SkFaceRec* ref_ft_face(uint32_t fontID) {
SkFaceRec* rec = gFaceRecHead;
while (rec) {
if (rec->fFontID == fontID) {
SkASSERT(rec->fFace);
rec->fRefCnt += 1;
return rec;
}
rec = rec->fNext;
}
SkStream* strm = SkFontHost::OpenStream(fontID);
if (NULL == strm) {
SkDEBUGF(("SkFontHost::OpenStream failed opening %x\n", fontID));
sk_throw();
return 0;
}
// this passes ownership of strm to the rec
rec = SkNEW_ARGS(SkFaceRec, (strm, fontID));
FT_Open_Args args;
memset(&args, 0, sizeof(args));
const void* memoryBase = strm->getMemoryBase();
if (NULL != memoryBase) {
//printf("mmap(%s)\n", keyString.c_str());
args.flags = FT_OPEN_MEMORY;
args.memory_base = (const FT_Byte*)memoryBase;
args.memory_size = strm->getLength();
} else {
//printf("fopen(%s)\n", keyString.c_str());
args.flags = FT_OPEN_STREAM;
args.stream = &rec->fFTStream;
}
FT_Error err = FT_Open_Face(gFTLibrary, &args, 0, &rec->fFace);
if (err) { // bad filename, try the default font
fprintf(stderr, "ERROR: unable to open font '%x'\n", fontID);
SkDELETE(rec);
sk_throw();
return 0;
} else {
SkASSERT(rec->fFace);
//fprintf(stderr, "Opened font '%s'\n", filename.c_str());
rec->fNext = gFaceRecHead;
gFaceRecHead = rec;
rec->fRefCnt = 1;
return rec;
}
}
示例3: init_skin_anim
void init_skin_anim(const char path[], SkAnimator* anim) {
SkASSERT(path && anim);
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
if (!stream.get()) {
SkDEBUGF(("init_skin_anim: loading skin failed <%s>\n", path));
sk_throw();
}
if (!anim->decodeStream(stream)) {
SkDEBUGF(("init_skin_anim: decoding skin failed <%s>\n", path));
sk_throw();
}
}
示例4: fTotalSize
JavaMemoryUsageReporter::JavaMemoryUsageReporter(JNIEnv* env)
: fTotalSize(0) {
if (env->GetJavaVM(&fVM) != JNI_OK) {
SkDebugf("------ [%p] env->GetJavaVM failed\n", env);
sk_throw();
}
}
示例5: sk_malloc_flags
void* sk_malloc_flags(size_t size, unsigned flags) {
void* p;
#if defined(ANDROID)
// Android doesn't have std::set_new_handler.
p = malloc(size);
#else
if (!(flags & SK_MALLOC_THROW)) {
#if defined(OS_MACOSX) && !defined(OS_IOS)
p = base::UncheckedMalloc(size);
#else
SkAutoMutexAcquire lock(gSkNewHandlerMutex);
std::new_handler old_handler = std::set_new_handler(NULL);
p = malloc(size);
std::set_new_handler(old_handler);
#endif
} else {
p = malloc(size);
}
#endif
if (p == NULL) {
if (flags & SK_MALLOC_THROW) {
sk_throw();
}
}
return p;
}
示例6: SkASSERT
SkFlattenable* SkFlattenableReadBuffer::readFlattenable() {
SkFlattenable::Factory factory = NULL;
if (fFactoryCount > 0) {
int32_t index = this->readU32();
if (0 == index) {
return NULL; // writer failed to give us the flattenable
}
index = -index; // we stored the negative of the index
index -= 1; // we stored the index-base-1
SkASSERT(index < fFactoryCount);
factory = fFactoryArray[index];
} else if (fFactoryTDArray) {
const int32_t* peek = (const int32_t*)this->peek();
if (*peek <= 0) {
int32_t index = this->readU32();
if (0 == index) {
return NULL; // writer failed to give us the flattenable
}
index = -index; // we stored the negative of the index
index -= 1; // we stored the index-base-1
factory = (*fFactoryTDArray)[index];
} else {
const char* name = this->readString();
factory = SkFlattenable::NameToFactory(name);
if (factory) {
SkASSERT(fFactoryTDArray->find(factory) < 0);
*fFactoryTDArray->append() = factory;
} else {
// SkDebugf("can't find factory for [%s]\n", name);
}
// if we didn't find a factory, that's our failure, not the writer's,
// so we fall through, so we can skip the sizeRecorded data.
}
} else {
factory = (SkFlattenable::Factory)readFunctionPtr();
if (NULL == factory) {
return NULL; // writer failed to give us the flattenable
}
}
// if we get here, factory may still be null, but if that is the case, the
// failure was ours, not the writer.
SkFlattenable* obj = NULL;
uint32_t sizeRecorded = this->readU32();
if (factory) {
uint32_t offset = this->offset();
obj = (*factory)(*this);
// check that we read the amount we expected
uint32_t sizeRead = this->offset() - offset;
if (sizeRecorded != sizeRead) {
// we could try to fix up the offset...
sk_throw();
}
} else {
// we must skip the remaining data
this->skip(sizeRecorded);
}
return obj;
}
示例7: load_system_fonts
SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
#if 0
load_system_fonts();
int style = stream->readU8();
int len = stream->readPackedUInt();
if (len > 0) {
SkString str;
str.resize(len);
stream->read(str.writable_str(), len);
const FontInitRec* rec = gSystemFonts;
for (size_t i = 0; i < SK_ARRAY_COUNT(gSystemFonts); i++) {
if (strcmp(rec[i].fFileName, str.c_str()) == 0) {
// backup until we hit the fNames
for (int j = i; j >= 0; --j) {
if (rec[j].fNames != NULL) {
return SkFontHost::CreateTypeface(NULL, rec[j].fNames[0], NULL, 0,
(SkTypeface::Style)style);
}
}
}
}
}
return SkFontHost::CreateTypeface(NULL, NULL, NULL, 0, (SkTypeface::Style)style);
#endif
sk_throw();
return NULL;
}
示例8: fReportSizeToVM
JavaPixelAllocator::JavaPixelAllocator(JNIEnv* env, bool reportSizeToVM)
: fReportSizeToVM(reportSizeToVM) {
if (env->GetJavaVM(&fVM) != JNI_OK) {
SkDebugf("------ [%p] env->GetJavaVM failed\n", env);
sk_throw();
}
}
示例9: fStorageObj
JavaPixelAllocator::JavaPixelAllocator(JNIEnv* env)
: fStorageObj(NULL),
fAllocCount(0) {
if (env->GetJavaVM(&fVM) != JNI_OK) {
SkDebugf("------ [%p] env->GetJavaVM failed\n", env);
sk_throw();
}
}
示例10: sk_malloc_flags
void* sk_malloc_flags(size_t size, unsigned flags) {
void* p = MALLOC(size | ALLOC_NO_ZMEM);
if (p == NULL) {
if (flags & SK_MALLOC_THROW) {
sk_throw();
}
}
return p;
}
示例11: init_skin_anim
void init_skin_anim(const char path[], SkAnimator* anim)
{
SkASSERT(path && anim);
SkFILEStream stream(path);
if (!stream.isValid())
{
SkDEBUGF(("init_skin_anim: loading skin failed <%s>\n", path));
sk_throw();
}
if (!anim->decodeStream(&stream))
{
SkDEBUGF(("init_skin_anim: decoding skin failed <%s>\n", path));
sk_throw();
}
}
示例12: INHERITED
SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffer) {
if (buffer.isVersionLT(SkReadBuffer::kSimplifyLocalMatrix_Version)) {
buffer.readMatrix(&(INHERITED::fLocalMatrix));
}
fProxyShader.reset(buffer.readShader());
if (NULL == fProxyShader.get()) {
sk_throw();
}
}
示例13: sk_new_handler
static void sk_new_handler()
{
if (SkGraphics::SetFontCacheUsed(0))
return;
if (gPrevNewHandler)
gPrevNewHandler();
else
sk_throw();
}
示例14: sk_throw
SkImageInfo GrSurface::info(SkAlphaType alphaType) const {
SkColorType colorType;
SkColorProfileType profileType;
if (!GrPixelConfig2ColorAndProfileType(this->config(), &colorType, &profileType)) {
sk_throw();
}
return SkImageInfo::Make(this->width(), this->height(), colorType, alphaType,
profileType);
}
示例15: sk_throw
SkImageInfo GrSurface::info() const {
SkImageInfo info;
if (!GrPixelConfig2ColorType(this->config(), &info.fColorType)) {
sk_throw();
}
info.fWidth = this->width();
info.fHeight = this->height();
info.fAlphaType = kPremul_SkAlphaType;
return info;
}