OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkBlitter.h" | 8 #include "SkBlitter.h" |
9 #include "SkAntiRun.h" | 9 #include "SkAntiRun.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 | 119 |
120 void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip) { | 120 void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip) { |
121 SkASSERT(mask.fBounds.contains(clip)); | 121 SkASSERT(mask.fBounds.contains(clip)); |
122 | 122 |
123 if (mask.fFormat == SkMask::kBW_Format) { | 123 if (mask.fFormat == SkMask::kBW_Format) { |
124 int cx = clip.fLeft; | 124 int cx = clip.fLeft; |
125 int cy = clip.fTop; | 125 int cy = clip.fTop; |
126 int maskLeft = mask.fBounds.fLeft; | 126 int maskLeft = mask.fBounds.fLeft; |
127 int mask_rowBytes = mask.fRowBytes; | 127 int mask_rowBytes = mask.fRowBytes; |
128 int height = clip.height(); | 128 int height = clip.height(); |
129 SkDEBUGCODE(const uint8_t* endOfImage = | |
130 mask.fImage + (mask.fBounds.fBottom - mask.fBounds.fTop) * mask_rowB ytes;) | |
129 | 131 |
130 const uint8_t* bits = mask.getAddr1(cx, cy); | 132 const uint8_t* bits = mask.getAddr1(cx, cy); |
131 | 133 |
132 if (cx == maskLeft && clip.fRight == mask.fBounds.fRight) { | 134 if (cx == maskLeft && clip.fRight == mask.fBounds.fRight) { |
133 while (--height >= 0) { | 135 while (--height >= 0) { |
134 bits_to_runs(this, cx, cy, bits, 0xFF, mask_rowBytes, 0xFF); | 136 SkASSERT(bits + mask_rowBytes <= endOfImage); |
137 U8CPU rightMask = 0xFF << (8 - (clip.width() & 7)); | |
reed1
2015/11/17 16:24:32
note: this will be bigger than a byte, something y
herb_g
2015/11/17 20:14:03
This ends up working because the bits_to_run code
| |
138 bits_to_runs(this, cx, cy, bits, 0xFF, mask_rowBytes, rightMask) ; | |
135 bits += mask_rowBytes; | 139 bits += mask_rowBytes; |
136 cy += 1; | 140 cy += 1; |
137 } | 141 } |
138 } else { | 142 } else { |
139 int left_edge = cx - maskLeft; | 143 int left_edge = cx - maskLeft; |
140 SkASSERT(left_edge >= 0); | 144 SkASSERT(left_edge >= 0); |
141 int rite_edge = clip.fRight - maskLeft; | 145 int rite_edge = clip.fRight - maskLeft; |
142 SkASSERT(rite_edge > left_edge); | 146 SkASSERT(rite_edge > left_edge); |
143 | 147 |
144 int left_mask = 0xFF >> (left_edge & 7); | 148 int left_mask = 0xFF >> (left_edge & 7); |
145 int rite_mask = 0xFF << (8 - (rite_edge & 7)); | 149 int rite_mask = (0xFF << (8 - (rite_edge & 7))) & 0xFF; |
146 int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3); | 150 int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3); |
147 | 151 |
148 // check for empty right mask, so we don't read off the end (or go s lower than we need to) | 152 // check for empty right mask, so we don't read off the end (or go s lower than we need to) |
149 if (rite_mask == 0) { | 153 if (rite_mask == 0) { |
150 SkASSERT(full_runs >= 0); | 154 SkASSERT(full_runs >= 0); |
151 full_runs -= 1; | 155 full_runs -= 1; |
152 rite_mask = 0xFF; | 156 rite_mask = 0xFF; |
153 } | 157 } |
154 if (left_mask == 0xFF) { | 158 if (left_mask == 0xFF) { |
155 full_runs -= 1; | 159 full_runs -= 1; |
156 } | 160 } |
157 | 161 |
158 // back up manually so we can keep in sync with our byte-aligned src | 162 // back up manually so we can keep in sync with our byte-aligned src |
159 // have cx reflect our actual starting x-coord | 163 // have cx reflect our actual starting x-coord |
160 cx -= left_edge & 7; | 164 cx -= left_edge & 7; |
161 | 165 |
162 if (full_runs < 0) { | 166 if (full_runs < 0) { |
163 SkASSERT((left_mask & rite_mask) != 0); | 167 SkASSERT((left_mask & rite_mask) != 0); |
164 while (--height >= 0) { | 168 while (--height >= 0) { |
169 SkASSERT(bits + 1 <= endOfImage); | |
165 bits_to_runs(this, cx, cy, bits, left_mask, 1, rite_mask); | 170 bits_to_runs(this, cx, cy, bits, left_mask, 1, rite_mask); |
166 bits += mask_rowBytes; | 171 bits += mask_rowBytes; |
167 cy += 1; | 172 cy += 1; |
168 } | 173 } |
169 } else { | 174 } else { |
170 while (--height >= 0) { | 175 while (--height >= 0) { |
176 SkASSERT(bits + full_runs + 2 <= endOfImage); | |
171 bits_to_runs(this, cx, cy, bits, left_mask, full_runs + 2, r ite_mask); | 177 bits_to_runs(this, cx, cy, bits, left_mask, full_runs + 2, r ite_mask); |
172 bits += mask_rowBytes; | 178 bits += mask_rowBytes; |
173 cy += 1; | 179 cy += 1; |
174 } | 180 } |
175 } | 181 } |
176 } | 182 } |
177 } else { | 183 } else { |
178 int width = clip.width(); | 184 int width = clip.width(); |
179 SkAutoSTMalloc<64, int16_t> runStorage(width + 1); | 185 SkAutoSTMalloc<64, int16_t> runStorage(width + 1); |
180 int16_t* runs = runStorage.get(); | 186 int16_t* runs = runStorage.get(); |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
968 fShaderContext->~Context(); | 974 fShaderContext->~Context(); |
969 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); | 975 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); |
970 if (nullptr == ctx) { | 976 if (nullptr == ctx) { |
971 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call | 977 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call |
972 // the in-place destructor. | 978 // the in-place destructor. |
973 new (fShaderContext) SkZeroShaderContext(*fShader, rec); | 979 new (fShaderContext) SkZeroShaderContext(*fShader, rec); |
974 return false; | 980 return false; |
975 } | 981 } |
976 return true; | 982 return true; |
977 } | 983 } |
OLD | NEW |