mirror of https://github.com/buggins/dlangui.git
Merge branch 'master' of github.com:buggins/dlangui
This commit is contained in:
commit
34f26ff445
|
@ -105,8 +105,8 @@ class GLDrawBuf : DrawBuf, GLConfigCallback {
|
||||||
if (!isFullyTransparentColor(color) && applyClipping(rc))
|
if (!isFullyTransparentColor(color) && applyClipping(rc))
|
||||||
_scene.add(new SolidRectSceneItem(rc, color));
|
_scene.add(new SolidRectSceneItem(rc, color));
|
||||||
}
|
}
|
||||||
/// draw pixel at (x, y) with specified color
|
/// draw pixel at (x, y) with specified color
|
||||||
override void drawPixel(int x, int y, uint color) {
|
override void drawPixel(int x, int y, uint color) {
|
||||||
assert(_scene !is null);
|
assert(_scene !is null);
|
||||||
if (!_clipRect.isPointInside(x, y))
|
if (!_clipRect.isPointInside(x, y))
|
||||||
return;
|
return;
|
||||||
|
@ -114,7 +114,7 @@ class GLDrawBuf : DrawBuf, GLConfigCallback {
|
||||||
if (isFullyTransparentColor(color))
|
if (isFullyTransparentColor(color))
|
||||||
return;
|
return;
|
||||||
_scene.add(new SolidRectSceneItem(Rect(x, y, x + 1, y + 1), color));
|
_scene.add(new SolidRectSceneItem(Rect(x, y, x + 1, y + 1), color));
|
||||||
}
|
}
|
||||||
/// draw 8bit alpha image - usually font glyph using specified color (clipping is applied)
|
/// draw 8bit alpha image - usually font glyph using specified color (clipping is applied)
|
||||||
override void drawGlyph(int x, int y, Glyph * glyph, uint color) {
|
override void drawGlyph(int x, int y, Glyph * glyph, uint color) {
|
||||||
assert(_scene !is null);
|
assert(_scene !is null);
|
||||||
|
@ -298,7 +298,7 @@ private class GLImageCache {
|
||||||
private int _x;
|
private int _x;
|
||||||
private bool _closed;
|
private bool _closed;
|
||||||
private bool _needUpdateTexture;
|
private bool _needUpdateTexture;
|
||||||
private uint _textureId;
|
private Tex2D _texture;
|
||||||
private int _itemCount;
|
private int _itemCount;
|
||||||
|
|
||||||
this(GLImageCache cache, int dx, int dy) {
|
this(GLImageCache cache, int dx, int dy) {
|
||||||
|
@ -314,26 +314,26 @@ private class GLImageCache {
|
||||||
destroy(_drawbuf);
|
destroy(_drawbuf);
|
||||||
_drawbuf = null;
|
_drawbuf = null;
|
||||||
}
|
}
|
||||||
if (_textureId != 0) {
|
if (_texture.ID != 0) {
|
||||||
glSupport.deleteTexture(_textureId);
|
destroy(_texture);
|
||||||
_textureId = 0;
|
_texture = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTexture() {
|
void updateTexture() {
|
||||||
if (_drawbuf is null)
|
if (_drawbuf is null)
|
||||||
return; // no draw buffer!!!
|
return; // no draw buffer!!!
|
||||||
if (_textureId == 0) {
|
if (_texture is null || _texture.ID == 0) {
|
||||||
_textureId = glSupport.genTexture();
|
_texture = new Tex2D();
|
||||||
Log.d("updateTexture - new texture id=", _textureId);
|
Log.d("updateTexture - new texture id=", _texture.ID);
|
||||||
if (!_textureId)
|
if (!_texture.ID)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.d("updateTexture for image cache page - setting image ", _drawbuf.width, "x", _drawbuf.height, " tx=", _textureId);
|
Log.d("updateTexture for image cache page - setting image ", _drawbuf.width, "x", _drawbuf.height, " tx=", _texture.ID);
|
||||||
uint * pixels = _drawbuf.scanLine(0);
|
uint * pixels = _drawbuf.scanLine(0);
|
||||||
if (!glSupport.setTextureImage(_textureId, _drawbuf.width, _drawbuf.height, cast(ubyte*)pixels)) {
|
if (!glSupport.setTextureImage(_texture, _drawbuf.width, _drawbuf.height, cast(ubyte*)pixels)) {
|
||||||
glSupport.deleteTexture(_textureId);
|
destroy(_texture);
|
||||||
_textureId = 0;
|
_texture = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_needUpdateTexture = false;
|
_needUpdateTexture = false;
|
||||||
|
@ -409,11 +409,7 @@ private class GLImageCache {
|
||||||
//CRLog::trace("drawing item at %d,%d %dx%d <= %d,%d %dx%d ", x, y, dx, dy, srcx, srcy, srcdx, srcdy);
|
//CRLog::trace("drawing item at %d,%d %dx%d <= %d,%d %dx%d ", x, y, dx, dy, srcx, srcy, srcdx, srcdy);
|
||||||
if (_needUpdateTexture)
|
if (_needUpdateTexture)
|
||||||
updateTexture();
|
updateTexture();
|
||||||
if (_textureId != 0) {
|
if (_texture.ID != 0) {
|
||||||
if (!glSupport.isTexture(_textureId)) {
|
|
||||||
Log.e("Invalid texture ", _textureId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//rotationAngle = 0;
|
//rotationAngle = 0;
|
||||||
int rx = dstrc.middlex;
|
int rx = dstrc.middlex;
|
||||||
int ry = dstrc.middley;
|
int ry = dstrc.middley;
|
||||||
|
@ -442,15 +438,14 @@ private class GLImageCache {
|
||||||
dstrc.bottom -= clip.bottom;
|
dstrc.bottom -= clip.bottom;
|
||||||
}
|
}
|
||||||
if (!dstrc.empty)
|
if (!dstrc.empty)
|
||||||
glSupport.drawColorAndTextureRect(_textureId, _tdx, _tdy, srcrc, dstrc, color, srcrc.width() != dstrc.width() || srcrc.height() != dstrc.height());
|
glSupport.drawColorAndTextureRect(_texture, _tdx, _tdy, srcrc, dstrc, color, srcrc.width() != dstrc.width() || srcrc.height() != dstrc.height());
|
||||||
//drawColorAndTextureRect(vertices, texcoords, color, _textureId);
|
//drawColorAndTextureRect(vertices, texcoords, color, _texture);
|
||||||
|
|
||||||
if (rotationAngle) {
|
if (rotationAngle) {
|
||||||
// unset rotation
|
// unset rotation
|
||||||
glSupport.setRotation(rx, ry, 0);
|
glSupport.setRotation(rx, ry, 0);
|
||||||
// glMatrixMode(GL_PROJECTION);
|
// glMatrixMode(GL_PROJECTION);
|
||||||
// glPopMatrix();
|
// checkgl!glPopMatrix();
|
||||||
// checkError("pop matrix");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -627,7 +622,7 @@ private class GLGlyphCache {
|
||||||
private int _x;
|
private int _x;
|
||||||
private bool _closed;
|
private bool _closed;
|
||||||
private bool _needUpdateTexture;
|
private bool _needUpdateTexture;
|
||||||
private uint _textureId;
|
private Tex2D _texture;
|
||||||
private int _itemCount;
|
private int _itemCount;
|
||||||
|
|
||||||
this(GLGlyphCache cache, int dx, int dy) {
|
this(GLGlyphCache cache, int dx, int dy) {
|
||||||
|
@ -643,26 +638,26 @@ private class GLGlyphCache {
|
||||||
destroy(_drawbuf);
|
destroy(_drawbuf);
|
||||||
_drawbuf = null;
|
_drawbuf = null;
|
||||||
}
|
}
|
||||||
if (_textureId != 0) {
|
if (_texture.ID != 0) {
|
||||||
glSupport.deleteTexture(_textureId);
|
destroy(_texture);
|
||||||
_textureId = 0;
|
_texture = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTexture() {
|
void updateTexture() {
|
||||||
if (_drawbuf is null)
|
if (_drawbuf is null)
|
||||||
return; // no draw buffer!!!
|
return; // no draw buffer!!!
|
||||||
if (_textureId == 0) {
|
if (_texture is null || _texture.ID == 0) {
|
||||||
_textureId = glSupport.genTexture();
|
_texture = new Tex2D();
|
||||||
//Log.d("updateTexture - new texture ", _textureId);
|
//Log.d("updateTexture - new texture ", _texture.ID);
|
||||||
if (!_textureId)
|
if (!_texture.ID)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Log.d("updateTexture for font glyph page - setting image ", _drawbuf.width, "x", _drawbuf.height, " tx=", _textureId);
|
//Log.d("updateTexture for font glyph page - setting image ", _drawbuf.width, "x", _drawbuf.height, " tx=", _texture.ID);
|
||||||
int len = _drawbuf.width * _drawbuf.height;
|
int len = _drawbuf.width * _drawbuf.height;
|
||||||
if (!glSupport.setTextureImage(_textureId, _drawbuf.width, _drawbuf.height, cast(ubyte *)_drawbuf.scanLine(0))) {
|
if (!glSupport.setTextureImage(_texture, _drawbuf.width, _drawbuf.height, cast(ubyte *)_drawbuf.scanLine(0))) {
|
||||||
glSupport.deleteTexture(_textureId);
|
destroy(_texture);
|
||||||
_textureId = 0;
|
_texture = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_needUpdateTexture = false;
|
_needUpdateTexture = false;
|
||||||
|
@ -724,11 +719,7 @@ private class GLGlyphCache {
|
||||||
//CRLog::trace("drawing item at %d,%d %dx%d <= %d,%d %dx%d ", x, y, dx, dy, srcx, srcy, srcdx, srcdy);
|
//CRLog::trace("drawing item at %d,%d %dx%d <= %d,%d %dx%d ", x, y, dx, dy, srcx, srcy, srcdx, srcdy);
|
||||||
if (_needUpdateTexture)
|
if (_needUpdateTexture)
|
||||||
updateTexture();
|
updateTexture();
|
||||||
if (_textureId != 0) {
|
if (_texture.ID != 0) {
|
||||||
if (!glSupport.isTexture(_textureId)) {
|
|
||||||
Log.e("Invalid texture ", _textureId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// convert coordinates to cached texture
|
// convert coordinates to cached texture
|
||||||
srcrc.offset(item._rc.left, item._rc.top);
|
srcrc.offset(item._rc.left, item._rc.top);
|
||||||
if (clip) {
|
if (clip) {
|
||||||
|
@ -751,8 +742,8 @@ private class GLGlyphCache {
|
||||||
}
|
}
|
||||||
if (!dstrc.empty) {
|
if (!dstrc.empty) {
|
||||||
//Log.d("drawing glyph with color ", color);
|
//Log.d("drawing glyph with color ", color);
|
||||||
glSupport.drawColorAndTextureGlyphRect(_textureId, _tdx, _tdy, srcrc, dstrc, color);
|
glSupport.drawColorAndTextureGlyphRect(_texture, _tdx, _tdy, srcrc, dstrc, color);
|
||||||
//glSupport.drawColorAndTextureRect(_textureId, _tdx, _tdy, srcrc, dstrc, color, false);
|
//glSupport.drawColorAndTextureRect(_texture, _tdx, _tdy, srcrc, dstrc, color, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue