当前位置: 首页>>代码示例>>C++>>正文


C++ SkPicture::serialize方法代码示例

本文整理汇总了C++中SkPicture::serialize方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPicture::serialize方法的具体用法?C++ SkPicture::serialize怎么用?C++ SkPicture::serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkPicture的用法示例。


在下文中一共展示了SkPicture::serialize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:CriGio,项目名称:platform_external_skia,代码行数:8,代码来源:PictureTest.cpp

示例2: 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

示例3: 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();
}
开发者ID:CriGio,项目名称:platform_external_skia,代码行数:8,代码来源:PictureTest.cpp

示例4: serialize

void PicturePileLayerContent::serialize(SkWStream* stream)
{
    if (!stream)
       return;
    SkPicture picture;
    draw(picture.beginRecording(width(), height(),
                                SkPicture::kUsePathBoundsForClip_RecordingFlag));
    picture.endRecording();
    picture.serialize(stream);
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:10,代码来源:PicturePileLayerContent.cpp

示例5: serialize

 static jboolean serialize(JNIEnv* env, jobject, jlong pictureHandle,
                       jobject jstream, jbyteArray jstorage) {
     SkPicture* picture = reinterpret_cast<SkPicture*>(pictureHandle);
     SkWStream* strm = CreateJavaOutputStreamAdaptor(env, jstream, jstorage);
     
     if (NULL != strm) {
         picture->serialize(strm);
         delete strm;
         return JNI_TRUE;
     }
     return JNI_FALSE;
 }
开发者ID:0359xiaodong,项目名称:platform_frameworks_base,代码行数:12,代码来源:Picture.cpp

示例6: drawpicture

    void drawpicture(SkCanvas* canvas, SkPicture& pict) {
#if 0
        SkDynamicMemoryWStream ostream;
        pict.serialize(&ostream);

        SkMemoryStream istream(ostream.getStream(), ostream.getOffset());
        SkPicture* newPict = new SkPicture(&istream);
        canvas->drawPicture(*newPict);
        newPict->unref();
#else
        canvas->drawPicture(pict);
#endif
    }
开发者ID:BBKeeper,项目名称:Skia,代码行数:13,代码来源:SampleShapes.cpp

示例7: afterChildren

void SampleWindow::afterChildren(SkCanvas* orig) {
    switch (fCanvasType) {
    case kRaster_CanvasType:
        break;
    case kPicture_CanvasType:
        if (true) {
            SkPicture* pict = new SkPicture(*fPicture);
            fPicture->unref();
            orig->drawPicture(*pict);
            pict->unref();
        } else if (true) {
            SkDynamicMemoryWStream ostream;
            fPicture->serialize(&ostream);
            fPicture->unref();

            SkMemoryStream istream(ostream.getStream(), ostream.getOffset());
            SkPicture pict(&istream);
            orig->drawPicture(pict);
        } else {
            fPicture->draw(orig);
            fPicture->unref();
        }
        fPicture = NULL;
        break;
#ifdef SK_SUPPORT_GL
    case kOpenGL_CanvasType:
        glFlush();
        delete fGLCanvas;
        fGLCanvas = NULL;
#ifdef USE_OFFSCREEN
        reverseRedAndBlue(orig->getDevice()->accessBitmap(true));
#endif
        break;
#endif
    }

//    if ((fScrollTestX | fScrollTestY) != 0)
    {
        const SkBitmap& bm = orig->getDevice()->accessBitmap(true);
        int dx = fScrollTestX * 7;
        int dy = fScrollTestY * 7;
        SkIRect r;
        SkRegion inval;

        r.set(50, 50, 50+100, 50+100);
        bm.scrollRect(&r, dx, dy, &inval);
        paint_rgn(bm, r, inval);
    }
}
开发者ID:avary,项目名称:skia,代码行数:49,代码来源:SampleApp.cpp

示例8: draw

void SerializeTask::draw() {
    SkPicture recorded;
    RecordPicture(fGM.get(), &recorded);

    SkDynamicMemoryWStream wStream;
    recorded.serialize(&wStream, &trivial_bitmap_encoder);
    SkAutoTUnref<SkStream> rStream(wStream.detachAsStream());
    SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream));

    SkBitmap bitmap;
    SetupBitmap(fReference.config(), fGM.get(), &bitmap);
    DrawPicture(reconstructed, &bitmap);
    if (!BitmapsEqual(bitmap, fReference)) {
        this->fail();
        this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
    }
}
开发者ID:CriGio,项目名称:platform_external_skia,代码行数:17,代码来源:DMSerializeTask.cpp

示例9: filter_picture

static int filter_picture(const SkString& inFile, const SkString& outFile) {
    SkAutoTDelete<SkPicture> inPicture;

    SkFILEStream inStream(inFile.c_str());
    if (inStream.isValid()) {
        inPicture.reset(SkPicture::CreateFromStream(&inStream));
    }

    if (NULL == inPicture.get()) {
        SkDebugf("Could not read file %s\n", inFile.c_str());
        return -1;
    }

    int localCount[SK_ARRAY_COUNT(gOptTable)];

    memset(localCount, 0, sizeof(localCount));

    SkDebugCanvas debugCanvas(inPicture->width(), inPicture->height());
    debugCanvas.setBounds(inPicture->width(), inPicture->height());
    inPicture->draw(&debugCanvas);

    // delete the initial save and restore since replaying the commands will
    // re-add them
    if (debugCanvas.getSize() > 1) {
        debugCanvas.deleteDrawCommandAt(0);
        debugCanvas.deleteDrawCommandAt(debugCanvas.getSize()-1);
    }

    bool changed = true;
    int numBefore = debugCanvas.getSize();

    while (changed) {
        changed = false;
        for (int i = 0; i < debugCanvas.getSize(); ++i) {
            for (size_t opt = 0; opt < SK_ARRAY_COUNT(gOptTable); ++opt) {
                if ((*gOptTable[opt].fCheck)(&debugCanvas, i)) {
                    (*gOptTable[opt].fApply)(&debugCanvas, i);

                    ++gOptTable[opt].fNumTimesApplied;
                    ++localCount[opt];

                    if (debugCanvas.getSize() == i) {
                        // the optimization removed all the remaining operations
                        break;
                    }

                    opt = 0;          // try all the opts all over again
                    changed = true;
                }
            }
        }
    }

    int numAfter = debugCanvas.getSize();

    if (!outFile.isEmpty()) {
        SkPicture outPicture;

        SkCanvas* canvas = outPicture.beginRecording(inPicture->width(), inPicture->height());
        debugCanvas.draw(canvas);
        outPicture.endRecording();

        SkFILEWStream outStream(outFile.c_str());

        outPicture.serialize(&outStream);
    }

    bool someOptFired = false;
    for (size_t opt = 0; opt < SK_ARRAY_COUNT(gOptTable); ++opt) {
        if (0 != localCount[opt]) {
            SkDebugf("%d: %d ", opt, localCount[opt]);
            someOptFired = true;
        }
    }

    if (!someOptFired) {
        SkDebugf("No opts fired\n");
    } else {
        SkDebugf("\t before: %d after: %d delta: %d\n",
                 numBefore, numAfter, numBefore-numAfter);
    }

    return 0;
}
开发者ID:CriGio,项目名称:platform_external_skia,代码行数:84,代码来源:filtermain.cpp


注:本文中的SkPicture::serialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。