[Haiku-commits] r31177 - in haiku/trunk/src/servers/app: . drawing/Painter
axeld at BerliOS
axeld at mail.berlios.de
Mon Jun 22 12:30:37 CEST 2009
Author: axeld
Date: 2009-06-22 12:30:36 +0200 (Mon, 22 Jun 2009)
New Revision: 31177
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31177&view=rev
Modified:
haiku/trunk/src/servers/app/AppServer.cpp
haiku/trunk/src/servers/app/drawing/Painter/Jamfile
haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp
Log:
* This should fix the app_server build under other architectures than x86.
* Fixed wrong operator precedence case in Painter::SetFont().
* Fixed dozens of style violations.
Modified: haiku/trunk/src/servers/app/AppServer.cpp
===================================================================
--- haiku/trunk/src/servers/app/AppServer.cpp 2009-06-22 09:04:02 UTC (rev 31176)
+++ haiku/trunk/src/servers/app/AppServer.cpp 2009-06-22 10:30:36 UTC (rev 31177)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001-2007, Haiku, Inc.
+ * Copyright (c) 2001-2009, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
@@ -39,11 +39,13 @@
uint32 gAppServerSIMDFlags = 0;
-/*! Detect SIMD flags for use in AppServer. Checks all CPUs in the system
- and chooses the minimum supported set of instructions. */
+/*! Detect SIMD flags for use in AppServer. Checks all CPUs in the system
+ and chooses the minimum supported set of instructions.
+*/
static void
detect_simd()
{
+#if __INTEL__
// Only scan CPUs for which we are certain the SIMD flags are properly
// defined.
char* vendorNames[] = {
@@ -56,15 +58,15 @@
0
};
- system_info sysInfo;
- if (get_system_info(&sysInfo) != B_OK || sysInfo.cpu_count < 1)
+ system_info systemInfo;
+ if (get_system_info(&systemInfo) != B_OK)
return;
// We start out with all flags set and end up with only those flags
// supported across all CPUs found.
uint32 appServerSIMD = 0xffffffff;
- for (int32 cpu = 0; cpu < sysInfo.cpu_count; cpu++) {
+ for (int32 cpu = 0; cpu < systemInfo.cpu_count; cpu++) {
cpuid_info cpuInfo;
get_cpuid(&cpuInfo, 0, cpu);
@@ -95,9 +97,13 @@
appServerSIMD &= cpuSIMD;
}
gAppServerSIMDFlags = appServerSIMD;
+#endif // __INTEL__
}
+// #pragma mark -
+
+
/*!
\brief Constructor
@@ -138,13 +144,10 @@
// Initialize SIMD flags
detect_simd();
-#if 0
- _LaunchCursorThread();
-#endif
}
-/*!
- \brief Destructor
+
+/*! \brief Destructor
Reached only when the server is asked to shut down in Test mode.
*/
AppServer::~AppServer()
@@ -161,9 +164,6 @@
}
-/*!
- \brief The call that starts it all...
-*/
void
AppServer::RunLooper()
{
@@ -172,8 +172,7 @@
}
-/*!
- \brief Creates a desktop object for an authorized user
+/*! \brief Creates a desktop object for an authorized user
*/
Desktop *
AppServer::_CreateDesktop(uid_t userID)
@@ -205,8 +204,7 @@
}
-/*!
- \brief Finds the desktop object that belongs to a certain user
+/*! \brief Finds the desktop object that belongs to a certain user
*/
Desktop *
AppServer::_FindDesktop(uid_t userID)
@@ -224,8 +222,7 @@
}
-/*!
- \brief Message handling function for all messages sent to the app_server
+/*! \brief Message handling function for all messages sent to the app_server
\param code ID of the message sent
\param buffer Attachment buffer for the message.
Modified: haiku/trunk/src/servers/app/drawing/Painter/Jamfile
===================================================================
--- haiku/trunk/src/servers/app/drawing/Painter/Jamfile 2009-06-22 09:04:02 UTC (rev 31176)
+++ haiku/trunk/src/servers/app/drawing/Painter/Jamfile 2009-06-22 10:30:36 UTC (rev 31177)
@@ -12,6 +12,11 @@
SEARCH_SOURCE += [ FDirName $(SUBDIR) drawing_modes ] ;
+local PAINTER_ARCH_SOURCES ;
+if $(TARGET_ARCH) = x86 {
+ PAINTER_ARCH_SOURCES = painter_bilinear_scale.nasm ;
+}
+
StaticLibrary libpainter.a :
GlobalSubpixelSettings.cpp
Painter.cpp
@@ -22,5 +27,5 @@
AGGTextRenderer.cpp
- painter_bilinear_scale.nasm
+ $(PAINTER_ARCH_SOURCES)
;
Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp
===================================================================
--- haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2009-06-22 09:04:02 UTC (rev 31176)
+++ haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2009-06-22 10:30:36 UTC (rev 31177)
@@ -5,10 +5,14 @@
* All rights reserved. Distributed under the terms of the MIT License.
*/
-/*! API to the Anti-Grain Geometry based "Painter" drawing backend. Manages
- rendering pipe-lines for stroke, fills, bitmap and text rendering.*/
+/*! API to the Anti-Grain Geometry based "Painter" drawing backend. Manages
+ rendering pipe-lines for stroke, fills, bitmap and text rendering.
+*/
+#include "Painter.h"
+
#include <new>
+
#include <stdio.h>
#include <string.h>
@@ -53,8 +57,6 @@
#include "ServerFont.h"
#include "SystemPalette.h"
-#include "Painter.h"
-
#include "AppServer.h"
using std::nothrow;
@@ -125,13 +127,16 @@
#endif
}
+
// destructor
Painter::~Painter()
{
}
+
// #pragma mark -
+
// AttachToBuffer
void
Painter::AttachToBuffer(RenderingBuffer* buffer)
@@ -158,6 +163,7 @@
}
}
+
// DetachFromBuffer
void
Painter::DetachFromBuffer()
@@ -167,6 +173,7 @@
fValidClipping = false;
}
+
// Bounds
BRect
Painter::Bounds() const
@@ -174,8 +181,10 @@
return BRect(0, 0, fBuffer.width() - 1, fBuffer.height() - 1);
}
+
// #pragma mark -
+
// SetDrawState
void
Painter::SetDrawState(const DrawState* data, int32 xOffset, int32 yOffset)
@@ -222,8 +231,10 @@
_UpdateDrawingMode();
}
+
// #pragma mark - state
+
// ConstrainClipping
void
Painter::ConstrainClipping(const BRegion* region)
@@ -239,6 +250,7 @@
}
}
+
// SetHighColor
void
Painter::SetHighColor(const rgb_color& color)
@@ -250,6 +262,7 @@
_SetRendererColor(color);
}
+
// SetLowColor
void
Painter::SetLowColor(const rgb_color& color)
@@ -259,6 +272,7 @@
_SetRendererColor(color);
}
+
// SetDrawingMode
void
Painter::SetDrawingMode(drawing_mode mode)
@@ -282,6 +296,7 @@
}
}
+
// SetPenSize
void
Painter::SetPenSize(float size)
@@ -289,6 +304,7 @@
fPenSize = size;
}
+
// SetStrokeMode
void
Painter::SetStrokeMode(cap_mode lineCap, join_mode joinMode, float miterLimit)
@@ -298,6 +314,7 @@
fMiterLimit = miterLimit;
}
+
// SetPattern
void
Painter::SetPattern(const pattern& p, bool drawingText)
@@ -318,26 +335,29 @@
}
}
+
// SetFont
void
Painter::SetFont(const ServerFont& font)
{
fTextRenderer.SetFont(font);
- fTextRenderer.SetAntialiasing(
- !(font.Flags() & B_DISABLE_ANTIALIASING));
+ fTextRenderer.SetAntialiasing(!(font.Flags() & B_DISABLE_ANTIALIASING));
}
+
// SetFont
void
Painter::SetFont(const DrawState* state)
{
fTextRenderer.SetFont(state->Font());
- fTextRenderer.SetAntialiasing(!(state->ForceFontAliasing()
- || state->Font().Flags() & B_DISABLE_ANTIALIASING));
+ fTextRenderer.SetAntialiasing(!state->ForceFontAliasing()
+ && (state->Font().Flags() & B_DISABLE_ANTIALIASING) != 0);
}
+
// #pragma mark - drawing
+
// StrokeLine
void
Painter::StrokeLine(BPoint a, BPoint b)
@@ -352,7 +372,6 @@
// first, try an optimized version
if (fPenSize == 1.0
&& (fDrawingMode == B_OP_COPY || fDrawingMode == B_OP_OVER)) {
-
pattern pat = *fPatternHandler.GetR5Pattern();
if (pat == B_SOLID_HIGH
&& StraightLine(a, b, fPatternHandler.HighColor())) {
@@ -429,6 +448,7 @@
}
}
+
// StraightLine
bool
Painter::StraightLine(BPoint a, BPoint b, const rgb_color& c) const
@@ -500,8 +520,10 @@
return false;
}
+
// #pragma mark -
+
// StrokeTriangle
BRect
Painter::StrokeTriangle(BPoint pt1, BPoint pt2, BPoint pt3) const
@@ -509,6 +531,7 @@
return _DrawTriangle(pt1, pt2, pt3, false);
}
+
// FillTriangle
BRect
Painter::FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3) const
@@ -516,6 +539,7 @@
return _DrawTriangle(pt1, pt2, pt3, true);
}
+
// FillTriangle
BRect
Painter::FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3,
@@ -538,15 +562,14 @@
return _FillPath(fPath, gradient);
}
+
// DrawPolygon
BRect
-Painter::DrawPolygon(BPoint* p, int32 numPts,
- bool filled, bool closed) const
+Painter::DrawPolygon(BPoint* p, int32 numPts, bool filled, bool closed) const
{
CHECK_CLIPPING
if (numPts > 0) {
-
fPath.remove_all();
_Transform(p);
@@ -563,21 +586,21 @@
if (filled)
return _FillPath(fPath);
- else
- return _StrokePath(fPath);
+
+ return _StrokePath(fPath);
}
return BRect(0.0, 0.0, -1.0, -1.0);
}
+
// FillPolygon
BRect
-Painter::FillPolygon(BPoint* p, int32 numPts,
- const BGradient& gradient, bool closed) const
+Painter::FillPolygon(BPoint* p, int32 numPts, const BGradient& gradient,
+ bool closed) const
{
CHECK_CLIPPING
if (numPts > 0) {
-
fPath.remove_all();
_Transform(p);
@@ -597,6 +620,7 @@
return BRect(0.0, 0.0, -1.0, -1.0);
}
+
// DrawBezier
BRect
Painter::DrawBezier(BPoint* p, bool filled) const
@@ -611,19 +635,17 @@
_Transform(&(p[3]));
fPath.move_to(p[0].x, p[0].y);
- fPath.curve4(p[1].x, p[1].y,
- p[2].x, p[2].y,
- p[3].x, p[3].y);
+ fPath.curve4(p[1].x, p[1].y, p[2].x, p[2].y, p[3].x, p[3].y);
-
if (filled) {
fPath.close_polygon();
return _FillPath(fCurve);
- } else {
- return _StrokePath(fCurve);
}
+
+ return _StrokePath(fCurve);
}
+
// FillBezier
BRect
Painter::FillBezier(BPoint* p, const BGradient& gradient) const
@@ -638,11 +660,8 @@
_Transform(&(p[3]));
fPath.move_to(p[0].x, p[0].y);
- fPath.curve4(p[1].x, p[1].y,
- p[2].x, p[2].y,
- p[3].x, p[3].y);
+ fPath.curve4(p[1].x, p[1].y, p[2].x, p[2].y, p[3].x, p[3].y);
-
fPath.close_polygon();
return _FillPath(fCurve, gradient);
}
@@ -677,9 +696,8 @@
if (op & OP_BEZIERTO) {
int32 count = opList[i] & 0x00FFFFFF;
while (count) {
- fPath.curve4(points[0].x, points[0].y,
- points[1].x, points[1].y,
- points[2].x, points[2].y);
+ fPath.curve4(points[0].x, points[0].y, points[1].x, points[1].y,
+ points[2].x, points[2].y);
points += 3;
count -= 3;
}
@@ -691,15 +709,15 @@
if (filled)
return _FillPath(fCurve);
- else
- return _StrokePath(fCurve);
+
+ return _StrokePath(fCurve);
}
+
// FillShape
BRect
Painter::FillShape(const int32& opCount, const uint32* opList,
- const int32& ptCount, const BPoint* points,
- const BGradient& gradient) const
+ const int32& ptCount, const BPoint* points, const BGradient& gradient) const
{
CHECK_CLIPPING
@@ -725,9 +743,8 @@
if (op & OP_BEZIERTO) {
int32 count = opList[i] & 0x00FFFFFF;
while (count) {
- fPath.curve4(points[0].x, points[0].y,
- points[1].x, points[1].y,
- points[2].x, points[2].y);
+ fPath.curve4(points[0].x, points[0].y, points[1].x, points[1].y,
+ points[2].x, points[2].y);
points += 3;
count -= 3;
}
@@ -740,6 +757,7 @@
return _FillPath(fCurve, gradient);
}
+
// StrokeRect
BRect
Painter::StrokeRect(const BRect& r) const
@@ -757,13 +775,11 @@
pattern p = *fPatternHandler.GetR5Pattern();
if (p == B_SOLID_HIGH) {
BRect rect(a, b);
- StrokeRect(rect,
- fPatternHandler.HighColor());
+ StrokeRect(rect, fPatternHandler.HighColor());
return _Clipped(rect);
} else if (p == B_SOLID_LOW) {
BRect rect(a, b);
- StrokeRect(rect,
- fPatternHandler.LowColor());
+ StrokeRect(rect, fPatternHandler.LowColor());
return _Clipped(rect);
}
}
@@ -791,20 +807,18 @@
return _StrokePath(fPath);
}
+
// StrokeRect
void
Painter::StrokeRect(const BRect& r, const rgb_color& c) const
{
- StraightLine(BPoint(r.left, r.top),
- BPoint(r.right - 1, r.top), c);
- StraightLine(BPoint(r.right, r.top),
- BPoint(r.right, r.bottom - 1), c);
- StraightLine(BPoint(r.right, r.bottom),
- BPoint(r.left + 1, r.bottom), c);
- StraightLine(BPoint(r.left, r.bottom),
- BPoint(r.left, r.top + 1), c);
+ StraightLine(BPoint(r.left, r.top), BPoint(r.right - 1, r.top), c);
+ StraightLine(BPoint(r.right, r.top), BPoint(r.right, r.bottom - 1), c);
+ StraightLine(BPoint(r.right, r.bottom), BPoint(r.left + 1, r.bottom), c);
+ StraightLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top + 1), c);
}
+
// FillRect
BRect
Painter::FillRect(const BRect& r) const
@@ -846,7 +860,6 @@
}
}
-
// account for stricter interpretation of coordinates in AGG
// the rectangle ranges from the top-left (.0, .0)
// to the bottom-right (.9999, .9999) corner of pixels
@@ -863,6 +876,7 @@
return _FillPath(fPath);
}
+
// FillRect
BRect
Painter::FillRect(const BRect& r, const BGradient& gradient) const
@@ -907,6 +921,7 @@
return _FillPath(fPath, gradient);
}
+
// FillRect
void
Painter::FillRect(const BRect& r, const rgb_color& c) const
@@ -940,16 +955,16 @@
// for (int32 x = x1; x <= x2; x++) {
// *handle++ = color.data32;
// }
-gfxset32(offset + y1 * bpr, color.data32, (x2 - x1 + 1) * 4);
+ gfxset32(offset + y1 * bpr, color.data32, (x2 - x1 + 1) * 4);
}
}
} while (fBaseRenderer.next_clip_box());
}
+
// FillRectVerticalGradient
void
-Painter::FillRectVerticalGradient(BRect r,
- const BGradientLinear& gradient) const
+Painter::FillRectVerticalGradient(BRect r, const BGradientLinear& gradient) const
{
if (!fValidClipping)
return;
@@ -998,6 +1013,7 @@
} while (fBaseRenderer.next_clip_box());
}
+
// FillRectNoClipping
void
Painter::FillRectNoClipping(const clipping_rect& r, const rgb_color& c) const
@@ -1025,6 +1041,7 @@
}
}
+
// StrokeRoundRect
BRect
Painter::StrokeRoundRect(const BRect& r, float xRadius, float yRadius) const
@@ -1045,83 +1062,85 @@
rect.radius(xRadius, yRadius);
return _StrokePath(rect);
- } else {
- // NOTE: This implementation might seem a little strange, but it makes
- // stroked round rects look like on R5. A more correct way would be to
- // use _StrokePath() as above (independent from fPenSize).
- // The fact that the bounding box of the round rect is not enlarged
- // by fPenSize/2 is actually on purpose, though one could argue it is
- // unexpected.
+ }
- // enclose the right and bottom edge
- rb.x++;
- rb.y++;
+ // NOTE: This implementation might seem a little strange, but it makes
+ // stroked round rects look like on R5. A more correct way would be to
+ // use _StrokePath() as above (independent from fPenSize).
+ // The fact that the bounding box of the round rect is not enlarged
+ // by fPenSize/2 is actually on purpose, though one could argue it is
+ // unexpected.
- agg::rounded_rect outer;
- outer.rect(lt.x, lt.y, rb.x, rb.y);
- outer.radius(xRadius, yRadius);
+ // enclose the right and bottom edge
+ rb.x++;
+ rb.y++;
- if (gSubpixelAntialiasing) {
- fSubpixRasterizer.reset();
- fSubpixRasterizer.add_path(outer);
+ agg::rounded_rect outer;
+ outer.rect(lt.x, lt.y, rb.x, rb.y);
+ outer.radius(xRadius, yRadius);
- // don't add an inner hole if the "size is negative", this avoids
- // some defects that can be observed on R5 and could be regarded
- // as a bug.
- if (2 * fPenSize < rb.x - lt.x && 2 * fPenSize < rb.y - lt.y) {
- agg::rounded_rect inner;
- inner.rect(lt.x + fPenSize, lt.y + fPenSize, rb.x - fPenSize,
- rb.y - fPenSize);
- inner.radius(max_c(0.0, xRadius - fPenSize),
- max_c(0.0, yRadius - fPenSize));
+ if (gSubpixelAntialiasing) {
+ fSubpixRasterizer.reset();
+ fSubpixRasterizer.add_path(outer);
- fSubpixRasterizer.add_path(inner);
- }
+ // don't add an inner hole if the "size is negative", this avoids
+ // some defects that can be observed on R5 and could be regarded
+ // as a bug.
+ if (2 * fPenSize < rb.x - lt.x && 2 * fPenSize < rb.y - lt.y) {
+ agg::rounded_rect inner;
+ inner.rect(lt.x + fPenSize, lt.y + fPenSize, rb.x - fPenSize,
+ rb.y - fPenSize);
+ inner.radius(max_c(0.0, xRadius - fPenSize),
+ max_c(0.0, yRadius - fPenSize));
- // make the inner rect work as a hole
- fSubpixRasterizer.filling_rule(agg::fill_even_odd);
+ fSubpixRasterizer.add_path(inner);
+ }
- if (fPenSize > 2)
- agg::render_scanlines(fSubpixRasterizer, fSubpixPackedScanline,
- fSubpixRenderer);
- else
- agg::render_scanlines(fSubpixRasterizer, fSubpixUnpackedScanline,
- fSubpixRenderer);
+ // make the inner rect work as a hole
+ fSubpixRasterizer.filling_rule(agg::fill_even_odd);
- fSubpixRasterizer.filling_rule(agg::fill_non_zero);
+ if (fPenSize > 2) {
+ agg::render_scanlines(fSubpixRasterizer, fSubpixPackedScanline,
+ fSubpixRenderer);
} else {
- fRasterizer.reset();
- fRasterizer.add_path(outer);
+ agg::render_scanlines(fSubpixRasterizer, fSubpixUnpackedScanline,
+ fSubpixRenderer);
+ }
- // don't add an inner hole if the "size is negative", this avoids
- // some defects that can be observed on R5 and could be regarded as
- // a bug.
- if (2 * fPenSize < rb.x - lt.x && 2 * fPenSize < rb.y - lt.y) {
- agg::rounded_rect inner;
- inner.rect(lt.x + fPenSize, lt.y + fPenSize, rb.x - fPenSize,
- rb.y - fPenSize);
- inner.radius(max_c(0.0, xRadius - fPenSize),
- max_c(0.0, yRadius - fPenSize));
+ fSubpixRasterizer.filling_rule(agg::fill_non_zero);
+ } else {
+ fRasterizer.reset();
+ fRasterizer.add_path(outer);
- fRasterizer.add_path(inner);
- }
+ // don't add an inner hole if the "size is negative", this avoids
+ // some defects that can be observed on R5 and could be regarded as
+ // a bug.
+ if (2 * fPenSize < rb.x - lt.x && 2 * fPenSize < rb.y - lt.y) {
+ agg::rounded_rect inner;
+ inner.rect(lt.x + fPenSize, lt.y + fPenSize, rb.x - fPenSize,
+ rb.y - fPenSize);
+ inner.radius(max_c(0.0, xRadius - fPenSize),
+ max_c(0.0, yRadius - fPenSize));
- // make the inner rect work as a hole
- fRasterizer.filling_rule(agg::fill_even_odd);
+ fRasterizer.add_path(inner);
+ }
- if (fPenSize > 2)
- agg::render_scanlines(fRasterizer, fPackedScanline, fRenderer);
- else
- agg::render_scanlines(fRasterizer, fUnpackedScanline, fRenderer);
+ // make the inner rect work as a hole
+ fRasterizer.filling_rule(agg::fill_even_odd);
- // reset to default
- fRasterizer.filling_rule(agg::fill_non_zero);
- }
+ if (fPenSize > 2)
+ agg::render_scanlines(fRasterizer, fPackedScanline, fRenderer);
+ else
+ agg::render_scanlines(fRasterizer, fUnpackedScanline, fRenderer);
- return _Clipped(_BoundingBox(outer));
+ // reset to default
+ fRasterizer.filling_rule(agg::fill_non_zero);
}
+
+ return _Clipped(_BoundingBox(outer));
}
+
// FillRoundRect
BRect
Painter::FillRoundRect(const BRect& r, float xRadius, float yRadius) const
@@ -1146,10 +1165,11 @@
return _FillPath(rect);
}
+
// FillRoundRect
BRect
Painter::FillRoundRect(const BRect& r, float xRadius, float yRadius,
- const BGradient& gradient) const
+ const BGradient& gradient) const
{
CHECK_CLIPPING
@@ -1171,6 +1191,7 @@
return _FillPath(rect, gradient);
}
+
// AlignEllipseRect
void
Painter::AlignEllipseRect(BRect* rect, bool filled) const
@@ -1188,6 +1209,7 @@
}
}
+
// DrawEllipse
BRect
Painter::DrawEllipse(BRect r, bool fill) const
@@ -1210,59 +1232,57 @@
agg::ellipse path(center.x, center.y, xRadius, yRadius, divisions);
return _FillPath(path);
- } else {
- // NOTE: This implementation might seem a little strange, but it makes
- // stroked ellipses look like on R5. A more correct way would be to use
- // _StrokePath(), but it currently has its own set of problems with narrow
- // ellipses (for small xRadii or yRadii).
- float inset = fPenSize / 2.0;
- agg::ellipse inner(center.x, center.y,
- max_c(0.0, xRadius - inset),
- max_c(0.0, yRadius - inset),
- divisions);
- agg::ellipse outer(center.x, center.y,
- xRadius + inset,
- yRadius + inset,
- divisions);
+ }
- if (gSubpixelAntialiasing) {
- fSubpixRasterizer.reset();
- fSubpixRasterizer.add_path(outer);
- fSubpixRasterizer.add_path(inner);
+ // NOTE: This implementation might seem a little strange, but it makes
+ // stroked ellipses look like on R5. A more correct way would be to use
+ // _StrokePath(), but it currently has its own set of problems with
+ // narrow ellipses (for small xRadii or yRadii).
+ float inset = fPenSize / 2.0;
+ agg::ellipse inner(center.x, center.y, max_c(0.0, xRadius - inset),
+ max_c(0.0, yRadius - inset), divisions);
+ agg::ellipse outer(center.x, center.y, xRadius + inset, yRadius + inset,
+ divisions);
- // make the inner ellipse work as a hole
- fSubpixRasterizer.filling_rule(agg::fill_even_odd);
+ if (gSubpixelAntialiasing) {
+ fSubpixRasterizer.reset();
+ fSubpixRasterizer.add_path(outer);
+ fSubpixRasterizer.add_path(inner);
- if (fPenSize > 4)
- agg::render_scanlines(fSubpixRasterizer, fSubpixPackedScanline,
- fSubpixRenderer);
- else
- agg::render_scanlines(fSubpixRasterizer, fSubpixUnpackedScanline,
- fSubpixRenderer);
+ // make the inner ellipse work as a hole
+ fSubpixRasterizer.filling_rule(agg::fill_even_odd);
- // reset to default
- fSubpixRasterizer.filling_rule(agg::fill_non_zero);
+ if (fPenSize > 4) {
+ agg::render_scanlines(fSubpixRasterizer, fSubpixPackedScanline,
+ fSubpixRenderer);
} else {
- fRasterizer.reset();
- fRasterizer.add_path(outer);
- fRasterizer.add_path(inner);
+ agg::render_scanlines(fSubpixRasterizer, fSubpixUnpackedScanline,
+ fSubpixRenderer);
+ }
- // make the inner ellipse work as a hole
- fRasterizer.filling_rule(agg::fill_even_odd);
+ // reset to default
+ fSubpixRasterizer.filling_rule(agg::fill_non_zero);
+ } else {
+ fRasterizer.reset();
+ fRasterizer.add_path(outer);
+ fRasterizer.add_path(inner);
- if (fPenSize > 4)
- agg::render_scanlines(fRasterizer, fPackedScanline, fRenderer);
- else
- agg::render_scanlines(fRasterizer, fUnpackedScanline, fRenderer);
+ // make the inner ellipse work as a hole
+ fRasterizer.filling_rule(agg::fill_even_odd);
- // reset to default
- fRasterizer.filling_rule(agg::fill_non_zero);
- }
+ if (fPenSize > 4)
+ agg::render_scanlines(fRasterizer, fPackedScanline, fRenderer);
+ else
+ agg::render_scanlines(fRasterizer, fUnpackedScanline, fRenderer);
- return _Clipped(_BoundingBox(outer));
+ // reset to default
+ fRasterizer.filling_rule(agg::fill_non_zero);
}
+
+ return _Clipped(_BoundingBox(outer));
}
+
// FillEllipse
BRect
Painter::FillEllipse(BRect r, const BGradient& gradient) const
@@ -1286,6 +1306,7 @@
return _FillPath(path, gradient);
}
+
// StrokeArc
BRect
Painter::StrokeArc(BPoint center, float xRadius, float yRadius, float angle,
@@ -1297,8 +1318,8 @@
double angleRad = (angle * PI) / 180.0;
double spanRad = (span * PI) / 180.0;
- agg::bezier_arc arc(center.x, center.y, xRadius, yRadius,
- -angleRad, -spanRad);
+ agg::bezier_arc arc(center.x, center.y, xRadius, yRadius, -angleRad,
+ -spanRad);
agg::conv_curve<agg::bezier_arc> path(arc);
path.approximation_scale(2.0);
@@ -1306,6 +1327,7 @@
return _StrokePath(path);
}
+
// FillArc
BRect
Painter::FillArc(BPoint center, float xRadius, float yRadius, float angle,
@@ -1317,8 +1339,8 @@
double angleRad = (angle * PI) / 180.0;
double spanRad = (span * PI) / 180.0;
- agg::bezier_arc arc(center.x, center.y, xRadius, yRadius,
- -angleRad, -spanRad);
+ agg::bezier_arc arc(center.x, center.y, xRadius, yRadius, -angleRad,
+ -spanRad);
agg::conv_curve<agg::bezier_arc> segmentedArc(arc);
@@ -1342,6 +1364,7 @@
return _FillPath(fPath);
}
+
// FillArc
BRect
Painter::FillArc(BPoint center, float xRadius, float yRadius, float angle,
@@ -1353,8 +1376,8 @@
double angleRad = (angle * PI) / 180.0;
double spanRad = (span * PI) / 180.0;
- agg::bezier_arc arc(center.x, center.y, xRadius, yRadius,
- -angleRad, -spanRad);
+ agg::bezier_arc arc(center.x, center.y, xRadius, yRadius, -angleRad,
+ -spanRad);
agg::conv_curve<agg::bezier_arc> segmentedArc(arc);
@@ -1378,8 +1401,10 @@
return _FillPath(fPath, gradient);
}
+
// #pragma mark -
+
// DrawString
BRect
Painter::DrawString(const char* utf8String, uint32 length, BPoint baseLine,
@@ -1408,6 +1433,7 @@
return _Clipped(bounds);
}
+
// BoundingBox
BRect
Painter::BoundingBox(const char* utf8String, uint32 length, BPoint baseLine,
@@ -1424,6 +1450,7 @@
baseLine, dummy, true, penLocation, delta, cacheReference);
}
+
// StringWidth
float
Painter::StringWidth(const char* utf8String, uint32 length,
@@ -1432,8 +1459,10 @@
return Font().StringWidth(utf8String, length, delta);
}
+
// #pragma mark -
+
// DrawBitmap
BRect
Painter::DrawBitmap(const ServerBitmap* bitmap, BRect bitmapRect,
@@ -1467,8 +1496,10 @@
return touched;
}
+
// #pragma mark -
+
// FillRegion
BRect
Painter::FillRegion(const BRegion* region) const
@@ -1484,6 +1515,7 @@
return touched;
}
+
// FillRegion
BRect
Painter::FillRegion(const BRegion* region, const BGradient& gradient) const
@@ -1499,6 +1531,7 @@
return touched;
}
+
// InvertRect
BRect
Painter::InvertRect(const BRect& r) const
@@ -1506,9 +1539,9 @@
CHECK_CLIPPING
BRegion region(r);
- if (fClippingRegion) {
+ if (fClippingRegion)
region.IntersectWith(fClippingRegion);
- }
+
[... truncated: 657 lines follow ...]
More information about the Haiku-commits
mailing list