OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrTextureStripAtlas.h" | 9 #include "GrTextureStripAtlas.h" |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 row->fKey = key; | 151 row->fKey = key; |
152 row->fLocks = 1; | 152 row->fLocks = 1; |
153 fKeyTable.insert(index, 1, &row); | 153 fKeyTable.insert(index, 1, &row); |
154 rowNumber = static_cast<int>(row - fRows); | 154 rowNumber = static_cast<int>(row - fRows); |
155 | 155 |
156 SkAutoLockPixels lock(data); | 156 SkAutoLockPixels lock(data); |
157 | 157 |
158 // Pass in the kDontFlush flag, since we know we're writing to a part of
this texture | 158 // Pass in the kDontFlush flag, since we know we're writing to a part of
this texture |
159 // that is not currently in use | 159 // that is not currently in use |
160 fTexture->writePixels(0, rowNumber * fDesc.fRowHeight, | 160 fTexture->writePixels(NULL, 0, rowNumber * fDesc.fRowHeight, |
161 fDesc.fWidth, fDesc.fRowHeight, | 161 fDesc.fWidth, fDesc.fRowHeight, |
162 SkImageInfo2GrPixelConfig(data.info()), | 162 SkImageInfo2GrPixelConfig(data.info()), |
163 data.getPixels(), | 163 data.getPixels(), |
164 data.rowBytes(), | 164 data.rowBytes(), |
165 GrContext::kDontFlush_PixelOpsFlag); | 165 GrContext::kDontFlush_PixelOpsFlag); |
166 } | 166 } |
167 | 167 |
168 SkASSERT(rowNumber >= 0); | 168 SkASSERT(rowNumber >= 0); |
169 VALIDATE; | 169 VALIDATE; |
170 return rowNumber; | 170 return rowNumber; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 builder[0] = static_cast<uint32_t>(fCacheKey); | 202 builder[0] = static_cast<uint32_t>(fCacheKey); |
203 builder.finish(); | 203 builder.finish(); |
204 | 204 |
205 fTexture = fDesc.fContext->textureProvider()->findAndRefTextureByUniqueKey(k
ey); | 205 fTexture = fDesc.fContext->textureProvider()->findAndRefTextureByUniqueKey(k
ey); |
206 if (nullptr == fTexture) { | 206 if (nullptr == fTexture) { |
207 fTexture = fDesc.fContext->textureProvider()->createTexture(texDesc, tru
e, nullptr, 0); | 207 fTexture = fDesc.fContext->textureProvider()->createTexture(texDesc, tru
e, nullptr, 0); |
208 if (!fTexture) { | 208 if (!fTexture) { |
209 return; | 209 return; |
210 } | 210 } |
211 fDesc.fContext->textureProvider()->assignUniqueKeyToTexture(key, fTextur
e); | 211 fDesc.fContext->textureProvider()->assignUniqueKeyToTexture(key, fTextur
e); |
| 212 fTexture->setFromRawPixels(true); |
212 // This is a new texture, so all of our cache info is now invalid | 213 // This is a new texture, so all of our cache info is now invalid |
213 this->initLRU(); | 214 this->initLRU(); |
214 fKeyTable.rewind(); | 215 fKeyTable.rewind(); |
215 } | 216 } |
216 SkASSERT(fTexture); | 217 SkASSERT(fTexture); |
217 } | 218 } |
218 | 219 |
219 void GrTextureStripAtlas::unlockTexture() { | 220 void GrTextureStripAtlas::unlockTexture() { |
220 SkASSERT(fTexture && 0 == fLockedRows); | 221 SkASSERT(fTexture && 0 == fLockedRows); |
221 fTexture->unref(); | 222 fTexture->unref(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 343 |
343 // If we have locked rows, we should have a locked texture, otherwise | 344 // If we have locked rows, we should have a locked texture, otherwise |
344 // it should be unlocked | 345 // it should be unlocked |
345 if (fLockedRows == 0) { | 346 if (fLockedRows == 0) { |
346 SkASSERT(nullptr == fTexture); | 347 SkASSERT(nullptr == fTexture); |
347 } else { | 348 } else { |
348 SkASSERT(fTexture); | 349 SkASSERT(fTexture); |
349 } | 350 } |
350 } | 351 } |
351 #endif | 352 #endif |
OLD | NEW |