本文整理汇总了C++中SkPicture::cullRect方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPicture::cullRect方法的具体用法?C++ SkPicture::cullRect怎么用?C++ SkPicture::cullRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPicture
的用法示例。
在下文中一共展示了SkPicture::cullRect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inspect
static SkPicture* inspect(const char path[]) {
SkFILEStream stream(path);
if (!stream.isValid()) {
printf("-- Can't open '%s'\n", path);
return nullptr;
}
printf("Opening '%s'...\n", path);
{
int32_t header[3];
if (stream.read(header, sizeof(header)) != sizeof(header)) {
printf("-- Failed to read header (12 bytes)\n");
return nullptr;
}
printf("version:%d width:%d height:%d\n", header[0], header[1], header[2]);
}
stream.rewind();
SkPicture* pic = SkPicture::CreateFromStream(&stream);
if (nullptr == pic) {
SkDebugf("Could not create SkPicture: %s\n", path);
return nullptr;
}
printf("picture cullRect: [%f %f %f %f]\n",
pic->cullRect().fLeft, pic->cullRect().fTop,
pic->cullRect().fRight, pic->cullRect().fBottom);
return pic;
}
示例2: draw_picture
static SkBitmap draw_picture(SkPicture& picture) {
SkBitmap bitmap;
bitmap.allocN32Pixels(SkScalarCeilToInt(picture.cullRect().width()),
SkScalarCeilToInt(picture.cullRect().height()));
SkCanvas canvas(bitmap);
picture.playback(&canvas);
return bitmap;
}
示例3: rerecord
static void rerecord(const SkPicture& src, SkBBHFactory* bbhFactory) {
SkPictureRecorder recorder;
if (FLAGS_skr) {
src.playback(recorder.EXPERIMENTAL_beginRecording(src.cullRect().width(),
src.cullRect().height(),
bbhFactory));
} else {
src.playback(recorder. DEPRECATED_beginRecording(src.cullRect().width(),
src.cullRect().height(),
bbhFactory));
}
SkAutoTUnref<SkPicture> pic(recorder.endRecording());
}
示例4:
PassRefPtr<JSONObject> LoggingCanvas::objectForSkPicture(const SkPicture& picture)
{
const SkIRect bounds = picture.cullRect().roundOut();
RefPtr<JSONObject> pictureItem = JSONObject::create();
pictureItem->setNumber("width", bounds.width());
pictureItem->setNumber("height", bounds.height());
return pictureItem.release();
}
示例5: check_pattern
// Do the commands in 'input' match the supplied pattern? Note: this is a pretty
// heavy-weight operation since we are drawing the picture into a debug canvas
// to extract the commands.
static bool check_pattern(SkPicture& input, const SkTDArray<DrawType> &pattern) {
SkDebugCanvas debugCanvas(SkScalarCeilToInt(input.cullRect().width()),
SkScalarCeilToInt(input.cullRect().height()));
input.draw(&debugCanvas);
if (pattern.count() != debugCanvas.getSize()) {
return false;
}
for (int i = 0; i < pattern.count(); ++i) {
if (pattern[i] != debugCanvas.getDrawCommandAt(i)->getType()) {
return false;
}
}
return true;
}
示例6: testOne
void TestResult::testOne() {
SkPicture* pic = nullptr;
{
#if DEBUG_SHOW_TEST_NAME
if (fTestStep == kCompareBits) {
SkString testName(fFilename);
const char http[] = "http";
if (testName.startsWith(http)) {
testName.remove(0, sizeof(http) - 1);
}
while (testName.startsWith("_")) {
testName.remove(0, 1);
}
const char dotSkp[] = ".skp";
if (testName.endsWith(dotSkp)) {
size_t len = testName.size();
testName.remove(len - (sizeof(dotSkp) - 1), sizeof(dotSkp) - 1);
}
testName.prepend("skp");
testName.append("1");
strncpy(DEBUG_FILENAME_STRING, testName.c_str(), DEBUG_FILENAME_STRING_LENGTH);
} else if (fTestStep == kEncodeFiles) {
strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
}
#endif
SkString path = get_in_path(fDirNo, fFilename);
SkFILEStream stream(path.c_str());
if (!stream.isValid()) {
SkDebugf("invalid stream %s\n", path.c_str());
goto finish;
}
pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory);
if (!pic) {
SkDebugf("unable to decode %s\n", fFilename);
goto finish;
}
SkScalar width = pic->cullRect().width();
SkScalar height = pic->cullRect().height();
SkBitmap oldBitmap, opBitmap;
fScale = 1;
while (width / fScale > 32767 || height / fScale > 32767) {
++fScale;
}
do {
int dimX = SkScalarCeilToInt(width / fScale);
int dimY = SkScalarCeilToInt(height / fScale);
if (oldBitmap.tryAllocN32Pixels(dimX, dimY) && opBitmap.tryAllocN32Pixels(dimX, dimY)) {
break;
}
SkDebugf("-%d-", fScale);
} while (++fScale < 256);
if (fScale >= 256) {
SkDebugf("unable to allocate bitmap for %s (w=%f h=%f)\n", fFilename,
width, height);
goto finish;
}
oldBitmap.eraseColor(SK_ColorWHITE);
SkCanvas oldCanvas(oldBitmap);
oldCanvas.setAllowSimplifyClip(false);
opBitmap.eraseColor(SK_ColorWHITE);
SkCanvas opCanvas(opBitmap);
opCanvas.setAllowSimplifyClip(true);
drawPict(pic, &oldCanvas, fScale);
drawPict(pic, &opCanvas, fScale);
if (fTestStep == kCompareBits) {
fPixelError = similarBits(oldBitmap, opBitmap);
int oldTime = timePict(pic, &oldCanvas);
int opTime = timePict(pic, &opCanvas);
fTime = SkTMax(0, oldTime - opTime);
} else if (fTestStep == kEncodeFiles) {
SkString pngStr = make_png_name(fFilename);
const char* pngName = pngStr.c_str();
writePict(oldBitmap, outOldDir, pngName);
writePict(opBitmap, outOpDir, pngName);
}
}
finish:
if (pic) {
pic->unref();
}
}