/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef OD_SR_RASTERIZERS #define OD_SR_RASTERIZERS #include "SrRenderState.h" // Forward declarations class OdSrFrameContext; // Helper structures and functions struct OdSrVec2F { float x; float y; }; inline bool is_top_left(const OdSrVec2F& start, const OdSrVec2F& end) { OdSrVec2F edge = { end.x - start.x, end.y - start.y }; bool is_top_edge = edge.y == 0 && edge.x > 0; bool is_left_edge = edge.y < 0; return is_left_edge || is_top_edge; } inline float edge_cross(const OdSrVec2F& a, const OdSrVec2F& b, const OdSrVec2F& p) { OdSrVec2F ab = { b.x - a.x, b.y - a.y }; OdSrVec2F ap = { p.x - a.x, p.y - a.y }; return ab.x * ap.y - ab.y * ap.x; } class OdSrFrameContext; struct GsSrRenderState; // Line rasterizer class GsSrLineRasterizer { public: static void draw(OdSrFrameContext& context, GsSrRenderState& state, int x1, int y1, int x2, int y2, ODCOLORREF col); }; // Triangle rasterizer class GsSrTriangleRasterizer { public: static void draw(OdSrFrameContext& context, GsSrRenderState& state, int x1, int y1, int x2, int y2, int x3, int y3, ODCOLORREF col); static void drawMultiColor(OdSrFrameContext& context, GsSrRenderState& state, float x1, float y1, float x2, float y2, float x3, float y3, const ODCOLORREF* threeColors); static void drawClipping(OdSrFrameContext& context, GsSrRenderState& state, int x1, int y1, int x2, int y2, int x3, int y3); }; // Circle rasterizer class GsSrCircleRasterizer { public: static void drawOutline(OdSrFrameContext& context, GsSrRenderState& state, int centerX, int centerY, int radius); static void drawFilled(OdSrFrameContext& context, GsSrRenderState& state, int x, int y, double radius, ODCOLORREF color); static void drawFilledPrecise(OdSrFrameContext& context, GsSrRenderState& state, double cx, double cy, double radius, ODCOLORREF color); }; // Ellipse rasterizer class GsSrEllipseRasterizer { public: static void drawOutline(OdSrFrameContext& context, GsSrRenderState& state, int centerX, int centerY, int radiusMajor, int radiusMinor); static void drawFilled(OdSrFrameContext& context, GsSrRenderState& state, int centerX, int centerY, int radiusMajor, int radiusMinor); }; #endif // OD_SR_RASTERIZERS