[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl2' - 3 commits - vcl/inc vcl/opengl vcl/workben
Michael Meeks
michael.meeks at collabora.com
Sun Nov 16 22:37:57 PST 2014
vcl/inc/opengl/salbmp.hxx | 2 ++
vcl/inc/opengl/win/gdiimpl.hxx | 1 +
vcl/inc/opengl/x11/gdiimpl.hxx | 1 +
vcl/inc/openglgdiimpl.hxx | 2 +-
vcl/opengl/gdiimpl.cxx | 4 ++--
vcl/opengl/salbmp.cxx | 28 ++++++++++++++++++----------
vcl/opengl/win/gdiimpl.cxx | 6 ++++++
vcl/opengl/x11/gdiimpl.cxx | 6 ++++++
vcl/workben/vcldemo.cxx | 21 +++++++++++++++------
9 files changed, 52 insertions(+), 19 deletions(-)
New commits:
commit 8c151cbdd5ea2061af469499eda5a70039557cfa
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Nov 17 06:37:06 2014 +0000
vcldemo: improve my rather trivial inferred alpha maths.
Change-Id: I420628cea2272d6f5af0b13b9c32902627dcf86f
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 9894f4f..336c85d 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -799,16 +799,25 @@ public:
// we get the most precision from the largest delta
long nInverseAlpha = std::max(nAR, std::max(nAG, nAB)); // (1-a)
nInverseAlpha = CLAMP(nInverseAlpha, 0, 255);
+ long nAlpha = 255 - nInverseAlpha;
pMaskAcc->SetPixel(y,x,BitmapColor((sal_Int8)CLAMP(nInverseAlpha,0,255)));
// now recover the pixels
- long n2R = aColW.GetRed() + aColB.GetRed();
- long n2G = aColW.GetGreen() + aColB.GetGreen();
- long n2B = aColW.GetBlue() + aColB.GetBlue();
+ long nR = (aColW.GetRed() + aColB.GetRed() - nInverseAlpha) * 128;
+ long nG = (aColW.GetGreen() + aColB.GetGreen() - nInverseAlpha) * 128;
+ long nB = (aColW.GetBlue() + aColB.GetBlue() - nInverseAlpha) * 128;
+ if (nAlpha == 0)
+ { // doesn't matter what's behind transparency
+ nR = nG = nB = 0;
+ }
+ else
+ {
+ nR /= nAlpha; nG /= nAlpha; nB /= nAlpha;
+ }
pRecAcc->SetPixel(y,x,BitmapColor(
- (sal_uInt8)CLAMP((n2R+1)/2-nInverseAlpha,0,255),
- (sal_uInt8)CLAMP((n2G+1)/2-nInverseAlpha,0,255),
- (sal_uInt8)CLAMP((n2B+1)/2-nInverseAlpha,0,255)));
+ (sal_uInt8)CLAMP(nR,0,255),
+ (sal_uInt8)CLAMP(nG,0,255),
+ (sal_uInt8)CLAMP(nB,0,255)));
#undef CLAMP
}
}
commit 97cb820d3c183a83652dd2779fa2da224ea44240
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Nov 17 05:15:13 2014 +0000
vcl: always use the default windows' GL Context for now to create bitmaps.
Change-Id: Ie20b10656788113709b0b0720d3cae2653639d78
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index dbb29d8..9995645 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -52,6 +52,8 @@ private:
int mnBufHeight;
std::deque< OpenGLSalBitmapOp* > maPendingOps;
+ bool makeCurrent();
+
public:
OpenGLSalBitmap();
virtual ~OpenGLSalBitmap();
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 4b5287e..780c268 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -395,7 +395,7 @@ GLuint OpenGLSalBitmap::CreateTexture()
}
}
- mpContext->makeCurrent();
+ makeCurrent();
maTexture = OpenGLTexture (mnBufWidth, mnBufHeight, nFormat, nType, pData );
SAL_INFO( "vcl.opengl", "Created texture " << maTexture.Id() );
@@ -449,7 +449,7 @@ bool OpenGLSalBitmap::ReadTexture()
return false;
}
- mpContext->makeCurrent();
+ makeCurrent();
maTexture.Read( nFormat, nType, pData );
mnBufWidth = mnWidth;
mnBufHeight = mnHeight;
@@ -462,6 +462,20 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const
return mnBits;
}
+bool OpenGLSalBitmap::makeCurrent()
+{
+ OpenGLContextProvider *pProvider;
+ pProvider = dynamic_cast< OpenGLContextProvider* >( ImplGetDefaultWindow()->GetGraphics() );
+ if( pProvider == NULL )
+ {
+ SAL_WARN( "vcl.opengl", "Couldn't get default OpenGL context provider" );
+ return false;
+ }
+ mpContext = pProvider->GetOpenGLContext();
+ mpContext->makeCurrent();
+ return true;
+}
+
BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
{
if( !maUserBuffer.get() )
@@ -474,15 +488,9 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
if( !maPendingOps.empty() )
{
- OpenGLContextProvider *pProvider;
- pProvider = dynamic_cast< OpenGLContextProvider* >( ImplGetDefaultWindow()->GetGraphics() );
- if( pProvider == NULL )
- {
- SAL_WARN( "vcl.opengl", "Couldn't get default OpenGL context provider" );
+ if (!makeCurrent())
return NULL;
- }
- mpContext = pProvider->GetOpenGLContext();
- mpContext->makeCurrent();
+
SAL_INFO( "vcl.opengl", "** Creating texture and reading it back immediatly" );
if( !CreateTexture() || !AllocateUserData() || !ReadTexture() )
return NULL;
commit 1989aea1c8df3fdd468efe85d3897e9ac5679db5
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Nov 17 04:35:29 2014 +0000
vcl: copyBits should operate on mrParent if no context supplied.
eg. OutputDevice::DrawOutDev:
mpGraphics->CopyBits( aPosAry, NULL, this, NULL );
Change-Id: I0b041bb5aa6aba573b9f589842084722481cb438
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index 085be79..557e58a 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -29,6 +29,7 @@ protected:
virtual GLfloat GetHeight() const SAL_OVERRIDE;
public:
+ virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
};
diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx
index 00eaf8c..a2b863e 100644
--- a/vcl/inc/opengl/x11/gdiimpl.hxx
+++ b/vcl/inc/opengl/x11/gdiimpl.hxx
@@ -32,6 +32,7 @@ protected:
public:
// implementation of X11GraphicsImpl
+ virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
void Init() SAL_OVERRIDE;
bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index dd0b1e3..80d760a 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -216,7 +216,7 @@ public:
// CopyBits and DrawBitmap --> RasterOp and ClipRegion
// CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics
- virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
+ void DoCopyBits( const SalTwoRect& rPosAry, OpenGLSalGraphicsImpl *pSrcImpl );
virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) SAL_OVERRIDE;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 5c5eae3..fc173ae 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1171,9 +1171,9 @@ void OpenGLSalGraphicsImpl::copyArea(
// CopyBits and DrawBitmap --> RasterOp and ClipRegion
// CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics
-void OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
+void OpenGLSalGraphicsImpl::DoCopyBits( const SalTwoRect& rPosAry, OpenGLSalGraphicsImpl* pSrcImpl )
{
- OpenGLSalGraphicsImpl *pImpl = pSrcGraphics ? dynamic_cast< OpenGLSalGraphicsImpl* >(pSrcGraphics->GetImpl()) : NULL;
+ OpenGLSalGraphicsImpl *pImpl = pSrcImpl;
SAL_INFO( "vcl.opengl", "::copyBits" );
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index e829ca4..67a192e 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -18,6 +18,12 @@ WinOpenGLSalGraphicsImpl::WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics):
{
}
+void WinOpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
+{
+ OpenGLSalGraphicsImpl *pImpl = pSrcGraphics ? dynamic_cast< OpenGLSalGraphicsImpl* >(pSrcGraphics->GetImpl()) : static_cast< OpenGLSalGraphicsImpl *>(mrParent.GetImpl());
+ OpenGLSalGraphicsImpl::DoCopyBits( rPosAry, pImpl );
+}
+
GLfloat WinOpenGLSalGraphicsImpl::GetWidth() const
{
if( mrParent.gethWnd() && IsWindow( mrParent.gethWnd() ) )
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 5292038..dcefcc2 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -81,6 +81,12 @@ void X11OpenGLSalGraphicsImpl::Init()
}
}
+void X11OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
+{
+ OpenGLSalGraphicsImpl *pImpl = pSrcGraphics ? dynamic_cast< OpenGLSalGraphicsImpl* >(pSrcGraphics->GetImpl()) : static_cast< OpenGLSalGraphicsImpl *>(mrParent.GetImpl());
+ OpenGLSalGraphicsImpl::DoCopyBits( rPosAry, pImpl );
+}
+
bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY )
{
Display* pDisplay = mrParent.GetXDisplay();
More information about the Libreoffice-commits
mailing list