graphics optimization feature inspirated by diablo3 engine

* the rendering now consits of two panes
- the background pane (for animated stuff like the map)
- the foreground pane (for steady stuff, like UI)
each pane has it own max FPS and works idependently
this may increase graphics performance on many platforms
This commit is contained in:
Eduardo Bart
2012-06-01 16:39:09 -03:00
parent c01b32b032
commit bd2faabe99
43 changed files with 461 additions and 138 deletions

View File

@@ -13,20 +13,60 @@ Panel
!text: tr('Fullscreen')
Label
!text: tr('Frame rate limit')
id: backgroundFrameRateLimitLabel
!text: tr('Background pane framerate limit: %s', 'max')
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 6
HorizontalScrollBar
id: frameRateScrollBar
id: backgroundFrameRateScrollBar
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 3
minimum: 0
maximum: 50
value: 0
minimum: 10
maximum: 201
value: 201
step: 1
@onValueChange: g_app.setFrameSleep(self:getValue())
@onValueChange: |
local value = self:getValue()
local text = value
if value == self:getMaximum() then
text = 'max'
value = 0
end
self:getParent():getChildById('backgroundFrameRateLimitLabel'):setText(tr('Background pane framerate limit: %s', text))
g_app.setBackgroundPaneMaxFps(value)
Label
id: foregroundFrameRateLimitLabel
!text: tr('Foreground pane framerate limit: %s', '8')
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 6
HorizontalScrollBar
id: foregroundFrameRateScrollBar
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 3
minimum: 1
maximum: 61
value: 8
step: 1
@onValueChange: |
local value = self:getValue()
local text = value
if value == self:getMaximum() then
text = 'max'
value = 0
end
self:getParent():getChildById('foregroundFrameRateLimitLabel'):setText(tr('Foreground pane framerate limit: %s', text))
g_app.setForegroundPaneMaxFps(value)

View File

@@ -69,9 +69,19 @@ TopPanel
anchors.bottom: parent.bottom
anchors.right: parent.right
FrameCounter
UILabel
size: 68 16
text-align: right
color: white
id: frameCounter
anchors.top: parent.top
anchors.right: prev.left
margin-top: 8
margin-right: 5
@onSetup: |
local updateFunc
updateFunc = function()
self:setText('FPS: ' .. g_app.getBackgroundPaneFps())
scheduleEvent(updateFunc, 250)
end
updateFunc()

View File

@@ -6,7 +6,7 @@ local currentHoveredWidget
-- private functions
local function moveToolTip(tooltip)
if not tooltip:isVisible() then return end
if not tooltip:isVisible() or tooltip:getOpacity() < 0.1 then return end
local pos = g_window.getMousePosition()
pos.y = pos.y + 1
@@ -49,6 +49,7 @@ function ToolTip.init()
toolTipLabel:setId('toolTip')
toolTipLabel:setBackgroundColor('#111111cc')
toolTipLabel:setTextAlign(AlignCenter)
toolTipLabel:hide()
toolTipLabel.onMouseMove = moveToolTip
end)
end

View File

@@ -89,8 +89,8 @@ function UIScrollBar.create()
local scrollbar = UIScrollBar.internalCreate()
scrollbar:setFocusable(false)
scrollbar.value = 0
scrollbar.minimum = 0
scrollbar.maximum = 0
scrollbar.minimum = -999999
scrollbar.maximum = 999999
scrollbar.step = 1
scrollbar.orientation = 'vertical'
scrollbar.pixelsScroll = false
@@ -98,6 +98,8 @@ function UIScrollBar.create()
end
function UIScrollBar:onSetup()
self.setupDone = true
signalcall(self.onValueChange, self, self.value)
addEvent(function()
Mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end)
Mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() end)
@@ -163,7 +165,9 @@ function UIScrollBar:setValue(value)
local delta = value - self.value
self.value = value
updateSlider(self)
signalcall(self.onValueChange, self, value, delta)
if self.setupDone then
signalcall(self.onValueChange, self, value, delta)
end
end
function UIScrollBar:setStep(step)

View File

@@ -20,7 +20,3 @@ FlatLabel < UILabel
GameLabel < UILabel
font: verdana-11px-antialised
color: #bbbbbb
FrameCounter < UIFrameCounter
size: 68 16
align: right