本文整理汇总了C++中SkPicture::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPicture::clone方法的具体用法?C++ SkPicture::clone怎么用?C++ SkPicture::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPicture
的用法示例。
在下文中一共展示了SkPicture::clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_picture
static bool render_picture(const SkString& inputPath, const SkString* outputDir,
sk_tools::PictureRenderer& renderer,
SkBitmap** out,
int clones) {
SkString inputFilename;
sk_tools::get_basename(&inputFilename, inputPath);
SkFILEStream inputStream;
inputStream.setPath(inputPath.c_str());
if (!inputStream.isValid()) {
SkDebugf("Could not open file %s\n", inputPath.c_str());
return false;
}
bool success = false;
SkPicture* picture = SkNEW_ARGS(SkPicture,
(&inputStream, &success, &SkImageDecoder::DecodeStream));
if (!success) {
SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str());
return false;
}
for (int i = 0; i < clones; ++i) {
SkPicture* clone = picture->clone();
SkDELETE(picture);
picture = clone;
}
SkDebugf("drawing... [%i %i] %s\n", picture->width(), picture->height(),
inputPath.c_str());
renderer.init(picture);
renderer.setup();
SkString* outputPath = NULL;
if (NULL != outputDir) {
outputPath = SkNEW(SkString);
make_output_filepath(outputPath, *outputDir, inputFilename);
}
success = renderer.render(outputPath, out);
if (outputPath) {
if (!success) {
SkDebugf("Could not write to file %s\n", outputPath->c_str());
}
SkDELETE(outputPath);
}
renderer.resetState();
renderer.end();
SkDELETE(picture);
return success;
}
示例2: test_clone_empty
static void test_clone_empty(skiatest::Reporter* reporter) {
// This is a regression test for crbug.com/172062
// Before the fix, we used to crash accessing a null pointer when we
// had a picture with no paints. This test passes by not crashing.
{
SkPicture picture;
picture.beginRecording(1, 1);
picture.endRecording();
SkPicture* destPicture = picture.clone();
REPORTER_ASSERT(reporter, NULL != destPicture);
destPicture->unref();
}
{
// Test without call to endRecording
SkPicture picture;
picture.beginRecording(1, 1);
SkPicture* destPicture = picture.clone();
REPORTER_ASSERT(reporter, NULL != destPicture);
destPicture->unref();
}
}
示例3: render_picture_internal
/**
* Called only by render_picture().
*/
static bool render_picture_internal(const SkString& inputPath, const SkString* outputDir,
sk_tools::PictureRenderer& renderer,
SkBitmap** out) {
SkString inputFilename;
sk_tools::get_basename(&inputFilename, inputPath);
SkString outputDirString;
if (NULL != outputDir && outputDir->size() > 0 && !FLAGS_writeEncodedImages) {
outputDirString.set(*outputDir);
}
SkFILEStream inputStream;
inputStream.setPath(inputPath.c_str());
if (!inputStream.isValid()) {
SkDebugf("Could not open file %s\n", inputPath.c_str());
return false;
}
SkPicture::InstallPixelRefProc proc;
if (FLAGS_deferImageDecoding) {
proc = &sk_tools::LazyDecodeBitmap;
} else if (FLAGS_writeEncodedImages) {
SkASSERT(!FLAGS_writePath.isEmpty());
reset_image_file_base_name(inputFilename);
proc = &write_image_to_file;
} else {
proc = &SkImageDecoder::DecodeMemory;
}
SkDebugf("deserializing... %s\n", inputPath.c_str());
SkPicture* picture = SkPicture::CreateFromStream(&inputStream, proc);
if (NULL == picture) {
SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str());
return false;
}
while (FLAGS_bench_record) {
const int kRecordFlags = 0;
SkPicture other;
picture->draw(other.beginRecording(picture->width(), picture->height(), kRecordFlags));
other.endRecording();
}
for (int i = 0; i < FLAGS_clone; ++i) {
SkPicture* clone = picture->clone();
SkDELETE(picture);
picture = clone;
}
SkDebugf("drawing... [%i %i] %s\n", picture->width(), picture->height(),
inputPath.c_str());
renderer.init(picture, &outputDirString, &inputFilename, FLAGS_writeChecksumBasedFilenames);
if (FLAGS_preprocess) {
if (NULL != renderer.getCanvas()) {
renderer.getCanvas()->EXPERIMENTAL_optimize(picture);
}
}
renderer.setup();
bool success = renderer.render(out);
if (!success) {
SkDebugf("Failed to render %s\n", inputFilename.c_str());
}
renderer.end();
SkDELETE(picture);
return success;
}