GrGLSharedSurface SkNativeSharedGLContext::stealSurface() {
    // Render the texture to the default framebuffer.
    int viewport[4];
    SK_GL(*this, GetIntegerv(GR_GL_VIEWPORT, viewport));
    int width = viewport[2], height = viewport[3];
    SK_GL(*this, BindFramebuffer(GR_GL_READ_FRAMEBUFFER, fFBO));
    SK_GL(*this, BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, 0));
    SK_GL(*this, BlitFramebuffer(0,
                                 0,
                                 width,
                                 height,
                                 0,
                                 0,
                                 width,
                                 height,
                                 GR_GL_COLOR_BUFFER_BIT,
                                 GR_GL_NEAREST));
    SK_GL(*this, Flush());
    SK_GL(*this, BindFramebuffer(GR_GL_FRAMEBUFFER, 0));

    Pixmap pixmap = fPixmap;
    destroyGLResources();
    fPixmap = 0;
    return pixmap;
}
SkNativeSharedGLContext::~SkNativeSharedGLContext() {
    if (fGlxPixmap) {
        destroyGLResources();
    }
    if (fPixmap) {
        XFreePixmap(fDisplay, fPixmap);
    }
    if (fGrContext) {
        fGrContext->Release();
    }
    SkSafeUnref(fGL);
    this->destroyGLContext();
}
Exemple #3
0
void font_impl::loadFont(const char* const pFile, int pFontSize)
{
    if (mIsFontLoaded) {
        if (pFile==mTTFfile)
            return;
        else {
            destroyGLResources();
            mIsFontLoaded = false;
        }
    }
    mLoadedPixelSize = pFontSize;

    CheckGL("Begin Font::loadFont");
    // Initialize freetype font library
    FT_Error bError = FT_Init_FreeType(&gFTLib);

    bError = FT_New_Face(gFTLib, pFile, 0, &gFTFace);
    if(bError) {
        FT_Done_FreeType(gFTLib);
        FT_THROW_ERROR("font face creation failed", fg::FG_ERR_FREETYPE_ERROR);
    }

    bError = FT_Set_Pixel_Sizes(gFTFace, 0, pFontSize);
    if (bError) {
        FT_Done_Face(gFTFace);
        FT_Done_FreeType(gFTLib);
        FT_THROW_ERROR("set font size failed", fg::FG_ERR_FREETYPE_ERROR);
    }

    // read font glyphs for only characters
    // from ' ' to '~'
    for (int i=START_CHAR; i<END_CHAR; ++i) extractGlyph(i);

    FT_Done_Face(gFTFace);
    FT_Done_FreeType(gFTLib);

    mVBO = createBuffer<float>(GL_ARRAY_BUFFER, mVertexData.size(), &(mVertexData.front()), GL_STATIC_DRAW);

    mIsFontLoaded = true;
    mTTFfile = pFile;
    CheckGL("End Font::loadFont");
}
Exemple #4
0
font_impl::~font_impl()
{
    destroyGLResources();
}