Skip to content

Commit

Permalink
Update minuitwrp graphics in line with latest minui
Browse files Browse the repository at this point in the history
Note: events.cpp is still old code renamed to cpp to make it
easier to call functions like gr_fb_width().

I had to modify AOSP fbdev code to provide a separate memory
surface for drawing to as drawing directly to the framebuffer
resulted in rendering taking about 5 times longer.

I also modified AOSP adf code to provide a separate memory surface
for drawing for the same performance reasons. The Nexus 9 supports
adf graphics.

Overlay graphics work on at least one device. Overlay provides a
separate memory buffer already so performance is good.

I do not have a drm device yet that I know of. I made some attempt
to update the drm code to determine the correct pixel format based
on the drm graphics format, but what is available in pixel flinger
and what is available in drm do not line up all that well. Reports
are that the Pixel C is using drm graphics, but performance is
slow, likely due to the use of a mmap instead of a memory buffyer.

Change-Id: Ibd45bccca6ac2cb826037aa9b2aa5065cf683eed
  • Loading branch information
Dees-Troy committed Jan 27, 2016
1 parent 66a1949 commit fbb4353
Show file tree
Hide file tree
Showing 40 changed files with 2,062 additions and 1,067 deletions.
2 changes: 1 addition & 1 deletion data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ extern "C"
{
#include "twcommon.h"
#include "gui/pages.h"
#include "minuitwrp/minui.h"
void gui_notifyVarChange(const char *name, const char* value);
}
#include "minuitwrp/minui.h"

#define FILE_VERSION 0x00010010

Expand Down
3 changes: 2 additions & 1 deletion gui/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@
#include "../adb_install.h"
#include "../fuse_sideload.h"
#include "blanktimer.hpp"

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "../variables.h"
#include "../twinstall.h"
#include "cutils/properties.h"
#include "../adb_install.h"
#include "../set_metadata.h"
};
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
10 changes: 4 additions & 6 deletions gui/blanktimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ using namespace std;
#include "blanktimer.hpp"
#include "../data.hpp"
extern "C" {
#include "../minuitwrp/minui.h"
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "../twrp-functions.hpp"
#include "../variables.h"

Expand Down Expand Up @@ -71,7 +71,8 @@ void blanktimer::checkForTimeout() {
PageManager::ChangeOverlay("lock");
}
#ifndef TW_NO_SCREEN_BLANK
if (state == kOff && gr_fb_blank(1) >= 0) {
if (state == kOff) {
gr_fb_blank(true);
state = kBlanked;
}
#endif
Expand All @@ -97,10 +98,7 @@ void blanktimer::resetTimerAndUnblank(void) {
switch (state) {
case kBlanked:
#ifndef TW_NO_SCREEN_BLANK
if (gr_fb_blank(0) < 0) {
LOGINFO("blanktimer::resetTimerAndUnblank failed to gr_fb_blank(0)\n");
break;
}
gr_fb_blank(false);
#endif
// TODO: this is asymmetric with postscreenblank.sh - shouldn't it be under the next case label?
TWFunc::check_and_run_script("/sbin/postscreenunblank.sh", "unblank");
Expand Down
2 changes: 1 addition & 1 deletion gui/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/checkbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/fileselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
extern "C"
{
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include <pixelflinger/pixelflinger.h>
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
28 changes: 14 additions & 14 deletions gui/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down Expand Up @@ -196,7 +196,7 @@ int GUIInput::HandleTextLocation(int x)
maskedValue += mMask;
displayValue = maskedValue;
}
textWidth = gr_measureEx(displayValue.c_str(), fontResource);
textWidth = gr_ttf_measureEx(displayValue.c_str(), fontResource);
if (textWidth <= mRenderW) {
lastX = x;
scrollingX = 0;
Expand All @@ -209,7 +209,7 @@ int GUIInput::HandleTextLocation(int x)
if (skipChars && skipChars < displayValue.size())
displayValue.erase(0, skipChars);

textWidth = gr_measureEx(displayValue.c_str(), fontResource);
textWidth = gr_ttf_measureEx(displayValue.c_str(), fontResource);
mRendered = false;

int deltaX, deltaText, newWidth;
Expand All @@ -222,11 +222,11 @@ int GUIInput::HandleTextLocation(int x)
if (mCursorLocation == -1) {
displayValue = originalValue;
skipChars = 0;
textWidth = gr_measureEx(displayValue.c_str(), fontResource);
textWidth = gr_ttf_measureEx(displayValue.c_str(), fontResource);
while (textWidth > mRenderW) {
displayValue.erase(0, 1);
skipChars++;
textWidth = gr_measureEx(displayValue.c_str(), fontResource);
textWidth = gr_ttf_measureEx(displayValue.c_str(), fontResource);
}
scrollingX = mRenderW - textWidth;
mInputText->SkipCharCount(skipChars);
Expand All @@ -237,12 +237,12 @@ int GUIInput::HandleTextLocation(int x)

cursorLocate = displayValue;
cursorLocate.resize(mCursorLocation);
textWidth = gr_measureEx(cursorLocate.c_str(), fontResource);
textWidth = gr_ttf_measureEx(cursorLocate.c_str(), fontResource);
while (textWidth > mRenderW) {
skipChars++;
mCursorLocation--;
cursorLocate.erase(0, 1);
textWidth = gr_measureEx(cursorLocate.c_str(), fontResource);
textWidth = gr_ttf_measureEx(cursorLocate.c_str(), fontResource);
adjust_scrollingX = -1;
}
if (adjust_scrollingX) {
Expand All @@ -261,7 +261,7 @@ int GUIInput::HandleTextLocation(int x)
}
insertChar = originalValue.substr(skipChars - 1, 1);
displayValue.insert(0, insertChar);
newWidth = gr_measureEx(displayValue.c_str(), fontResource);
newWidth = gr_ttf_measureEx(displayValue.c_str(), fontResource);
deltaText = newWidth - textWidth;
if (newWidth > mRenderW) {
scrollingX = mRenderW - textWidth;
Expand Down Expand Up @@ -289,7 +289,7 @@ int GUIInput::HandleTextLocation(int x)
}
insertChar = originalValue.substr(skipChars - 1, 1);
displayValue.insert(0, insertChar);
newWidth = gr_measureEx(displayValue.c_str(), fontResource);
newWidth = gr_ttf_measureEx(displayValue.c_str(), fontResource);
deltaText = newWidth - textWidth;
if (deltaText < deltaX) {
lastX += deltaText;
Expand Down Expand Up @@ -324,7 +324,7 @@ int GUIInput::HandleTextLocation(int x)
deltaX = lastX - x;
displayValue.erase(0, 1);
skipChars++;
newWidth = gr_measureEx(displayValue.c_str(), fontResource);
newWidth = gr_ttf_measureEx(displayValue.c_str(), fontResource);
deltaText = textWidth - newWidth;
if (newWidth <= mRenderW) {
scrollingX = mRenderW - newWidth;
Expand Down Expand Up @@ -407,15 +407,15 @@ int GUIInput::Render(void)

cursorDisplay = displayValue;
cursorDisplay.resize(mCursorLocation);
cursorX = gr_measureEx(cursorDisplay.c_str(), fontResource) + mRenderX;
cursorX = gr_ttf_measureEx(cursorDisplay.c_str(), fontResource) + mRenderX;
} else {
// Cursor location is after the end of the text - reset to -1
mCursorLocation = -1;
cursorX = gr_measureEx(displayValue.c_str(), fontResource) + mRenderX;
cursorX = gr_ttf_measureEx(displayValue.c_str(), fontResource) + mRenderX;
}
} else {
// Cursor is at the end (-1)
cursorX = gr_measureEx(displayValue.c_str(), fontResource) + mRenderX;
cursorX = gr_ttf_measureEx(displayValue.c_str(), fontResource) + mRenderX;
}
}
cursorX += scrollingX;
Expand Down Expand Up @@ -534,7 +534,7 @@ int GUIInput::NotifyTouch(TOUCH_STATE state, int x, int y)
for(index=0; index<displayValue.size(); index++)
{
cursorString = displayValue.substr(0, index);
cursorX = gr_measureEx(cursorString.c_str(), fontResource) + mRenderX;
cursorX = gr_ttf_measureEx(cursorString.c_str(), fontResource) + mRenderX;
if (cursorX > x) {
if (index > 0)
mCursorLocation = index - 1;
Expand Down
6 changes: 3 additions & 3 deletions gui/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "gui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down Expand Up @@ -333,7 +333,7 @@ void GUIKeyboard::DrawKey(Key& key, int keyX, int keyY, int keyW, int keyH)
else if (!labelText.empty())
{
void* fontResource = labelFont->GetResource();
int textW = gr_measureEx(labelText.c_str(), fontResource);
int textW = gr_ttf_measureEx(labelText.c_str(), fontResource);
int textH = labelFont->GetHeight();
int textX = keyX + (keyW - textW) / 2;
int textY = keyY + (keyH - textH) / 2;
Expand All @@ -347,7 +347,7 @@ void GUIKeyboard::DrawKey(Key& key, int keyX, int keyY, int keyW, int keyH)
gr_color(mLongpressFontColor.red, mLongpressFontColor.green, mLongpressFontColor.blue, mLongpressFontColor.alpha);
string text(1, keychar);
int textH = mLongpressFont->GetHeight();
int textW = gr_measureEx(text.c_str(), fontResource);
int textW = gr_ttf_measureEx(text.c_str(), fontResource);
int textX = keyX + keyW - longpressOffsetX - textW;
int textY = keyY + longpressOffsetY;
gr_textEx_scaleW(textX, textY, text.c_str(), fontResource, keyW, TOP_LEFT, 0);
Expand Down
2 changes: 1 addition & 1 deletion gui/listbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/mousecursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/pages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "../minzip/SysUtil.h"
#include "../minzip/Zip.h"
#include "gui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/partitionlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/patternpassword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/progressbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include "../minzip/Zip.h"
extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "gui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/resources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FontResource : public Resource

public:
void* GetResource() { return this ? mFont : NULL; }
int GetHeight() { return gr_getMaxFontHeight(this ? mFont : NULL); }
int GetHeight() { return gr_ttf_getMaxFontHeight(this ? mFont : NULL); }
void Override(xml_node<>* node, ZipArchive* pZip);

protected:
Expand Down
2 changes: 1 addition & 1 deletion gui/scrolllist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
2 changes: 1 addition & 1 deletion gui/slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

extern "C" {
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
}
#include "../minuitwrp/minui.h"

#include "rapidxml.hpp"
#include "objects.hpp"
Expand Down
Loading

0 comments on commit fbb4353

Please sign in to comment.