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 class SkDeviceLooper { | |
|
tomhudson
2013/08/28 10:53:05
Since this has state that changes the class semant
reed1
2013/08/28 12:35:07
Yes indeed, I will add dox.
| |
| 16 public: | |
| 17 SkDeviceLooper(const SkBitmap& base, const SkRasterClip&, | |
| 18 const SkIRect& bounds, bool aa); | |
| 19 ~SkDeviceLooper(); | |
| 20 | |
| 21 const SkBitmap& getBitmap() const { | |
| 22 SkASSERT(kDone_State != fState); | |
| 23 return *fCurrBitmap; | |
| 24 } | |
| 25 | |
| 26 const SkRasterClip& getRC() const { | |
| 27 SkASSERT(kDone_State != fState); | |
| 28 return *fCurrRC; | |
| 29 } | |
| 30 | |
| 31 void mapRect(SkRect* dst, const SkRect& src) const; | |
| 32 void mapMatrix(SkMatrix* dst, const SkMatrix& src) const; | |
| 33 | |
| 34 bool next(); | |
| 35 | |
| 36 private: | |
| 37 const SkBitmap& fBaseBitmap; | |
| 38 const SkRasterClip& fBaseRC; | |
| 39 | |
| 40 enum State { | |
| 41 kDone_State, // iteration is complete, getters will assert | |
| 42 kSimple_State, // no translate/clip mods needed | |
| 43 kComplex_State | |
| 44 }; | |
| 45 | |
| 46 // storage for our tiled versions. Perhaps could use SkTLazy | |
| 47 SkBitmap fSubsetBitmap; | |
| 48 SkRasterClip fSubsetRC; | |
| 49 | |
| 50 const SkBitmap* fCurrBitmap; | |
| 51 const SkRasterClip* fCurrRC; | |
| 52 SkIRect fClippedBounds; | |
| 53 SkIPoint fCurrOffset; | |
| 54 int fDelta; | |
| 55 State fState; | |
| 56 | |
| 57 enum Delta { | |
| 58 kBW_Delta = 1 << 14, // 16K, gives room to spare for fixedpoint | |
| 59 kAA_Delta = kBW_Delta >> 2 // supersample 4x | |
| 60 }; | |
| 61 | |
| 62 bool fitsInDelta(const SkIRect& r) const { | |
| 63 return r.right() < fDelta && r.bottom() < fDelta; | |
| 64 } | |
| 65 | |
| 66 bool computeCurrBitmapAndClip(); | |
| 67 }; | |
| 68 | |
| 69 #endif | |
| OLD | NEW |