Skip to content

Commit 38c7880

Browse files
committed
Squashed commit of:
Refactor ImageView drawing to remove checker background from render - Set default for "bg" parameter in Image::Render to false so it doesn't draw the checker bg - Remove code to render the checker bg in Image::DoRenderPreview - In ImageView add checker bg bitmap. it is the size of two checker squares and is drawn as a tiled bitmap first thing in the ImageView::Draw function. the bitmap is drawn in the ImageView::MakeBackground() function and this is also called when the settings change to redraw the background bitmap - in ImageView::Draw the background is drawn first and the brush drawing was also moved here. this is because in Haiku drawing should happen only in the Draw() function so other Draw commands were removed unless in functions called by Draw(). - ImageView::BlitImage() uses alpha drawing mode to draw the changed bitmap parts - ImageView::UpdateImage() uses Invalidate() to force redraw but doesn't use BlitImage() anymore - ImageView::MouseDown() invalidates window region when scrolling view to force redraw - ImageView::MouseUp() code is not needed because DrawBrush happens in Draw() - ImageView::MouseMoved() invalidates area where brush is drawn but doesn't draw brush because it happens in Draw() function. Also the Draw() when the mouse leaves the view is changed to Invalidate() - ImageView::DrawBrush() clear code is not needed because Draw erases the bg before calling DrawBrush. Also calls to Draw are replaced by Invalidate() - A few tools (FreeLineTool, EraserTool, HairyBrushTool) make sure updated_rect is within the image bounds to prevent crashes Refactor Color Selector tool to stop drawing directly to ImageView - Removed drawing / erasing code from ColorSelectorTool::UseTool - in ImageView::DrawBrush draw rect for color selection Refactor SelectorTool to not draw directly to ImageView - add SelectorTool to ImageView::DrawBrush so selection draws during Draw() function - in SelectorTool store the points for a selection in progress. "selectionPoints" is for drawing selections like rectangle or ellipse. "activePoints" is needed for intelligent scissors because there is the part currenyly being drawn and then "selectionPoints" is for the part that the user drew before clicking the mouse. - add SelectorTool::DrawSelection function to draw in progress selections based on points stored in SelectorTool::UseTool - removed drawing code from SelectorTool::UseTool. store points for selections. use ImageUpdater like other drawing tools to update the image instead of drawing directly to the view
1 parent b747948 commit 38c7880

12 files changed

Lines changed: 321 additions & 210 deletions

File tree

artpaint/paintwindow/Image.cpp

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,28 +1490,11 @@ Image::DoRenderPreview(BRect area, int32 resolution)
14901490
int32 right = (int32)area.right;
14911491
int32 bottom = (int32)area.bottom;
14921492

1493-
int32 gridSize;
1494-
uint32 color1;
1495-
uint32 color2;
1496-
1497-
gridSize = 20;
1498-
rgb_color rgb1, rgb2;
1499-
rgb1.red = rgb1.green = rgb1.blue = 0xBB;
1500-
rgb2.red = rgb2.green = rgb2.blue = 0x99;
1501-
rgb1.alpha = rgb2.alpha = 0xFF;
1502-
color1 = RGBColorToBGRA(rgb1);
1503-
color2 = RGBColorToBGRA(rgb2);
1493+
union color_conversion white_bg;
1494+
white_bg.word = 0xFFFFFFFF;
1495+
white_bg.bytes[3] = 0x00;
15041496

1505-
if (SettingsServer* server = SettingsServer::Instance()) {
1506-
BMessage settings;
1507-
server->GetApplicationSettings(&settings);
1508-
1509-
gridSize = settings.GetInt32(skBgGridSize, gridSize);
1510-
color1 = settings.GetUInt32(skBgColor1, color1);
1511-
color2 = settings.GetUInt32(skBgColor2, color2);
1512-
}
1513-
1514-
BitmapUtilities::CheckerBitmap(rendered_image, color1, color2, gridSize, &area);
1497+
BitmapUtilities::ClearBitmap(rendered_image, white_bg.word, &area);
15151498

15161499
for (int32 y = top; y <= bottom; y += resolution) {
15171500
for (int32 x = left; x <= right; x += resolution) {

artpaint/paintwindow/Image.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ class Image {
9292
Image(ImageView*, float, float, UndoQueue*);
9393
~Image();
9494

95-
void Render(bool bg = true);
96-
void Render(BRect, bool bg = true);
95+
void Render(bool bg = false);
96+
void Render(BRect, bool bg = false);
9797
void RenderPreview(BRect, int32);
9898
void RenderPreview(BRegion&, int32);
9999
void MultiplyRenderedImagePixels(int32);

0 commit comments

Comments
 (0)