本文整理汇总了C++中SkPicture类的典型用法代码示例。如果您正苦于以下问题:C++ SkPicture类的具体用法?C++ SkPicture怎么用?C++ SkPicture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkPicture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_layers
// Add several layers to the cache
static void create_layers(skiatest::Reporter* reporter,
GrLayerCache* cache,
const SkPicture& picture,
unsigned numToAdd,
unsigned idOffset) {
for (unsigned i = 0; i < numToAdd; ++i) {
unsigned indices[1] = { idOffset+i+1 };
GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(),
idOffset+i+1, idOffset+i+2,
SkIRect::MakeEmpty(),
SkIRect::MakeEmpty(),
SkMatrix::I(),
indices, 1,
NULL);
REPORTER_ASSERT(reporter, layer);
GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkMatrix::I(),
indices, 1);
REPORTER_ASSERT(reporter, temp == layer);
REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1);
REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID());
REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1);
REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2);
REPORTER_ASSERT(reporter, NULL == layer->texture());
REPORTER_ASSERT(reporter, NULL == layer->paint());
REPORTER_ASSERT(reporter, !layer->isAtlased());
}
}
示例2: 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;
}
示例3: context
void ImageBuffer::copyRecordingToCanvas(GraphicsContext* paintContext, const IntRect& r) const
{
SkCanvas* paintCanvas = paintContext->platformContext()->mCanvas;
SkPicture* canvasRecording = context()->platformContext()->getRecordingPicture();
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
const SkIRect& clipBounds = paintCanvas->getTotalClip().getBounds();
SkRect rect;
int saveCount = 0;
if( (clipBounds.width() > r.width() * 2 ) || (clipBounds.height() > r.height() * 2))
{
rect.set(r.location().x(), r.location().y(),r.width(), r.height());
saveCount = paintCanvas->saveLayer(&rect, &paint);
}
else
saveCount = paintCanvas->saveLayer(0, &paint);
paintCanvas->translate(r.location().x(), r.location().y());
// Resize to the now known viewport.
paintCanvas->scale(r.width() / width(), r.height() / height());
// Draw the canvas recording into the layer recording canvas.
canvasRecording->draw(paintCanvas);
context()->platformContext()->clearRecording();
paintCanvas->restoreToCount(saveCount);
}
示例4: onDraw
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
SkMatrix saveM = *fMatrixRefs[3];
SkScalar c = SkIntToScalar(50);
fMatrixRefs[3]->preRotate(SkIntToScalar(30), c, c);
SkMatrix matrix;
SkGroupShape* gs = new SkGroupShape;
SkAutoUnref aur(gs);
gs->appendShape(&fGroup);
matrix.setScale(-SK_Scalar1, SK_Scalar1);
matrix.postTranslate(SkIntToScalar(220), SkIntToScalar(240));
gs->appendShape(&fGroup, matrix);
matrix.setTranslate(SkIntToScalar(240), 0);
matrix.preScale(SK_Scalar1*2, SK_Scalar1*2);
gs->appendShape(&fGroup, matrix);
#if 0
canvas->drawShape(gs);
#else
SkPicture pict;
SkCanvas* cv = pict.beginRecording(1000, 1000);
cv->scale(SK_ScalarHalf, SK_ScalarHalf);
cv->drawShape(gs);
cv->translate(SkIntToScalar(680), SkIntToScalar(480));
cv->scale(-SK_Scalar1, SK_Scalar1);
cv->drawShape(gs);
pict.endRecording();
canvas->drawPicture(pict);
#endif
*fMatrixRefs[3] = saveM;
}
示例5: onDraw
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
SkMatrix matrix;
SkGroupShape* gs = new SkGroupShape;
SkAutoUnref aur(gs);
gs->appendShape(&fGroup);
matrix.setScale(-SK_Scalar1, SK_Scalar1);
matrix.postTranslate(SkIntToScalar(220), SkIntToScalar(240));
gs->appendShape(&fGroup, matrix);
matrix.setTranslate(SkIntToScalar(240), 0);
matrix.preScale(SK_Scalar1*2, SK_Scalar1*2);
gs->appendShape(&fGroup, matrix);
#if 1
SkPicture* pict = new SkPicture;
SkCanvas* cv = pict->beginRecording(1000, 1000);
cv->scale(SK_ScalarHalf, SK_ScalarHalf);
gs->draw(cv);
cv->translate(SkIntToScalar(680), SkIntToScalar(480));
cv->scale(-SK_Scalar1, SK_Scalar1);
gs->draw(cv);
pict->endRecording();
canvas->drawPicture(*pict);
pict->unref();
#endif
}
示例6: nativeSerializeViewState
static bool nativeSerializeViewState(JNIEnv* env, jobject, jint jbaseLayer,
jobject jstream, jbyteArray jstorage)
{
BaseLayerAndroid* baseLayer = (BaseLayerAndroid*) jbaseLayer;
if (!baseLayer)
return false;
SkWStream *stream = CreateJavaOutputStreamAdaptor(env, jstream, jstorage);
#if USE(ACCELERATED_COMPOSITING)
// SAMSUNG CHANGE >> White flickering issue.
// WAS:stream->write32(baseLayer->getBackgroundColor().rgb());
stream->write32(baseLayer->getBackgroundColor());
// SAMSUNG CHANGE <<
#else
stream->write32(0);
#endif
SkPicture picture;
PictureSet* content = baseLayer->content();
baseLayer->drawCanvas(picture.beginRecording(content->width(), content->height(),
SkPicture::kUsePathBoundsForClip_RecordingFlag));
picture.endRecording();
if (!stream)
return false;
picture.serialize(stream);
int childCount = baseLayer->countChildren();
XLOG("BaseLayer has %d child(ren)", childCount);
stream->write32(childCount);
for (int i = 0; i < childCount; i++) {
LayerAndroid* layer = static_cast<LayerAndroid*>(baseLayer->getChild(i));
serializeLayer(layer, stream);
}
delete stream;
return true;
}
开发者ID:johnwpoliver,项目名称:Samsung-GT-P3113-AOSP-CM-Kernel-and-Ramdisk,代码行数:34,代码来源:ViewStateSerializer.cpp
示例7: inspect
static SkPicture* inspect(const char path[]) {
SkFILEStream stream(path);
if (!stream.isValid()) {
printf("-- Can't open '%s'\n", path);
return NULL;
}
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 NULL;
}
printf("version:%d width:%d height:%d\n", header[0], header[1], header[2]);
}
stream.rewind();
SkPicture* pic = SkPicture::CreateFromStream(&stream, &sk_tools::LazyDecodeBitmap);
if (NULL == pic) {
SkDebugf("Could not create SkPicture: %s\n", path);
return NULL;
}
printf("picture size:[%d %d]\n", pic->width(), pic->height());
return pic;
}
示例8: test_serializing_empty_picture
// Ensure that serializing an empty picture does not assert. Likewise only runs in debug mode.
static void test_serializing_empty_picture() {
SkPicture picture;
picture.beginRecording(0, 0);
picture.endRecording();
SkDynamicMemoryWStream stream;
picture.serialize(&stream);
}
示例9: serialized_picture_from_bitmap
static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) {
SkPicture picture;
SkCanvas* canvas = picture.beginRecording(bitmap.width(), bitmap.height());
canvas->drawBitmap(bitmap, 0, 0);
SkDynamicMemoryWStream wStream;
picture.serialize(&wStream, &encode_bitmap_to_data);
return wStream.copyToData();
}
示例10: 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;
}
示例11: draw
static void draw(JNIEnv* env, jobject, jlong canvasHandle,
jlong pictureHandle) {
SkCanvas* canvas = reinterpret_cast<SkCanvas*>(canvasHandle);
SkPicture* picture = reinterpret_cast<SkPicture*>(pictureHandle);
SkASSERT(canvas);
SkASSERT(picture);
picture->draw(canvas);
}
示例12: drawPicture
void SkDumpCanvas::drawPicture(SkPicture& picture) {
this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p) %d:%d", &picture,
picture.width(), picture.height());
fNestLevel += 1;
this->INHERITED::drawPicture(picture);
fNestLevel -= 1;
this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %d:%d", &picture,
picture.width(), picture.height());
}
示例13: test_deleting_empty_playback
// Ensure that deleting SkPicturePlayback does not assert. Asserts only fire in debug mode, so only
// run in debug mode.
static void test_deleting_empty_playback() {
SkPicture picture;
// Creates an SkPictureRecord
picture.beginRecording(0, 0);
// Turns that into an SkPicturePlayback
picture.endRecording();
// Deletes the old SkPicturePlayback, and creates a new SkPictureRecord
picture.beginRecording(0, 0);
}
示例14: draw
void PicturePileLayerContent::serialize(SkWStream* stream)
{
if (!stream)
return;
SkPicture picture;
draw(picture.beginRecording(width(), height(),
SkPicture::kUsePathBoundsForClip_RecordingFlag));
picture.endRecording();
picture.serialize(stream);
}
示例15: gets_ops
// Extract the command ops from the input SkPicture
static void gets_ops(SkPicture& input, SkTDArray<DrawType>* ops) {
SkDebugCanvas debugCanvas(input.width(), input.height());
debugCanvas.setBounds(input.width(), input.height());
input.draw(&debugCanvas);
ops->setCount(debugCanvas.getSize());
for (int i = 0; i < debugCanvas.getSize(); ++i) {
(*ops)[i] = debugCanvas.getDrawCommandAt(i)->getType();
}
}