michael@0: michael@0: /* michael@0: * Copyright 2011 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkScan_DEFINED michael@0: #define SkScan_DEFINED michael@0: michael@0: #include "SkRect.h" michael@0: michael@0: class SkRasterClip; michael@0: class SkRegion; michael@0: class SkBlitter; michael@0: class SkPath; michael@0: michael@0: /** Defines a fixed-point rectangle, identical to the integer SkIRect, but its michael@0: coordinates are treated as SkFixed rather than int32_t. michael@0: */ michael@0: typedef SkIRect SkXRect; michael@0: michael@0: class SkScan { michael@0: public: michael@0: static void FillPath(const SkPath&, const SkIRect&, SkBlitter*); michael@0: michael@0: /////////////////////////////////////////////////////////////////////////// michael@0: // rasterclip michael@0: michael@0: static void FillIRect(const SkIRect&, const SkRasterClip&, SkBlitter*); michael@0: static void FillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*); michael@0: static void FillRect(const SkRect&, const SkRasterClip&, SkBlitter*); michael@0: static void AntiFillRect(const SkRect&, const SkRasterClip&, SkBlitter*); michael@0: static void AntiFillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*); michael@0: static void FillPath(const SkPath&, const SkRasterClip&, SkBlitter*); michael@0: static void AntiFillPath(const SkPath&, const SkRasterClip&, SkBlitter*); michael@0: static void FrameRect(const SkRect&, const SkPoint& strokeSize, michael@0: const SkRasterClip&, SkBlitter*); michael@0: static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize, michael@0: const SkRasterClip&, SkBlitter*); michael@0: static void FillTriangle(const SkPoint pts[], const SkRasterClip&, SkBlitter*); michael@0: static void HairLine(const SkPoint&, const SkPoint&, const SkRasterClip&, michael@0: SkBlitter*); michael@0: static void AntiHairLine(const SkPoint&, const SkPoint&, const SkRasterClip&, michael@0: SkBlitter*); michael@0: static void HairRect(const SkRect&, const SkRasterClip&, SkBlitter*); michael@0: static void AntiHairRect(const SkRect&, const SkRasterClip&, SkBlitter*); michael@0: static void HairPath(const SkPath&, const SkRasterClip&, SkBlitter*); michael@0: static void AntiHairPath(const SkPath&, const SkRasterClip&, SkBlitter*); michael@0: michael@0: private: michael@0: friend class SkAAClip; michael@0: friend class SkRegion; michael@0: michael@0: static void FillIRect(const SkIRect&, const SkRegion* clip, SkBlitter*); michael@0: static void FillXRect(const SkXRect&, const SkRegion* clip, SkBlitter*); michael@0: static void FillRect(const SkRect&, const SkRegion* clip, SkBlitter*); michael@0: static void AntiFillRect(const SkRect&, const SkRegion* clip, SkBlitter*); michael@0: static void AntiFillXRect(const SkXRect&, const SkRegion*, SkBlitter*); michael@0: static void FillPath(const SkPath&, const SkRegion& clip, SkBlitter*); michael@0: static void AntiFillPath(const SkPath&, const SkRegion& clip, SkBlitter*, michael@0: bool forceRLE = false); michael@0: static void FillTriangle(const SkPoint pts[], const SkRegion*, SkBlitter*); michael@0: michael@0: static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize, michael@0: const SkRegion*, SkBlitter*); michael@0: static void HairLineRgn(const SkPoint&, const SkPoint&, const SkRegion*, michael@0: SkBlitter*); michael@0: static void AntiHairLineRgn(const SkPoint&, const SkPoint&, const SkRegion*, michael@0: SkBlitter*); michael@0: }; michael@0: michael@0: /** Assign an SkXRect from a SkIRect, by promoting the src rect's coordinates michael@0: from int to SkFixed. Does not check for overflow if the src coordinates michael@0: exceed 32K michael@0: */ michael@0: static inline void XRect_set(SkXRect* xr, const SkIRect& src) { michael@0: xr->fLeft = SkIntToFixed(src.fLeft); michael@0: xr->fTop = SkIntToFixed(src.fTop); michael@0: xr->fRight = SkIntToFixed(src.fRight); michael@0: xr->fBottom = SkIntToFixed(src.fBottom); michael@0: } michael@0: michael@0: /** Assign an SkXRect from a SkRect, by promoting the src rect's coordinates michael@0: from SkScalar to SkFixed. Does not check for overflow if the src coordinates michael@0: exceed 32K michael@0: */ michael@0: static inline void XRect_set(SkXRect* xr, const SkRect& src) { michael@0: xr->fLeft = SkScalarToFixed(src.fLeft); michael@0: xr->fTop = SkScalarToFixed(src.fTop); michael@0: xr->fRight = SkScalarToFixed(src.fRight); michael@0: xr->fBottom = SkScalarToFixed(src.fBottom); michael@0: } michael@0: michael@0: /** Round the SkXRect coordinates, and store the result in the SkIRect. michael@0: */ michael@0: static inline void XRect_round(const SkXRect& xr, SkIRect* dst) { michael@0: dst->fLeft = SkFixedRoundToInt(xr.fLeft); michael@0: dst->fTop = SkFixedRoundToInt(xr.fTop); michael@0: dst->fRight = SkFixedRoundToInt(xr.fRight); michael@0: dst->fBottom = SkFixedRoundToInt(xr.fBottom); michael@0: } michael@0: michael@0: /** Round the SkXRect coordinates out (i.e. use floor for left/top, and ceiling michael@0: for right/bottom), and store the result in the SkIRect. michael@0: */ michael@0: static inline void XRect_roundOut(const SkXRect& xr, SkIRect* dst) { michael@0: dst->fLeft = SkFixedFloorToInt(xr.fLeft); michael@0: dst->fTop = SkFixedFloorToInt(xr.fTop); michael@0: dst->fRight = SkFixedCeilToInt(xr.fRight); michael@0: dst->fBottom = SkFixedCeilToInt(xr.fBottom); michael@0: } michael@0: michael@0: #endif