void vg_prepare_blend_surface_from_mask(struct vg_context *ctx) { struct pipe_surface *dest_surface = NULL; struct pipe_context *pipe = ctx->pipe; struct st_framebuffer *stfb = ctx->draw_buffer; struct st_renderbuffer *strb = stfb->strb; vg_validate_state(ctx); /* first finish all pending rendering */ vgFinish(); dest_surface = pipe->screen->get_tex_surface(pipe->screen, stfb->blend_texture_view->texture, 0, 0, 0, PIPE_BIND_RENDER_TARGET); /* flip it, because we want to use it as a sampler */ util_blit_pixels_tex(ctx->blit, stfb->alpha_mask_view, 0, strb->height, strb->width, 0, dest_surface, 0, 0, strb->width, strb->height, 0.0, PIPE_TEX_MIPFILTER_NEAREST); /* make sure it's complete */ vgFinish(); if (dest_surface) pipe_surface_reference(&dest_surface, NULL); }
void vgCopyPixels(VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct pipe_framebuffer_state *fb = &ctx->state.g3d.fb; struct st_renderbuffer *strb = ctx->draw_buffer->strb; if (width <= 0 || height <= 0) { vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR); return; } /* do nothing if we copy from outside the fb */ if (dx >= (VGint)fb->width || dy >= (VGint)fb->height || sx >= (VGint)fb->width || sy >= (VGint)fb->height) return; vg_validate_state(ctx); /* make sure rendering has completed */ vgFinish(); vg_copy_surface(ctx, strb->surface, dx, dy, strb->surface, sx, sy, width, height); }
void vg_prepare_blend_surface(struct vg_context *ctx) { struct pipe_surface *dest_surface = NULL; struct pipe_context *pipe = ctx->pipe; struct pipe_sampler_view *view; struct pipe_sampler_view view_templ; struct st_framebuffer *stfb = ctx->draw_buffer; struct st_renderbuffer *strb = stfb->strb; /* first finish all pending rendering */ vgFinish(); u_sampler_view_default_template(&view_templ, strb->texture, strb->texture->format); view = pipe->create_sampler_view(pipe, strb->texture, &view_templ); dest_surface = pipe->screen->get_tex_surface(pipe->screen, stfb->blend_texture_view->texture, 0, 0, 0, PIPE_BIND_RENDER_TARGET); /* flip it, because we want to use it as a sampler */ util_blit_pixels_tex(ctx->blit, view, 0, strb->height, strb->width, 0, dest_surface, 0, 0, strb->width, strb->height, 0.0, PIPE_TEX_MIPFILTER_NEAREST); if (dest_surface) pipe_surface_reference(&dest_surface, NULL); /* make sure it's complete */ vgFinish(); pipe_sampler_view_reference(&view, NULL); }
void vgFlush ( void ) { vgFinish (); }
/*! \fn HbSgimageIconProcessor::createSgimage() ToDO \a iconPath the path to the icon file */ bool HbSgimageIconProcessor::createSgimage(const QString &iconPath) { bool isDefaultSize = iconKey.size.isNull(); data.type = INVALID_FORMAT; HbIconSource *source = HbThemeServerUtils::getIconSource(iconPath); QByteArray *sourceByteArray = source->byteArray(); if( !sourceByteArray ) { return false; } byteArray = *sourceByteArray; QSizeF size = source->defaultSize(); defaultSize = size.toSize(); QSizeF renderSize(defaultSize); data.sgImageData.defaultWidth = defaultSize.width(); data.sgImageData.defaultHeight = defaultSize.height(); if (!isDefaultSize) { renderSize.scale(iconKey.size, iconKey.aspectRatioMode); } data.sgImageData.width = renderSize.width(); data.sgImageData.height = renderSize.height(); //SgDriver is opened only once for the themserver process when the themserver is started. //Also eglInitialize is done only once for the theserver process //It is closed only when the themeserver is closed. // Create RSgImage, specifying ESgUsageBitOpenVgImage and ESgUsageBitOpenVgSurface // usage bits so it can be used as a target for OpenVG rendering inside the Theme // Server and as an OpenVG image inside the client applications. TSgImageInfo info; info.iSizeInPixels = TSize(data.sgImageData.width, data.sgImageData.height); info.iPixelFormat = ESgPixelFormatARGB_8888_PRE; info.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface; QScopedPointer<RSgImage, HbSgImageClosure> tempSgImage(new RSgImage); RSgImage *sgImage = tempSgImage.data(); Q_CHECK_PTR(sgImage); TInt err = sgImage->Create(info, 0, 0); if (err != KErrNone) { return false; } TSgDrawableId sgImageId = sgImage->Id(); memcpy(&data.sgImageData.id, &sgImageId.iId, sizeof(data.sgImageData.id)); data.type = SGIMAGE; bool success = sgImageRenderer->beginRendering(sgImage); if (!success) { return false; } VGfloat color[4] = { 0.0f, 1.0f, 1.0f, 0.0f }; // TODO revert back to white color vgSetfv(VG_CLEAR_COLOR, 4, color); vgClear(0, 0, data.sgImageData.width, data.sgImageData.height); success = renderNvg(byteArray, QRect(0, 0, data.sgImageData.width, data.sgImageData.height), iconKey.aspectRatioMode, iconKey.mirrored); if (!success) { return false; } vgFinish(); // Once finished, release all handles to the image, and shut down EGL. // Make a null EGLSurface current to release the current surface before // destroying. The RSgImage contents will persist until the RSgImage is closed. sgImageRenderer->endRendering(); tempSgImage.take(); HbSgImageRenderer::addSgImageToHash(data.sgImageData.id, sgImage); return true; }
bool HbSgimageIconProcessor::createMultiPieceIconData(const QVector<HbSharedIconInfo> &multiPieceIconInfo, HbMultiIconParams &multiPieceIconParams) { bool mirrored = false; int consolidatedIconWidth = 0; TSgImageInfo info; info.iSizeInPixels = TSize(qRound(multiPieceIconParams.size.width()), qRound(multiPieceIconParams.size.height())); info.iPixelFormat = ESgPixelFormatARGB_8888_PRE; info.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface; QScopedPointer<RSgImage, HbSgImageClosure> tempSgImage(new RSgImage); RSgImage *sgImage = tempSgImage.data(); Q_CHECK_PTR(sgImage); TInt err = sgImage->Create(info, 0, 0); if (err != KErrNone) { return false; } data.type = SGIMAGE; data.sgImageData.width = qRound(multiPieceIconParams.size.width()); data.sgImageData.height = qRound(multiPieceIconParams.size.height()); data.sgImageData.defaultWidth = defaultSize.width(); data.sgImageData.defaultHeight = defaultSize.height(); //data.sgImageData.sgImage = sgImage; TSgDrawableId sgImageId = sgImage->Id(); memcpy(&data.sgImageData.id, &sgImageId.iId, sizeof(data.sgImageData.id)); bool success = sgImageRenderer->beginRendering(sgImage); if (!success) { return false; } //Clear VGfloat color[4] = { 1.0f, 1.0f, 1.0f, 0.0f }; vgSetfv(VG_CLEAR_COLOR, 4, color); vgClear(0, 0, data.sgImageData.width, data.sgImageData.height); if (multiPieceIconParams.mirrored) { mirrored = true; consolidatedIconWidth = multiPieceIconParams.size.toSize().width(); } int iconCount = multiPieceIconParams.multiPartIconList.count(); GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory); for (int i = 0; i < iconCount; i++) { HbIconFormatType type = multiPieceIconInfo[i].type; bool success = false; if (type == NVG) { #ifdef HB_NVG_CS_ICON QPoint position = multiPieceIconParams.multiPartIconData.targets[i].topLeft(); if (mirrored) { int pieceTopRight = position.x() + multiPieceIconParams.multiPartIconData.targets[i].width(); position.setX(consolidatedIconWidth - pieceTopRight); } byteArray = QByteArray::fromRawData((char*)manager->base() + multiPieceIconInfo[i].nvgData.offset, multiPieceIconInfo[i].nvgData.dataSize); success = renderNvg(byteArray, QRect(position, multiPieceIconParams.multiPartIconData.pixmapSizes[i]), (Qt::AspectRatioMode)multiPieceIconParams.aspectRatioMode, mirrored); #endif } if (!success) { sgImageRenderer->endRendering(); return false; } } vgFinish(); sgImageRenderer->endRendering(); tempSgImage.take(); HbSgImageRenderer::addSgImageToHash(data.sgImageData.id, sgImage); return true; }
static void _cairo_boilerplate_vg_synchronize (void *closure) { vgFinish (); }