1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/core/SkScan.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,116 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2011 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#ifndef SkScan_DEFINED 1.14 +#define SkScan_DEFINED 1.15 + 1.16 +#include "SkRect.h" 1.17 + 1.18 +class SkRasterClip; 1.19 +class SkRegion; 1.20 +class SkBlitter; 1.21 +class SkPath; 1.22 + 1.23 +/** Defines a fixed-point rectangle, identical to the integer SkIRect, but its 1.24 + coordinates are treated as SkFixed rather than int32_t. 1.25 +*/ 1.26 +typedef SkIRect SkXRect; 1.27 + 1.28 +class SkScan { 1.29 +public: 1.30 + static void FillPath(const SkPath&, const SkIRect&, SkBlitter*); 1.31 + 1.32 + /////////////////////////////////////////////////////////////////////////// 1.33 + // rasterclip 1.34 + 1.35 + static void FillIRect(const SkIRect&, const SkRasterClip&, SkBlitter*); 1.36 + static void FillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*); 1.37 + static void FillRect(const SkRect&, const SkRasterClip&, SkBlitter*); 1.38 + static void AntiFillRect(const SkRect&, const SkRasterClip&, SkBlitter*); 1.39 + static void AntiFillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*); 1.40 + static void FillPath(const SkPath&, const SkRasterClip&, SkBlitter*); 1.41 + static void AntiFillPath(const SkPath&, const SkRasterClip&, SkBlitter*); 1.42 + static void FrameRect(const SkRect&, const SkPoint& strokeSize, 1.43 + const SkRasterClip&, SkBlitter*); 1.44 + static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize, 1.45 + const SkRasterClip&, SkBlitter*); 1.46 + static void FillTriangle(const SkPoint pts[], const SkRasterClip&, SkBlitter*); 1.47 + static void HairLine(const SkPoint&, const SkPoint&, const SkRasterClip&, 1.48 + SkBlitter*); 1.49 + static void AntiHairLine(const SkPoint&, const SkPoint&, const SkRasterClip&, 1.50 + SkBlitter*); 1.51 + static void HairRect(const SkRect&, const SkRasterClip&, SkBlitter*); 1.52 + static void AntiHairRect(const SkRect&, const SkRasterClip&, SkBlitter*); 1.53 + static void HairPath(const SkPath&, const SkRasterClip&, SkBlitter*); 1.54 + static void AntiHairPath(const SkPath&, const SkRasterClip&, SkBlitter*); 1.55 + 1.56 +private: 1.57 + friend class SkAAClip; 1.58 + friend class SkRegion; 1.59 + 1.60 + static void FillIRect(const SkIRect&, const SkRegion* clip, SkBlitter*); 1.61 + static void FillXRect(const SkXRect&, const SkRegion* clip, SkBlitter*); 1.62 + static void FillRect(const SkRect&, const SkRegion* clip, SkBlitter*); 1.63 + static void AntiFillRect(const SkRect&, const SkRegion* clip, SkBlitter*); 1.64 + static void AntiFillXRect(const SkXRect&, const SkRegion*, SkBlitter*); 1.65 + static void FillPath(const SkPath&, const SkRegion& clip, SkBlitter*); 1.66 + static void AntiFillPath(const SkPath&, const SkRegion& clip, SkBlitter*, 1.67 + bool forceRLE = false); 1.68 + static void FillTriangle(const SkPoint pts[], const SkRegion*, SkBlitter*); 1.69 + 1.70 + static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize, 1.71 + const SkRegion*, SkBlitter*); 1.72 + static void HairLineRgn(const SkPoint&, const SkPoint&, const SkRegion*, 1.73 + SkBlitter*); 1.74 + static void AntiHairLineRgn(const SkPoint&, const SkPoint&, const SkRegion*, 1.75 + SkBlitter*); 1.76 +}; 1.77 + 1.78 +/** Assign an SkXRect from a SkIRect, by promoting the src rect's coordinates 1.79 + from int to SkFixed. Does not check for overflow if the src coordinates 1.80 + exceed 32K 1.81 +*/ 1.82 +static inline void XRect_set(SkXRect* xr, const SkIRect& src) { 1.83 + xr->fLeft = SkIntToFixed(src.fLeft); 1.84 + xr->fTop = SkIntToFixed(src.fTop); 1.85 + xr->fRight = SkIntToFixed(src.fRight); 1.86 + xr->fBottom = SkIntToFixed(src.fBottom); 1.87 +} 1.88 + 1.89 +/** Assign an SkXRect from a SkRect, by promoting the src rect's coordinates 1.90 + from SkScalar to SkFixed. Does not check for overflow if the src coordinates 1.91 + exceed 32K 1.92 +*/ 1.93 +static inline void XRect_set(SkXRect* xr, const SkRect& src) { 1.94 + xr->fLeft = SkScalarToFixed(src.fLeft); 1.95 + xr->fTop = SkScalarToFixed(src.fTop); 1.96 + xr->fRight = SkScalarToFixed(src.fRight); 1.97 + xr->fBottom = SkScalarToFixed(src.fBottom); 1.98 +} 1.99 + 1.100 +/** Round the SkXRect coordinates, and store the result in the SkIRect. 1.101 +*/ 1.102 +static inline void XRect_round(const SkXRect& xr, SkIRect* dst) { 1.103 + dst->fLeft = SkFixedRoundToInt(xr.fLeft); 1.104 + dst->fTop = SkFixedRoundToInt(xr.fTop); 1.105 + dst->fRight = SkFixedRoundToInt(xr.fRight); 1.106 + dst->fBottom = SkFixedRoundToInt(xr.fBottom); 1.107 +} 1.108 + 1.109 +/** Round the SkXRect coordinates out (i.e. use floor for left/top, and ceiling 1.110 + for right/bottom), and store the result in the SkIRect. 1.111 +*/ 1.112 +static inline void XRect_roundOut(const SkXRect& xr, SkIRect* dst) { 1.113 + dst->fLeft = SkFixedFloorToInt(xr.fLeft); 1.114 + dst->fTop = SkFixedFloorToInt(xr.fTop); 1.115 + dst->fRight = SkFixedCeilToInt(xr.fRight); 1.116 + dst->fBottom = SkFixedCeilToInt(xr.fBottom); 1.117 +} 1.118 + 1.119 +#endif