1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2011 The Android Open Source Project 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */ 8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkScan_DEFINED 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkScan_DEFINED 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkRect.h" 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 151ba7137fc0dcace0c1be1367fe977202c63746bareed@google.comclass SkRasterClip; 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkRegion; 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkBlitter; 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPath; 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** Defines a fixed-point rectangle, identical to the integer SkIRect, but its 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com coordinates are treated as SkFixed rather than int32_t. 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comtypedef SkIRect SkXRect; 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkScan { 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 27045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillPath(const SkPath&, const SkIRect&, SkBlitter*); 28045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com 29045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com /////////////////////////////////////////////////////////////////////////// 30045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com // rasterclip 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 32045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillIRect(const SkIRect&, const SkRasterClip&, SkBlitter*); 33045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*); 34045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillRect(const SkRect&, const SkRasterClip&, SkBlitter*); 35045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void AntiFillRect(const SkRect&, const SkRasterClip&, SkBlitter*); 36045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void AntiFillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*); 37045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillPath(const SkPath&, const SkRasterClip&, SkBlitter*); 38045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void AntiFillPath(const SkPath&, const SkRasterClip&, SkBlitter*); 39045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FrameRect(const SkRect&, const SkPoint& strokeSize, 40045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com const SkRasterClip&, SkBlitter*); 41045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize, 42045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com const SkRasterClip&, SkBlitter*); 43045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillTriangle(const SkPoint pts[], const SkRasterClip&, SkBlitter*); 44045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void HairLine(const SkPoint&, const SkPoint&, const SkRasterClip&, 457ff678bc1618dc669648198a7bdca8adfb189505mike@reedtribe.org SkBlitter*); 46045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void AntiHairLine(const SkPoint&, const SkPoint&, const SkRasterClip&, 47045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com SkBlitter*); 48045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void HairRect(const SkRect&, const SkRasterClip&, SkBlitter*); 49045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void AntiHairRect(const SkRect&, const SkRasterClip&, SkBlitter*); 50045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void HairPath(const SkPath&, const SkRasterClip&, SkBlitter*); 51045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void AntiHairPath(const SkPath&, const SkRasterClip&, SkBlitter*); 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 53045e62d715f5ee9b03deb5af3c750f8318096179reed@google.comprivate: 54045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com friend class SkAAClip; 55045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com friend class SkRegion; 56045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com 57045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillIRect(const SkIRect&, const SkRegion* clip, SkBlitter*); 58045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillXRect(const SkXRect&, const SkRegion* clip, SkBlitter*); 59045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillRect(const SkRect&, const SkRegion* clip, SkBlitter*); 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static void AntiFillRect(const SkRect&, const SkRegion* clip, SkBlitter*); 6167ba5fa3283185f29c22e9b8daad521de0d00b23reed@google.com static void AntiFillXRect(const SkXRect&, const SkRegion*, SkBlitter*); 62045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillPath(const SkPath&, const SkRegion& clip, SkBlitter*); 632c508f2dc22027d61437b79326297ba055041561reed@google.com static void AntiFillPath(const SkPath&, const SkRegion& clip, SkBlitter*, 642c508f2dc22027d61437b79326297ba055041561reed@google.com bool forceRLE = false); 65045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void FillTriangle(const SkPoint pts[], const SkRegion*, SkBlitter*); 66fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 67761fb62b0eb174783316d2a8b933fba896ca6355reed@google.com static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize, 68761fb62b0eb174783316d2a8b933fba896ca6355reed@google.com const SkRegion*, SkBlitter*); 69045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void HairLineRgn(const SkPoint&, const SkPoint&, const SkRegion*, 70045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com SkBlitter*); 71045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com static void AntiHairLineRgn(const SkPoint&, const SkPoint&, const SkRegion*, 72045e62d715f5ee9b03deb5af3c750f8318096179reed@google.com SkBlitter*); 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** Assign an SkXRect from a SkIRect, by promoting the src rect's coordinates 768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com from int to SkFixed. Does not check for overflow if the src coordinates 778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com exceed 32K 788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 79fc25abdabff76f913fb9d4f373418c10a1eca92breed@android.comstatic inline void XRect_set(SkXRect* xr, const SkIRect& src) { 808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xr->fLeft = SkIntToFixed(src.fLeft); 818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xr->fTop = SkIntToFixed(src.fTop); 828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xr->fRight = SkIntToFixed(src.fRight); 838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xr->fBottom = SkIntToFixed(src.fBottom); 848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** Assign an SkXRect from a SkRect, by promoting the src rect's coordinates 878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com from SkScalar to SkFixed. Does not check for overflow if the src coordinates 888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com exceed 32K 898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 90fc25abdabff76f913fb9d4f373418c10a1eca92breed@android.comstatic inline void XRect_set(SkXRect* xr, const SkRect& src) { 918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xr->fLeft = SkScalarToFixed(src.fLeft); 928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xr->fTop = SkScalarToFixed(src.fTop); 938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xr->fRight = SkScalarToFixed(src.fRight); 948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xr->fBottom = SkScalarToFixed(src.fBottom); 958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** Round the SkXRect coordinates, and store the result in the SkIRect. 988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 99fc25abdabff76f913fb9d4f373418c10a1eca92breed@android.comstatic inline void XRect_round(const SkXRect& xr, SkIRect* dst) { 1009fb00413ec55deb3a4953d4dff2dba3ec5cdb645mike@reedtribe.org dst->fLeft = SkFixedRoundToInt(xr.fLeft); 1019fb00413ec55deb3a4953d4dff2dba3ec5cdb645mike@reedtribe.org dst->fTop = SkFixedRoundToInt(xr.fTop); 1029fb00413ec55deb3a4953d4dff2dba3ec5cdb645mike@reedtribe.org dst->fRight = SkFixedRoundToInt(xr.fRight); 1039fb00413ec55deb3a4953d4dff2dba3ec5cdb645mike@reedtribe.org dst->fBottom = SkFixedRoundToInt(xr.fBottom); 1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** Round the SkXRect coordinates out (i.e. use floor for left/top, and ceiling 1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com for right/bottom), and store the result in the SkIRect. 1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 109fc25abdabff76f913fb9d4f373418c10a1eca92breed@android.comstatic inline void XRect_roundOut(const SkXRect& xr, SkIRect* dst) { 1109fb00413ec55deb3a4953d4dff2dba3ec5cdb645mike@reedtribe.org dst->fLeft = SkFixedFloorToInt(xr.fLeft); 1119fb00413ec55deb3a4953d4dff2dba3ec5cdb645mike@reedtribe.org dst->fTop = SkFixedFloorToInt(xr.fTop); 1129fb00413ec55deb3a4953d4dff2dba3ec5cdb645mike@reedtribe.org dst->fRight = SkFixedCeilToInt(xr.fRight); 1139fb00413ec55deb3a4953d4dff2dba3ec5cdb645mike@reedtribe.org dst->fBottom = SkFixedCeilToInt(xr.fBottom); 1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 117