Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(875)

Side by Side Diff: src/core/SkDeviceLooper.cpp

Issue 1164373003: Revert of change SkDraw and all Blitters to use pixmap instead of bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkDeviceLooper.h ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDeviceLooper.h" 8 #include "SkDeviceLooper.h"
9 9
10 SkDeviceLooper::SkDeviceLooper(const SkPixmap& base, const SkRasterClip& rc, con st SkIRect& bounds, 10 SkDeviceLooper::SkDeviceLooper(const SkBitmap& base,
11 bool aa) 11 const SkRasterClip& rc,
12 : fBaseDst(base) 12 const SkIRect& bounds, bool aa)
13 : fBaseBitmap(base)
13 , fBaseRC(rc) 14 , fBaseRC(rc)
14 , fSubsetRC(rc.isForceConservativeRects()) 15 , fSubsetRC(rc.isForceConservativeRects())
15 , fDelta(aa ? kAA_Delta : kBW_Delta) 16 , fDelta(aa ? kAA_Delta : kBW_Delta)
16 { 17 {
17 // sentinels that next() has not yet been called, and so our mapper function s 18 // sentinels that next() has not yet been called, and so our mapper function s
18 // should not be called either. 19 // should not be called either.
19 fCurrDst = NULL; 20 fCurrBitmap = NULL;
20 fCurrRC = NULL; 21 fCurrRC = NULL;
21 22
22 if (!rc.isEmpty()) { 23 if (!rc.isEmpty()) {
23 // clip must be contained by the bitmap 24 // clip must be contained by the bitmap
24 SkASSERT(SkIRect::MakeWH(base.width(), base.height()).contains(rc.getBou nds())); 25 SkASSERT(SkIRect::MakeWH(base.width(), base.height()).contains(rc.getBou nds()));
25 } 26 }
26 27
27 if (rc.isEmpty() || !fClippedBounds.intersect(bounds, rc.getBounds())) { 28 if (rc.isEmpty() || !fClippedBounds.intersect(bounds, rc.getBounds())) {
28 fState = kDone_State; 29 fState = kDone_State;
29 } else if (this->fitsInDelta(fClippedBounds)) { 30 } else if (this->fitsInDelta(fClippedBounds)) {
30 fState = kSimple_State; 31 fState = kSimple_State;
31 } else { 32 } else {
32 // back up by 1 DX, so that next() will put us in a correct starting 33 // back up by 1 DX, so that next() will put us in a correct starting
33 // position. 34 // position.
34 fCurrOffset.set(fClippedBounds.left() - fDelta, 35 fCurrOffset.set(fClippedBounds.left() - fDelta,
35 fClippedBounds.top()); 36 fClippedBounds.top());
36 fState = kComplex_State; 37 fState = kComplex_State;
37 } 38 }
38 } 39 }
39 40
40 SkDeviceLooper::~SkDeviceLooper() {} 41 SkDeviceLooper::~SkDeviceLooper() {
42 }
41 43
42 void SkDeviceLooper::mapRect(SkRect* dst, const SkRect& src) const { 44 void SkDeviceLooper::mapRect(SkRect* dst, const SkRect& src) const {
43 SkASSERT(kDone_State != fState); 45 SkASSERT(kDone_State != fState);
44 SkASSERT(fCurrDst); 46 SkASSERT(fCurrBitmap);
45 SkASSERT(fCurrRC); 47 SkASSERT(fCurrRC);
46 48
47 *dst = src; 49 *dst = src;
48 dst->offset(SkIntToScalar(-fCurrOffset.fX), 50 dst->offset(SkIntToScalar(-fCurrOffset.fX),
49 SkIntToScalar(-fCurrOffset.fY)); 51 SkIntToScalar(-fCurrOffset.fY));
50 } 52 }
51 53
52 void SkDeviceLooper::mapMatrix(SkMatrix* dst, const SkMatrix& src) const { 54 void SkDeviceLooper::mapMatrix(SkMatrix* dst, const SkMatrix& src) const {
53 SkASSERT(kDone_State != fState); 55 SkASSERT(kDone_State != fState);
54 SkASSERT(fCurrDst); 56 SkASSERT(fCurrBitmap);
55 SkASSERT(fCurrRC); 57 SkASSERT(fCurrRC);
56 58
57 *dst = src; 59 *dst = src;
58 dst->postTranslate(SkIntToScalar(-fCurrOffset.fX), SkIntToScalar(-fCurrOffse t.fY)); 60 dst->postTranslate(SkIntToScalar(-fCurrOffset.fX),
61 SkIntToScalar(-fCurrOffset.fY));
59 } 62 }
60 63
61 bool SkDeviceLooper::computeCurrBitmapAndClip() { 64 bool SkDeviceLooper::computeCurrBitmapAndClip() {
62 SkASSERT(kComplex_State == fState); 65 SkASSERT(kComplex_State == fState);
63 66
64 SkIRect r = SkIRect::MakeXYWH(fCurrOffset.x(), fCurrOffset.y(), 67 SkIRect r = SkIRect::MakeXYWH(fCurrOffset.x(), fCurrOffset.y(),
65 fDelta, fDelta); 68 fDelta, fDelta);
66 if (!fBaseDst.extractSubset(&fSubsetDst, r)) { 69 if (!fBaseBitmap.extractSubset(&fSubsetBitmap, r)) {
67 fSubsetRC.setEmpty(); 70 fSubsetRC.setEmpty();
68 } else { 71 } else {
72 fSubsetBitmap.lockPixels();
69 fBaseRC.translate(-r.left(), -r.top(), &fSubsetRC); 73 fBaseRC.translate(-r.left(), -r.top(), &fSubsetRC);
70 (void)fSubsetRC.op(SkIRect::MakeWH(fDelta, fDelta), SkRegion::kIntersect _Op); 74 (void)fSubsetRC.op(SkIRect::MakeWH(fDelta, fDelta),
75 SkRegion::kIntersect_Op);
71 } 76 }
72 77
73 fCurrDst = &fSubsetDst; 78 fCurrBitmap = &fSubsetBitmap;
74 fCurrRC = &fSubsetRC; 79 fCurrRC = &fSubsetRC;
75 return !fCurrRC->isEmpty(); 80 return !fCurrRC->isEmpty();
76 } 81 }
77 82
78 static bool next_tile(const SkIRect& boundary, int delta, SkIPoint* offset) { 83 static bool next_tile(const SkIRect& boundary, int delta, SkIPoint* offset) {
79 // can we move to the right? 84 // can we move to the right?
80 if (offset->x() + delta < boundary.right()) { 85 if (offset->x() + delta < boundary.right()) {
81 offset->fX += delta; 86 offset->fX += delta;
82 return true; 87 return true;
83 } 88 }
(...skipping 11 matching lines...) Expand all
95 100
96 bool SkDeviceLooper::next() { 101 bool SkDeviceLooper::next() {
97 switch (fState) { 102 switch (fState) {
98 case kDone_State: 103 case kDone_State:
99 // in theory, we should not get called here, since we must have 104 // in theory, we should not get called here, since we must have
100 // previously returned false, but we check anyway. 105 // previously returned false, but we check anyway.
101 break; 106 break;
102 107
103 case kSimple_State: 108 case kSimple_State:
104 // first time for simple 109 // first time for simple
105 if (NULL == fCurrDst) { 110 if (NULL == fCurrBitmap) {
106 fCurrDst = &fBaseDst; 111 fCurrBitmap = &fBaseBitmap;
107 fCurrRC = &fBaseRC; 112 fCurrRC = &fBaseRC;
108 fCurrOffset.set(0, 0); 113 fCurrOffset.set(0, 0);
109 return true; 114 return true;
110 } 115 }
111 // 2nd time for simple, we are done 116 // 2nd time for simple, we are done
112 break; 117 break;
113 118
114 case kComplex_State: 119 case kComplex_State:
115 // need to propogate fCurrOffset through clippedbounds 120 // need to propogate fCurrOffset through clippedbounds
116 // left to right, until we wrap around and move down 121 // left to right, until we wrap around and move down
117 122
118 while (next_tile(fClippedBounds, fDelta, &fCurrOffset)) { 123 while (next_tile(fClippedBounds, fDelta, &fCurrOffset)) {
119 if (this->computeCurrBitmapAndClip()) { 124 if (this->computeCurrBitmapAndClip()) {
120 return true; 125 return true;
121 } 126 }
122 } 127 }
123 break; 128 break;
124 } 129 }
125 fState = kDone_State; 130 fState = kDone_State;
126 return false; 131 return false;
127 } 132 }
OLDNEW
« no previous file with comments | « src/core/SkDeviceLooper.h ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698