summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/inc/opengl/AccumulatedTextures.hxx7
-rw-r--r--vcl/opengl/PackedTextureAtlas.cxx8
-rw-r--r--vcl/opengl/gdiimpl.cxx7
-rw-r--r--vcl/opengl/texture.cxx10
-rw-r--r--vcl/win/source/gdi/winlayout.cxx39
5 files changed, 46 insertions, 25 deletions
diff --git a/vcl/inc/opengl/AccumulatedTextures.hxx b/vcl/inc/opengl/AccumulatedTextures.hxx
index e74c06535f69..882a69476db5 100644
--- a/vcl/inc/opengl/AccumulatedTextures.hxx
+++ b/vcl/inc/opengl/AccumulatedTextures.hxx
@@ -88,8 +88,11 @@ public:
maEntries.clear();
}
- void insert(OpenGLTexture& rTexture, const SalColor& aColor, const SalTwoRect& r2Rect)
+ bool insert(OpenGLTexture& rTexture, const SalColor& aColor, const SalTwoRect& r2Rect)
{
+ if (!rTexture)
+ return false;
+
GLuint nTextureId = rTexture.Id();
if (maEntries.find(nTextureId) == maEntries.end())
@@ -100,6 +103,8 @@ public:
std::unique_ptr<AccumulatedTexturesEntry>& rEntry = maEntries[nTextureId];
rEntry->insert(rTexture, aColor, r2Rect);
+
+ return true;
}
AccumulatedTexturesMap& getAccumulatedTexturesMap()
diff --git a/vcl/opengl/PackedTextureAtlas.cxx b/vcl/opengl/PackedTextureAtlas.cxx
index 0231cbdda530..c8e9c3fba597 100644
--- a/vcl/opengl/PackedTextureAtlas.cxx
+++ b/vcl/opengl/PackedTextureAtlas.cxx
@@ -110,7 +110,7 @@ Node* Node::insert(int nWidth, int nHeight, int nPadding)
struct PackedTexture
{
- ImplOpenGLTexture* mpTexture;
+ std::unique_ptr<ImplOpenGLTexture> mpTexture;
std::unique_ptr<Node> mpRootNode;
int mnDeallocatedArea;
@@ -132,7 +132,7 @@ PackedTextureAtlasManager::~PackedTextureAtlasManager()
for (std::unique_ptr<PackedTexture>& pPackedTexture : maPackedTextures)
{
// Free texture early in VCL shutdown while we have a context.
- delete pPackedTexture->mpTexture;
+ pPackedTexture->mpTexture.reset();
}
}
@@ -152,7 +152,7 @@ OpenGLTexture PackedTextureAtlasManager::Reserve(int nWidth, int nHeight)
Node* pNode = pPackedTexture->mpRootNode->insert(nWidth, nHeight, 1);
if (pNode != nullptr)
{
- return OpenGLTexture(pPackedTexture->mpTexture, pNode->mRectangle, -1);
+ return OpenGLTexture(pPackedTexture->mpTexture.get(), pNode->mRectangle, -1);
}
}
CreateNewTexture();
@@ -160,7 +160,7 @@ OpenGLTexture PackedTextureAtlasManager::Reserve(int nWidth, int nHeight)
Node* pNode = pPackedTexture->mpRootNode->insert(nWidth, nHeight, 1);
if (pNode != nullptr)
{
- return OpenGLTexture(pPackedTexture->mpTexture, pNode->mRectangle, -1);
+ return OpenGLTexture(pPackedTexture->mpTexture.get(), pNode->mRectangle, -1);
}
return OpenGLTexture();
}
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index d9640b96381b..c6139e8b5f33 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -2497,8 +2497,11 @@ void OpenGLSalGraphicsImpl::doFlush()
{
FlushDeferredDrawing();
- mpContext->state()->scissor().disable();
- mpContext->state()->stencil().disable();
+ if (OpenGLContext::hasCurrent())
+ {
+ mpContext->state()->scissor().disable();
+ mpContext->state()->stencil().disable();
+ }
if( IsOffscreen() )
return;
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 9f5f9a2965a3..63e39b8f34fc 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -413,11 +413,11 @@ void OpenGLTexture::FillCoords<GL_TRIANGLES>(std::vector<GLfloat>& aCoord, const
GLfloat y1 = 0.0f;
GLfloat y2 = 0.0f;
- double fTextureWidth(mpImpl->mnWidth);
- double fTextureHeight(mpImpl->mnHeight);
-
if (mpImpl)
{
+ double fTextureWidth(mpImpl->mnWidth);
+ double fTextureHeight(mpImpl->mnHeight);
+
x1 = (maRect.Left() + rPosAry.mnSrcX) / fTextureWidth;
x2 = (maRect.Left() + rPosAry.mnSrcX + rPosAry.mnSrcWidth) / fTextureWidth;
@@ -472,7 +472,9 @@ void OpenGLTexture::GetWholeCoord( GLfloat* pCoord ) const
OpenGLTexture OpenGLTexture::GetWholeTexture()
{
- return OpenGLTexture(mpImpl, Rectangle(Point(0, 0), Size(mpImpl->mnWidth, mpImpl->mnHeight)), -1);
+ if (mpImpl)
+ return OpenGLTexture(mpImpl, Rectangle(Point(0, 0), Size(mpImpl->mnWidth, mpImpl->mnHeight)), -1);
+ return OpenGLTexture();
}
GLenum OpenGLTexture::GetFilter() const
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 170c94be21a2..360a3d35b85f 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -127,10 +127,12 @@ public:
gGlobalGlyphCache.get()->maGlyphCaches.erase(this);
}
- void ReserveTextureSpace(OpenGLGlyphDrawElement& rElement, int nWidth, int nHeight)
+ bool ReserveTextureSpace(OpenGLGlyphDrawElement& rElement, int nWidth, int nHeight)
{
GlobalGlyphCache* pGlobalGlyphCache = gGlobalGlyphCache.get();
rElement.maTexture = pGlobalGlyphCache->maPackedTextureAtlas.Reserve(nWidth, nHeight);
+ if (!rElement.maTexture)
+ return false;
std::vector<GLuint> aTextureIDs = pGlobalGlyphCache->maPackedTextureAtlas.ReduceTextureNumber(8);
if (!aTextureIDs.empty())
{
@@ -139,6 +141,7 @@ public:
pGlyphCache->RemoveTextures(aTextureIDs);
}
}
+ return true;
}
void RemoveTextures(std::vector<GLuint>& rTextureIDs)
@@ -508,8 +511,11 @@ bool ImplWinFontEntry::CacheGlyphToAtlas(bool bRealGlyphIndices, int nGlyphIndex
pTxt->ReleaseFont();
- maGlyphCache.ReserveTextureSpace(aElement, nBitmapWidth, nBitmapHeight);
- aDC.copyToTexture(aElement.maTexture);
+ if (!maGlyphCache.ReserveTextureSpace(aElement, nBitmapWidth, nBitmapHeight))
+ return false;
+ if (!aDC.copyToTexture(aElement.maTexture))
+ return false;
+
maGlyphCache.PutDrawElementInCache(aElement, nGlyphIndex);
SelectFont(aDC.getCompatibleHDC(), hOrigFont);
@@ -1459,11 +1465,11 @@ bool SimpleWinLayout::CacheGlyphs(SalGraphics& rGraphics) const
nCodePoint = mpOutGlyphs[i];
}
- if (mrWinFontEntry.GetGlyphCache().IsGlyphCached(nCodePoint))
- continue;
-
- if (!mrWinFontEntry.CacheGlyphToAtlas(false, nCodePoint, *this, rGraphics))
- return false;
+ if (!mrWinFontEntry.GetGlyphCache().IsGlyphCached(nCodePoint))
+ {
+ if (!mrWinFontEntry.CacheGlyphToAtlas(false, nCodePoint, *this, rGraphics))
+ return false;
+ }
}
return true;
@@ -1508,6 +1514,9 @@ bool SimpleWinLayout::DrawCachedGlyphs(SalGraphics& rGraphics) const
OpenGLGlyphDrawElement& rElement(mrWinFontEntry.GetGlyphCache().GetDrawElement(nCodePoint));
OpenGLTexture& rTexture = rElement.maTexture;
+ if (!rTexture)
+ return false;
+
SalTwoRect a2Rects(0, 0,
rTexture.GetWidth(), rTexture.GetHeight(),
nAdvance + aPos.X() - rElement.getExtraOffset() + rElement.maLeftOverhangs,
@@ -2729,12 +2738,11 @@ bool UniscribeLayout::CacheGlyphs(SalGraphics& rGraphics) const
for (int i = 0; i < mnGlyphCount; i++)
{
int nCodePoint = mpOutGlyphs[i];
-
- if (mrWinFontEntry.GetGlyphCache().IsGlyphCached(nCodePoint))
- continue;
-
- if (!mrWinFontEntry.CacheGlyphToAtlas(true, nCodePoint, *this, rGraphics))
- return false;
+ if (!mrWinFontEntry.GetGlyphCache().IsGlyphCached(nCodePoint))
+ {
+ if (!mrWinFontEntry.CacheGlyphToAtlas(true, nCodePoint, *this, rGraphics))
+ return false;
+ }
}
}
@@ -2994,6 +3002,9 @@ bool UniscribeLayout::DrawCachedGlyphsUsingTextures(SalGraphics& rGraphics) cons
OpenGLGlyphDrawElement& rElement = mrWinFontEntry.GetGlyphCache().GetDrawElement(mpOutGlyphs[i]);
OpenGLTexture& rTexture = rElement.maTexture;
+ if (!rTexture)
+ return false;
+
if (rElement.mbVertical)
{
SalTwoRect a2Rects(0, 0,