mirror of https://github.com/buggins/dlangui.git
performace optimizations
This commit is contained in:
parent
90aa9bbb49
commit
970928d5f6
|
@ -36,7 +36,8 @@
|
|||
<OutputName>dlanguilib</OutputName>
|
||||
<ObjectsDirectory>obj/Release</ObjectsDirectory>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<Target>Executable</Target>
|
||||
<Target>StaticLibrary</Target>
|
||||
<ExtraCompilerArguments>-version=USE_OPENGL</ExtraCompilerArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Unittest|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -45,7 +46,7 @@
|
|||
<ObjectsDirectory>obj/Unittest</ObjectsDirectory>
|
||||
<OutputName>dlanguilib</OutputName>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<Target>Executable</Target>
|
||||
<Target>StaticLibrary</Target>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="src\dlangui\core\logger.d" />
|
||||
|
@ -61,9 +62,6 @@
|
|||
<Compile Include="src\dlangui\widgets\layouts.d" />
|
||||
<Compile Include="src\dlangui\widgets\styles.d" />
|
||||
<Compile Include="src\dlangui\widgets\widget.d" />
|
||||
<Compile Include="3rdparty\libpng\source\libpng\png.d" />
|
||||
<Compile Include="3rdparty\libpng\source\libpng\pngconf.d" />
|
||||
<Compile Include="3rdparty\libpng\source\libpng\pnglibconf.d" />
|
||||
<Compile Include="src\dlangui\platforms\x11\x11app.d" />
|
||||
<Compile Include="..\DerelictFT\source\derelict\freetype\ft.d">
|
||||
<Link>3rdparty\DerelictFT\ft.d</Link>
|
||||
|
|
|
@ -5,7 +5,7 @@ import std.stdio;
|
|||
import std.conv;
|
||||
|
||||
version (linux) {
|
||||
pragma(lib, "png");
|
||||
//pragma(lib, "png");
|
||||
pragma(lib, "xcb");
|
||||
pragma(lib, "xcb-shm");
|
||||
pragma(lib, "xcb-image");
|
||||
|
|
|
@ -80,6 +80,7 @@ class Window {
|
|||
_mainWidget.layout(Rect(0, 0, _dx, _dy));
|
||||
long layoutEnd = currentTimeMillis;
|
||||
Log.d("layout took ", layoutEnd - measureEnd, " ms");
|
||||
checkUpdateNeeded(needDraw, needLayout, animationActive);
|
||||
}
|
||||
long drawStart = currentTimeMillis;
|
||||
_mainWidget.onDraw(buf);
|
||||
|
|
|
@ -28,6 +28,13 @@ version(linux) {
|
|||
import derelict.opengl3.gl3;
|
||||
import derelict.opengl3.glx;
|
||||
|
||||
// pragma(lib, "xcb");
|
||||
// pragma(lib, "xcb-shm");
|
||||
// pragma(lib, "xcb-image");
|
||||
// pragma(lib, "X11-xcb");
|
||||
// pragma(lib, "X11");
|
||||
// pragma(lib, "dl");
|
||||
|
||||
extern (System)
|
||||
xcb_connection_t *XGetXCBConnection(std.c.linux.X11.Xlib.Display *dpy);
|
||||
enum XEventQueueOwner { XlibOwnsEventQueue = 0, XCBOwnsEventQueue };
|
||||
|
@ -161,11 +168,19 @@ version(linux) {
|
|||
return true;
|
||||
}
|
||||
|
||||
private int _imageDx;
|
||||
private int _imageDy;
|
||||
void createImage() {
|
||||
Log.i("CRXCBScreen::createImage ", _dx, "x", _dy);
|
||||
if (_image)
|
||||
if (_image) {
|
||||
if (_imageDx == _imageDx && _imageDy == _dy)
|
||||
return; // already have image of proper size
|
||||
Log.i("CRXCBScreen::createImage - destroying existing image");
|
||||
xcb_image_destroy(_image);
|
||||
_image = null;
|
||||
_image = null;
|
||||
}
|
||||
_imageDx = _dx;
|
||||
_imageDy = _dy;
|
||||
Log.i("CRXCBScreen::createImage ", _dx, "x", _dy);
|
||||
xcb_shm_query_version_reply_t * rep_shm;
|
||||
rep_shm = xcb_shm_query_version_reply (_xcbconnection,
|
||||
xcb_shm_query_version(_xcbconnection),
|
||||
|
@ -403,9 +418,9 @@ version(linux) {
|
|||
_drawbuf = new ColorDrawBuf(_dx, _dy);
|
||||
_drawbuf.resize(_dx, _dy);
|
||||
_drawbuf.fill(_backgroundColor);
|
||||
Log.d("calling createImage");
|
||||
//Log.d("calling createImage");
|
||||
createImage();
|
||||
Log.d("done createImage");
|
||||
//Log.d("done createImage");
|
||||
onDraw(_drawbuf);
|
||||
draw(_drawbuf);
|
||||
/*
|
||||
|
|
|
@ -457,7 +457,31 @@ class ScrollBar : AbstractSlider, OnClickHandler {
|
|||
measuredContent(parentWidth, parentHeight, sz.x, sz.y);
|
||||
}
|
||||
|
||||
protected void layoutButtons(Rect irc) {
|
||||
override protected void onPositionChanged() {
|
||||
if (!needLayout)
|
||||
layoutButtons();
|
||||
}
|
||||
|
||||
protected void layoutButtons() {
|
||||
Rect irc = _scrollArea;
|
||||
if (_orientation == Orientation.Vertical) {
|
||||
// vertical
|
||||
int spaceBackSize, spaceForwardSize, indicatorSize;
|
||||
bool indicatorVisible = calcButtonSizes(_scrollArea.height, spaceBackSize, spaceForwardSize, indicatorSize);
|
||||
irc.top += spaceBackSize;
|
||||
irc.bottom -= spaceForwardSize;
|
||||
layoutButtons(irc);
|
||||
} else {
|
||||
// horizontal
|
||||
int spaceBackSize, spaceForwardSize, indicatorSize;
|
||||
bool indicatorVisible = calcButtonSizes(_scrollArea.width, spaceBackSize, spaceForwardSize, indicatorSize);
|
||||
irc.left += spaceBackSize;
|
||||
irc.right -= spaceForwardSize;
|
||||
layoutButtons(irc);
|
||||
}
|
||||
}
|
||||
|
||||
protected void layoutButtons(Rect irc) {
|
||||
Rect r;
|
||||
_indicator.visibility = Visibility.Visible;
|
||||
if (_orientation == Orientation.Vertical) {
|
||||
|
@ -500,6 +524,7 @@ class ScrollBar : AbstractSlider, OnClickHandler {
|
|||
}
|
||||
|
||||
override void layout(Rect rc) {
|
||||
_needLayout = false;
|
||||
applyMargins(rc);
|
||||
applyPadding(rc);
|
||||
Rect r;
|
||||
|
@ -519,12 +544,6 @@ class ScrollBar : AbstractSlider, OnClickHandler {
|
|||
r.top = backbtnpos;
|
||||
r.bottom = fwdbtnpos;
|
||||
_scrollArea = r;
|
||||
int spaceBackSize, spaceForwardSize, indicatorSize;
|
||||
bool indicatorVisible = calcButtonSizes(r.height, spaceBackSize, spaceForwardSize, indicatorSize);
|
||||
Rect irc = r;
|
||||
irc.top += spaceBackSize;
|
||||
irc.bottom -= spaceForwardSize;
|
||||
layoutButtons(irc);
|
||||
} else {
|
||||
// horizontal
|
||||
int backbtnpos = rc.left + _btnSize;
|
||||
|
@ -540,15 +559,9 @@ class ScrollBar : AbstractSlider, OnClickHandler {
|
|||
r.left = backbtnpos;
|
||||
r.right = fwdbtnpos;
|
||||
_scrollArea = r;
|
||||
int spaceBackSize, spaceForwardSize, indicatorSize;
|
||||
bool indicatorVisible = calcButtonSizes(r.width, spaceBackSize, spaceForwardSize, indicatorSize);
|
||||
Rect irc = r;
|
||||
irc.left += spaceBackSize;
|
||||
irc.right -= spaceForwardSize;
|
||||
layoutButtons(irc);
|
||||
}
|
||||
layoutButtons();
|
||||
_pos = rc;
|
||||
_needLayout = false;
|
||||
}
|
||||
|
||||
override bool onClick(Widget source) {
|
||||
|
|
|
@ -253,15 +253,14 @@ class LinearLayout : WidgetGroup {
|
|||
|
||||
/// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
|
||||
override void layout(Rect rc) {
|
||||
_needLayout = false;
|
||||
if (visibility == Visibility.Gone) {
|
||||
_needLayout = false;
|
||||
return;
|
||||
}
|
||||
_pos = rc;
|
||||
applyMargins(rc);
|
||||
applyPadding(rc);
|
||||
_layoutItems.layout(rc);
|
||||
_needLayout = false;
|
||||
}
|
||||
/// Draw widget at its position to buffer
|
||||
override void onDraw(DrawBuf buf) {
|
||||
|
@ -329,8 +328,8 @@ class FrameLayout : WidgetGroup {
|
|||
|
||||
/// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
|
||||
override void layout(Rect rc) {
|
||||
_needLayout = false;
|
||||
if (visibility == Visibility.Gone) {
|
||||
_needLayout = false;
|
||||
return;
|
||||
}
|
||||
_pos = rc;
|
||||
|
|
|
@ -323,6 +323,7 @@ class ListWidget : WidgetGroup, OnScrollHandler {
|
|||
|
||||
/// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
|
||||
override void layout(Rect rc) {
|
||||
_needLayout = false;
|
||||
if (visibility == Visibility.Gone) {
|
||||
return;
|
||||
}
|
||||
|
@ -357,8 +358,6 @@ class ListWidget : WidgetGroup, OnScrollHandler {
|
|||
|
||||
// calc item rectangles
|
||||
updateItemPositions();
|
||||
|
||||
_needLayout = false;
|
||||
}
|
||||
|
||||
/// Draw widget at its position to buffer
|
||||
|
|
|
@ -402,6 +402,19 @@ class TabHost : FrameLayout, TabHandler {
|
|||
_tabControl.selectTab(index);
|
||||
}
|
||||
}
|
||||
// /// request relayout of widget and its children
|
||||
// override void requestLayout() {
|
||||
// Log.d("TabHost.requestLayout called");
|
||||
// super.requestLayout();
|
||||
// //_needLayout = true;
|
||||
// }
|
||||
// /// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
|
||||
// override void layout(Rect rc) {
|
||||
// Log.d("TabHost.layout() called");
|
||||
// super.layout(rc);
|
||||
// Log.d("after layout(): needLayout = ", needLayout);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/// compound widget - contains from TabControl widget (tabs header) and TabHost (content pages)
|
||||
|
@ -447,4 +460,10 @@ class TabWidget : VerticalLayout, TabHandler {
|
|||
void selectTab(string ID) {
|
||||
_tabHost.selectTab(ID);
|
||||
}
|
||||
// /// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
|
||||
// override void layout(Rect rc) {
|
||||
// Log.d("TabWidget.layout() called");
|
||||
// super.layout(rc);
|
||||
// Log.d("after layout(): tabhost.needLayout = ", _tabHost.needLayout);
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue