Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2013 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef SkDeviceLooper_DEFINED | |
| 9 #define SkDeviceLooper_DEFINED | |
| 10 | |
| 11 #include "SkBitmap.h" | |
| 12 #include "SkMatrix.h" | |
| 13 #include "SkRasterClip.h" | |
| 14 | |
| 15 /** | |
| 16 * Helper class to manage "tiling" are large coordinate space into managable | |
|
tomhudson
2013/08/28 14:27:50
Nit: are?
reed1
2013/08/28 14:38:33
Done.
| |
| 17 * chunks, where managable means areas that are <= some max critical coordinate | |
| 18 * size. | |
| 19 * | |
| 20 * The constructor takes an antialiasing bool, which affects what this maximum | |
| 21 * allowable size is: If we're drawing BW, then we need coordinates to stay | |
| 22 * safely within fixed-point range (we use +- 16K, to give ourselves room to | |
| 23 * add/subtract two fixed values and still be in range. If we're drawing AA, | |
| 24 * then we reduce that size by the amount that the supersampler scan converter | |
| 25 * needs (at the moment, that is 4X, so the effect "safe" range is +- 4K). | |
|
tomhudson
2013/08/28 14:27:50
Nit: effect -> effective
Or just drop that word, a
reed1
2013/08/28 14:38:33
Done.
| |
| 26 * | |
| 27 * For performance reasons, the class first checks to see if any help is needed | |
| 28 * at all, and if not (i.e. the specified bounds and base bitmap area already | |
| 29 * in the safe-zone, then the class does nothing (effectively). | |
| 30 */ | |
| 31 class SkDeviceLooper { | |
| 32 public: | |
| 33 SkDeviceLooper(const SkBitmap& base, const SkRasterClip&, | |
| 34 const SkIRect& bounds, bool aa); | |
| 35 ~SkDeviceLooper(); | |
| 36 | |
| 37 const SkBitmap& getBitmap() const { | |
| 38 SkASSERT(kDone_State != fState); | |
| 39 return *fCurrBitmap; | |
| 40 } | |
| 41 | |
| 42 const SkRasterClip& getRC() const { | |
| 43 SkASSERT(kDone_State != fState); | |
| 44 return *fCurrRC; | |
| 45 } | |
| 46 | |
| 47 void mapRect(SkRect* dst, const SkRect& src) const; | |
| 48 void mapMatrix(SkMatrix* dst, const SkMatrix& src) const; | |
| 49 | |
| 50 bool next(); | |
|
tomhudson
2013/08/28 14:27:50
Even after reading the code I don't know what the
reed1
2013/08/28 14:38:33
Same as all of skia's interators that just use a n
| |
| 51 | |
| 52 private: | |
| 53 const SkBitmap& fBaseBitmap; | |
| 54 const SkRasterClip& fBaseRC; | |
| 55 | |
| 56 enum State { | |
| 57 kDone_State, // iteration is complete, getters will assert | |
| 58 kPreSimple_State, // no translate/clip mods needed | |
| 59 kPostSimple_State, | |
| 60 kComplex_State | |
| 61 }; | |
| 62 | |
| 63 // storage for our tiled versions. Perhaps could use SkTLazy | |
| 64 SkBitmap fSubsetBitmap; | |
| 65 SkRasterClip fSubsetRC; | |
| 66 | |
| 67 const SkBitmap* fCurrBitmap; | |
| 68 const SkRasterClip* fCurrRC; | |
| 69 SkIRect fClippedBounds; | |
| 70 SkIPoint fCurrOffset; | |
| 71 int fDelta; | |
| 72 State fState; | |
| 73 | |
| 74 enum Delta { | |
| 75 kBW_Delta = 1 << 14, // 16K, gives room to spare for fixedpoint | |
| 76 kAA_Delta = kBW_Delta >> 2 // supersample 4x | |
| 77 }; | |
| 78 | |
| 79 bool fitsInDelta(const SkIRect& r) const { | |
| 80 return r.right() < fDelta && r.bottom() < fDelta; | |
| 81 } | |
| 82 | |
| 83 bool computeCurrBitmapAndClip(); | |
| 84 }; | |
| 85 | |
| 86 #endif | |
| OLD | NEW |