ActivityMonitor: remove double buffering and custom background drawing
Part of #15623. Change-Id: Id6b7c13623e66d5b88ffc48766a5fe5ec4099b64 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2133 Reviewed-by: Stephan Aßmus <[email protected]>
This commit is contained in:
@@ -553,7 +553,7 @@ const float kDraggerSize = 7;
|
|||||||
ActivityView::ActivityView(BRect frame, const char* name,
|
ActivityView::ActivityView(BRect frame, const char* name,
|
||||||
const BMessage* settings, uint32 resizingMode)
|
const BMessage* settings, uint32 resizingMode)
|
||||||
: BView(frame, name, resizingMode,
|
: BView(frame, name, resizingMode,
|
||||||
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS),
|
B_WILL_DRAW | B_SUBPIXEL_PRECISE | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS),
|
||||||
fSourcesLock("data sources")
|
fSourcesLock("data sources")
|
||||||
{
|
{
|
||||||
_Init(settings);
|
_Init(settings);
|
||||||
@@ -598,7 +598,6 @@ ActivityView::ActivityView(BMessage* archive)
|
|||||||
|
|
||||||
ActivityView::~ActivityView()
|
ActivityView::~ActivityView()
|
||||||
{
|
{
|
||||||
delete fOffscreen;
|
|
||||||
delete fSystemInfoHandler;
|
delete fSystemInfoHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,7 +608,6 @@ ActivityView::_Init(const BMessage* settings)
|
|||||||
fHistoryBackgroundColor = (rgb_color){255, 255, 240};
|
fHistoryBackgroundColor = (rgb_color){255, 255, 240};
|
||||||
fLegendBackgroundColor = LowColor();
|
fLegendBackgroundColor = LowColor();
|
||||||
// the low color is restored by the BView unarchiving
|
// the low color is restored by the BView unarchiving
|
||||||
fOffscreen = NULL;
|
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
fHistoryLayoutItem = NULL;
|
fHistoryLayoutItem = NULL;
|
||||||
fLegendLayoutItem = NULL;
|
fLegendLayoutItem = NULL;
|
||||||
@@ -925,51 +923,6 @@ ActivityView::MinSize()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ActivityView::FrameResized(float /*width*/, float /*height*/)
|
|
||||||
{
|
|
||||||
_UpdateOffscreenBitmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ActivityView::_UpdateOffscreenBitmap()
|
|
||||||
{
|
|
||||||
BRect frame = _HistoryFrame();
|
|
||||||
frame.OffsetTo(B_ORIGIN);
|
|
||||||
|
|
||||||
if (fOffscreen != NULL && frame == fOffscreen->Bounds())
|
|
||||||
return;
|
|
||||||
|
|
||||||
delete fOffscreen;
|
|
||||||
|
|
||||||
// create offscreen bitmap
|
|
||||||
|
|
||||||
fOffscreen = new(std::nothrow) BBitmap(frame, B_BITMAP_ACCEPTS_VIEWS,
|
|
||||||
B_RGB32);
|
|
||||||
if (fOffscreen == NULL || fOffscreen->InitCheck() != B_OK) {
|
|
||||||
delete fOffscreen;
|
|
||||||
fOffscreen = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BView* view = new BView(frame, NULL, B_FOLLOW_NONE, B_SUBPIXEL_PRECISE);
|
|
||||||
view->SetViewColor(fHistoryBackgroundColor);
|
|
||||||
view->SetLowColor(view->ViewColor());
|
|
||||||
fOffscreen->AddChild(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BView*
|
|
||||||
ActivityView::_OffscreenView()
|
|
||||||
{
|
|
||||||
if (fOffscreen == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return fOffscreen->ChildAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ActivityView::MouseDown(BPoint where)
|
ActivityView::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
@@ -1323,23 +1276,15 @@ ActivityView::_PositionForValue(DataSource* source, DataHistory* values,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ActivityView::_DrawHistory(bool drawBackground)
|
ActivityView::_DrawHistory()
|
||||||
{
|
{
|
||||||
_UpdateOffscreenBitmap();
|
|
||||||
|
|
||||||
BView* view = this;
|
BView* view = this;
|
||||||
if (fOffscreen != NULL) {
|
|
||||||
fOffscreen->Lock();
|
|
||||||
view = _OffscreenView();
|
|
||||||
}
|
|
||||||
|
|
||||||
BRect frame = _HistoryFrame();
|
BRect frame = _HistoryFrame();
|
||||||
BRect outerFrame = frame.InsetByCopy(-2, -2);
|
BRect outerFrame = frame.InsetByCopy(-2, -2);
|
||||||
|
|
||||||
// draw the outer frame
|
// draw the outer frame
|
||||||
uint32 flags = 0;
|
uint32 flags = BControlLook::B_BLEND_FRAME;
|
||||||
if (!drawBackground)
|
|
||||||
flags |= BControlLook::B_BLEND_FRAME;
|
|
||||||
be_control_look->DrawTextControlBorder(this, outerFrame,
|
be_control_look->DrawTextControlBorder(this, outerFrame,
|
||||||
outerFrame, fLegendBackgroundColor, flags);
|
outerFrame, fLegendBackgroundColor, flags);
|
||||||
|
|
||||||
@@ -1432,12 +1377,9 @@ ActivityView::_DrawHistory(bool drawBackground)
|
|||||||
view->EndLineArray();
|
view->EndLineArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view->SetPenSize(1);
|
||||||
|
|
||||||
// TODO: add marks when an app started or quit
|
// TODO: add marks when an app started or quit
|
||||||
view->Sync();
|
|
||||||
if (fOffscreen != NULL) {
|
|
||||||
fOffscreen->Unlock();
|
|
||||||
DrawBitmap(fOffscreen, outerFrame.LeftTop());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1467,11 +1409,7 @@ ActivityView::_UpdateResolution(int32 resolution, bool broadcast)
|
|||||||
void
|
void
|
||||||
ActivityView::Draw(BRect updateRect)
|
ActivityView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
bool drawBackground = true;
|
_DrawHistory();
|
||||||
if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0)
|
|
||||||
drawBackground = false;
|
|
||||||
|
|
||||||
_DrawHistory(drawBackground);
|
|
||||||
|
|
||||||
if (!fShowLegend)
|
if (!fShowLegend)
|
||||||
return;
|
return;
|
||||||
@@ -1481,12 +1419,6 @@ ActivityView::Draw(BRect updateRect)
|
|||||||
if (LowUIColor() == B_NO_COLOR)
|
if (LowUIColor() == B_NO_COLOR)
|
||||||
SetLowColor(fLegendBackgroundColor);
|
SetLowColor(fLegendBackgroundColor);
|
||||||
|
|
||||||
if (drawBackground) {
|
|
||||||
BRect backgroundFrame(legendFrame);
|
|
||||||
backgroundFrame.bottom += kDraggerSize;
|
|
||||||
FillRect(backgroundFrame, B_SOLID_LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
BAutolock _(fSourcesLock);
|
BAutolock _(fSourcesLock);
|
||||||
|
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
@@ -1520,9 +1452,6 @@ ActivityView::Draw(BRect updateRect)
|
|||||||
label = source->ShortLabel();
|
label = source->ShortLabel();
|
||||||
TruncateString(&label, B_TRUNCATE_MIDDLE, possibleLabelWidth);
|
TruncateString(&label, B_TRUNCATE_MIDDLE, possibleLabelWidth);
|
||||||
|
|
||||||
if (drawBackground)
|
|
||||||
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
|
||||||
|
|
||||||
if (be_control_look == NULL) {
|
if (be_control_look == NULL) {
|
||||||
DrawString(label.String(), BPoint(6 + colorBox.right, y));
|
DrawString(label.String(), BPoint(6 + colorBox.right, y));
|
||||||
DrawString(text.String(), BPoint(frame.right - width, y));
|
DrawString(text.String(), BPoint(frame.right - width, y));
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ protected:
|
|||||||
virtual BSize MinSize();
|
virtual BSize MinSize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void FrameResized(float width, float height);
|
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
@@ -101,8 +100,6 @@ private:
|
|||||||
::Scale* _ScaleFor(scale_type type);
|
::Scale* _ScaleFor(scale_type type);
|
||||||
void _Refresh();
|
void _Refresh();
|
||||||
static status_t _RefreshThread(void* self);
|
static status_t _RefreshThread(void* self);
|
||||||
void _UpdateOffscreenBitmap();
|
|
||||||
BView* _OffscreenView();
|
|
||||||
void _UpdateFrame();
|
void _UpdateFrame();
|
||||||
BRect _HistoryFrame() const;
|
BRect _HistoryFrame() const;
|
||||||
float _LegendHeight() const;
|
float _LegendHeight() const;
|
||||||
@@ -111,7 +108,7 @@ private:
|
|||||||
BRect _LegendColorFrameAt(BRect frame, int32 index) const;
|
BRect _LegendColorFrameAt(BRect frame, int32 index) const;
|
||||||
float _PositionForValue(DataSource* source,
|
float _PositionForValue(DataSource* source,
|
||||||
DataHistory* values, int64 value);
|
DataHistory* values, int64 value);
|
||||||
void _DrawHistory(bool drawBackground);
|
void _DrawHistory();
|
||||||
void _UpdateResolution(int32 resolution,
|
void _UpdateResolution(int32 resolution,
|
||||||
bool broadcast = true);
|
bool broadcast = true);
|
||||||
|
|
||||||
@@ -124,7 +121,6 @@ private:
|
|||||||
|
|
||||||
rgb_color fHistoryBackgroundColor;
|
rgb_color fHistoryBackgroundColor;
|
||||||
rgb_color fLegendBackgroundColor;
|
rgb_color fLegendBackgroundColor;
|
||||||
BBitmap* fOffscreen;
|
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
BLayoutItem* fHistoryLayoutItem;
|
BLayoutItem* fHistoryLayoutItem;
|
||||||
BLayoutItem* fLegendLayoutItem;
|
BLayoutItem* fLegendLayoutItem;
|
||||||
|
|||||||
Reference in New Issue
Block a user