void Canvas::DrawClippedText(int x, int y, unsigned width, unsigned height, const TCHAR *text) { assert(text != nullptr); assert(ValidateUTF8(text)); #ifdef HAVE_GLES assert(offset == OpenGL::translate); #endif if (font == nullptr) return; GLTexture *texture = TextCache::Get(*font, text); if (texture == nullptr) return; if (texture->GetHeight() < height) height = texture->GetHeight(); if (texture->GetWidth() < width) width = texture->GetWidth(); PrepareColoredAlphaTexture(text_color); #ifndef USE_GLSL GLEnable scope(GL_TEXTURE_2D); #endif const GLBlend blend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); texture->Bind(); texture->Draw(x, y, width, height, 0, 0, width, height); }
void Canvas::DrawText(int x, int y, const TCHAR *text) { assert(text != nullptr); assert(ValidateUTF8(text)); #ifdef HAVE_GLES assert(offset == OpenGL::translate); #endif if (font == nullptr) return; GLTexture *texture = TextCache::Get(*font, text); if (texture == nullptr) return; if (background_mode == OPAQUE) DrawFilledRectangle(x, y, x + texture->GetWidth(), y + texture->GetHeight(), background_color); PrepareColoredAlphaTexture(text_color); #ifndef USE_GLSL GLEnable scope(GL_TEXTURE_2D); #endif const GLBlend blend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); texture->Bind(); texture->Draw(x, y); }
void Canvas::Stretch(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const GLTexture &texture) { Stretch(dest_x, dest_y, dest_width, dest_height, texture, 0, 0, texture.GetWidth(), texture.GetHeight()); }
void Canvas::Stretch(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const GLTexture &texture) { Stretch(dest_x, dest_y, dest_width, dest_height, texture, 0, 0, texture.GetWidth(), texture.GetHeight()); }
void Canvas::TextClipped(PixelScalar x, PixelScalar y, UPixelScalar width, UPixelScalar height, const TCHAR *text) { assert(text != NULL); assert(ValidateUTF8(text)); #ifdef HAVE_GLES assert(x_offset == OpenGL::translate_x); assert(y_offset == OpenGL::translate_y); #endif if (font == NULL) return; GLTexture *texture = TextCache::Get(font, text); if (texture == NULL) return; GLEnable scope(GL_TEXTURE_2D); texture->Bind(); GLLogicOp logic_op(GL_AND_INVERTED); if (texture->GetHeight() < height) height = texture->GetHeight(); if (texture->GetWidth() < width) width = texture->GetWidth(); /* cut out the shape in black */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); texture->Draw(x, y, width, height, 0, 0, width, height); if (text_color != COLOR_BLACK) { /* draw the text color on top */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); logic_op.set(GL_OR); text_color.Set(); texture->Draw(x, y, width, height, 0, 0, width, height); } }
void Canvas::text(PixelScalar x, PixelScalar y, const TCHAR *text) { assert(text != NULL); assert(ValidateUTF8(text)); #ifdef HAVE_GLES assert(x_offset == OpenGL::translate_x); assert(y_offset == OpenGL::translate_y); #endif if (font == NULL) return; GLTexture *texture = TextCache::Get(font, text); if (texture == NULL) return; if (background_mode == OPAQUE) /* draw the opaque background */ DrawFilledRectangle(x, y, x + texture->GetWidth(), y + texture->GetHeight(), background_color); GLEnable scope(GL_TEXTURE_2D); texture->Bind(); GLLogicOp logic_op(GL_AND_INVERTED); if (background_mode != OPAQUE || background_color != COLOR_BLACK) { /* cut out the shape in black */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); texture->Draw(x, y); } if (text_color != COLOR_BLACK) { /* draw the text color on top */ OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); logic_op.set(GL_OR); text_color.Set(); texture->Draw(x, y); } }
void CVideoControlSoft::OnPaint(wxPaintEvent& event) { #ifdef __WXGTK__ double scale_factor = GetContentScaleFactor(); #else double scale_factor = 1.0f; #endif GLTexture * glTexture = nullptr; //printf("OnPaint Soft Render begin \n"); #ifndef WIN32 if(!renderBitmapOpenGL->IsInit()) { renderBitmapOpenGL->Init(this); } #endif std::clock_t start; start = std::clock(); int width = GetWindowWidth() * scale_factor; int height = GetWindowHeight() * scale_factor; if(width == 0 || height == 0) return; if (quitWindow) return; #ifdef WIN32 renderBitmapOpenGL->SetCurrent(*this); #else if(updateContext) { renderBitmapOpenGL->SetCurrent(*this); updateContext = false; } #endif if (openCLEngine == nullptr) { openCLEngine = new COpenCLEngine(); if (openCLEngine != nullptr) openclContext = openCLEngine->GetInstance(); openclEffectYUV = new COpenCLEffectVideoYUV(openclContext); } nbFrame++; printf("Nb Frame per Seconds : %d \n",nbFrame); if (videoRenderStart && initStart) { //nbFrame = 0; if(!fpsTimer->IsRunning()) fpsTimer->Start(1000); } if(videoRenderStart) { glTexture = RenderToGLTexture(); if(glTexture != nullptr) printf("glTexture id : %d \n",glTexture->GetTextureID()); } if(videoRenderStart && glTexture != nullptr) { renderBitmapOpenGL->CreateScreenRender(width, height, CRgbaquad(0,0,0,0)); if(glTexture != nullptr) { muVideoEffect.lock(); int enableopenCL = videoEffectParameter.enableOpenCL; muVideoEffect.unlock(); int inverted = 1; int x = (width - glTexture->GetWidth()) / 2; int y = (height - glTexture->GetHeight()) / 2; if(openclContext->IsSharedContextCompatible()) inverted = 0; if(!enableopenCL) inverted = 1; if(isffmpegDecode) inverted = 1; //printf("Inverted %d Enable OpenCL %d \n",inverted, enableopenCL); printf("flipH : %d flipV : %d inverted : %d \n", flipH, flipV, inverted); muVideoEffect.lock(); renderBitmapOpenGL->RenderWithEffect(x,y, glTexture, &videoEffectParameter, flipH, flipV, inverted); printf("Rotation : %d \n",videoEffectParameter.rotation); muVideoEffect.unlock(); } muVideoEffect.lock(); if(videoEffectParameter.showFPS) { renderBitmapOpenGL->Print(0, 1, CConvertUtility::ConvertToUTF8(msgFrame)); } muVideoEffect.unlock(); muSubtitle.lock(); if(subtilteUpdate && pictureSubtitle != nullptr) { renderBitmapOpenGL->SetSubtitle(pictureSubtitle); delete pictureSubtitle; pictureSubtitle = nullptr; subtilteUpdate = false; } else if(subtilteUpdate) { renderBitmapOpenGL->DeleteSubtitle(); subtilteUpdate = false; } muSubtitle.unlock(); if(videoEffectParameter.enableSubtitle) { renderBitmapOpenGL->ShowSubtitle(); } } else { renderBitmapOpenGL->CreateScreenRender(width, height, CRgbaquad(0,0,0,0)); } this->SwapBuffers(); if(deleteTexture && glTexture != nullptr) delete glTexture; double duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC; std::cout<<"Video OnPaint Time : "<< duration <<'\n'; // printf("OnPaint end \n"); }