[prev in list] [next in list] [prev in thread] [next in thread]
List: haiku-commits
Subject: [haiku-commits] haiku: hrev53916 - src/apps/fontdemo
From: waddlesplash <waddlesplash () gmail ! com>
Date: 2020-02-25 4:50:01
Message-ID: 20200225045001.A8A532416B () turing ! freelists ! org
[Download RAW message or body]
hrev53916 adds 1 changeset to branch 'master'
old head: 371b3b2b42188baf7b34be16f0891595014f5ef2
new head: 48de299d5436f3989377719ed6dbeaf167935fa5
overview: https://git.haiku-os.org/haiku/log/?qt=range&q=48de299d5436+%5E371b3b2b4218
----------------------------------------------------------------------------
48de299d5436: FontDemo: remove flickering workarounds
Part of #15623.
Change-Id: Iddd1bff519fac8f5387ba1eeec22cc2314112271
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2276
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
[ X512 <danger_mail@list.ru> ]
----------------------------------------------------------------------------
Revision: hrev53916
Commit: 48de299d5436f3989377719ed6dbeaf167935fa5
URL: https://git.haiku-os.org/haiku/commit/?id=48de299d5436
Author: X512 <danger_mail@list.ru>
Date: Mon Feb 24 19:53:27 2020 UTC
Committer: waddlesplash <waddlesplash@gmail.com>
Commit-Date: Tue Feb 25 04:49:58 2020 UTC
Ticket: https://dev.haiku-os.org/ticket/15623
----------------------------------------------------------------------------
2 files changed, 18 insertions(+), 79 deletions(-)
src/apps/fontdemo/FontDemoView.cpp | 90 +++++++---------------------------
src/apps/fontdemo/FontDemoView.h | 7 ---
----------------------------------------------------------------------------
diff --git a/src/apps/fontdemo/FontDemoView.cpp b/src/apps/fontdemo/FontDemoView.cpp
index ec1ab5498f..67416a0f42 100644
--- a/src/apps/fontdemo/FontDemoView.cpp
+++ b/src/apps/fontdemo/FontDemoView.cpp
@@ -29,8 +29,6 @@
FontDemoView::FontDemoView(BRect rect)
: BView(rect, "FontDemoView", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS),
- fBitmap(NULL),
- fBufferView(NULL),
fFontSize(50.0),
fSpacing(0.0),
fOutLineLevel(0),
@@ -39,22 +37,16 @@ FontDemoView::FontDemoView(BRect rect)
fDrawShapes(false),
fShapes(NULL)
{
- SetViewColor(B_TRANSPARENT_COLOR);
BString setStr = B_TRANSLATE("Haiku, Inc.");
SetString(setStr);
SetFontSize(fFontSize);
SetAntialiasing(true);
-
- _NewBitmap(Bounds());
}
FontDemoView::~FontDemoView()
{
free(fShapes);
-
- fBitmap->Lock();
- delete fBitmap;
}
@@ -71,33 +63,15 @@ FontDemoView::FrameResized(float width, float height)
void
FontDemoView::Draw(BRect updateRect)
{
- BRect rect = Bounds();
- fBufferView = _GetView(rect);
- _DrawView(fBufferView);
+ SetDrawingMode(B_OP_COPY);
- fBufferView->Sync();
- DrawBitmap(fBitmap, rect);
- fBitmap->Unlock();
-}
-
-
-void
-FontDemoView::_DrawView(BView* view)
-{
- if (!view)
- return;
-
- view->SetDrawingMode(B_OP_COPY);
-
-
- BRect rect = view->Bounds();
- view->SetHighColor(255, 255, 255);
- view->FillRect(rect);
+ BRect rect = Bounds();
+ SetHighColor(255, 255, 255);
if (!fString)
return;
- view->SetFont(&fFont, B_FONT_ALL);
+ SetFont(&fFont, B_FONT_ALL);
const size_t size = fString.CountChars();
BStackOrHeapArray<BRect, 64> boundBoxes(size);
@@ -136,7 +110,7 @@ FontDemoView::_DrawView(BView* view)
// region area instead of the whole view.
fBoxRegion.MakeEmpty();
-
+
for (size_t i = 0; i < size; i++) {
xCoordArray[i] = 0.0f;
yCoordArray[i] = 0.0f;
@@ -150,28 +124,28 @@ FontDemoView::_DrawView(BView* view)
boundBoxes[i].OffsetBy(xCoordArray[i], yCoordArray[i]);
if (OutLineLevel()) {
- view->MovePenTo(xCoordArray[i], yCoordArray[i]);
- view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
- view->FillShape(fShapes[i]);
- view->SetPenSize(OutLineLevel());
- view->SetHighColor(0, 0, 0);
- view->StrokeShape(fShapes[i]);
+ MovePenTo(xCoordArray[i], yCoordArray[i]);
+ SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ FillShape(fShapes[i]);
+ SetPenSize(OutLineLevel());
+ SetHighColor(0, 0, 0);
+ StrokeShape(fShapes[i]);
} else {
- view->SetHighColor(0, 0, 0);
- view->SetDrawingMode(fDrawingMode);
+ SetHighColor(0, 0, 0);
+ SetDrawingMode(fDrawingMode);
int32 charLength;
const char* charAt = fString.CharAt(i, &charLength);
- view->DrawString(charAt, charLength,
+ DrawString(charAt, charLength,
BPoint(xCoordArray[i], yCoordArray[i]));
}
if (BoundingBoxes() && !OutLineLevel()) {
if (i % 2)
- view->SetHighColor(0, 255, 0);
+ SetHighColor(0, 255, 0);
else
- view->SetHighColor(255, 0, 0);
- view->SetDrawingMode(B_OP_COPY);
- view->StrokeRect(boundBoxes[i]);
+ SetHighColor(255, 0, 0);
+ SetDrawingMode(B_OP_COPY);
+ StrokeRect(boundBoxes[i]);
}
// add the bounding to the region.
@@ -430,31 +404,3 @@ FontDemoView::_AddShapes(BString string)
fShapes[i] = new BShape();
}
}
-
-
-BView*
-FontDemoView::_GetView(BRect rect)
-{
- if (!fBitmap || fBitmap->Bounds() != rect)
- _NewBitmap(rect);
-
- fBitmap->Lock();
- return fBitmap->ChildAt(0);
-}
-
-
-void
-FontDemoView::_NewBitmap(BRect rect)
-{
- delete fBitmap;
- fBitmap = new BBitmap(rect, B_RGB16, true);
-
- if (fBitmap->Lock()) {
- BView* view = new BView(rect, "", B_FOLLOW_NONE, B_WILL_DRAW);
- fBitmap->AddChild(view);
- fBitmap->Unlock();
- } else {
- delete fBitmap;
- fBitmap = NULL;
- }
-}
diff --git a/src/apps/fontdemo/FontDemoView.h b/src/apps/fontdemo/FontDemoView.h
index 23b1395eff..a638043539 100644
--- a/src/apps/fontdemo/FontDemoView.h
+++ b/src/apps/fontdemo/FontDemoView.h
@@ -51,13 +51,6 @@ class FontDemoView : public BView {
private:
void _AddShapes(BString string);
- void _DrawView(BView* view);
-
- BView* _GetView(BRect rect);
- void _NewBitmap(BRect rect);
-
- BBitmap* fBitmap;
- BView* fBufferView;
BString fString;
float fFontSize;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic