* will handle calling munmap().
*/
static SkData* NewFromMMap(const void* data, size_t length);
-
+
/**
* Create a new dataref using a subset of the data in the specified
* src dataref.
* returned object. On failure, returns NULL.
*/
static SkStream* NewFromFile(const char path[]);
-
+
SK_DECLARE_INST_COUNT(SkStream)
/** Called to rewind to the beginning of the stream. If this cannot be
}
#ifdef SK_DEVELOPER
- virtual void toString(SkString* str) const SK_OVERRIDE {
- str->append("Darken: (");
+ virtual void toString(SkString* str) const SK_OVERRIDE {
+ str->append("Darken: (");
this->INHERITED::toString(str);
str->append(")");
}
gEmptySet->ref();
return gEmptySet;
}
-
if (fd < 0) {
return false;
}
-
+
off_t offset = lseek(fd, 0, SEEK_END); // find the file size
if (offset == -1) {
close(fd);
return false;
}
(void)lseek(fd, 0, SEEK_SET); // restore file offset to beginning
-
+
// to avoid a 64bit->32bit warning, I explicitly create a size_t size
size_t size = static_cast<size_t>(offset);
-
+
void* addr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
close(fd);
-
+
if (MAP_FAILED == addr) {
return false;
}
-
+
*addrPtr = addr;
*sizePtr = size;
return true;
return SkNEW_ARGS(SkMemoryStream, (data.get()));
}
}
-
+
// If we get here, then our attempt at using mmap failed, so try normal
// file access.
SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path));
}
return stream;
}
-
str->append("flags: (");
if (fBlurFlags) {
bool needSeparator = false;
- SkAddFlagToString(str,
- SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag),
+ SkAddFlagToString(str,
+ SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag),
"IgnoreXform", &needSeparator);
- SkAddFlagToString(str,
- SkToBool(fBlurFlags & SkBlurMaskFilter::kHighQuality_BlurFlag),
+ SkAddFlagToString(str,
+ SkToBool(fBlurFlags & SkBlurMaskFilter::kHighQuality_BlurFlag),
"HighQuality", &needSeparator);
} else {
str->append("None");
str->appendScalar(fLight.fDirection[2]);
str->append(") ");
- str->appendf("ambient: %d specular: %d ",
+ str->appendf("ambient: %d specular: %d ",
fLight.fAmbient, fLight.fSpecular);
str->append("blurRadius: ");