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

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

Issue 940323003: Revert of Make SkPixelRef::isLocked() debug-only, remove related dead code. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | « include/core/SkPixelRef.h ('k') | src/core/SkPixelRef.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkBitmapProcState.h" 9 #include "SkBitmapProcState.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // that here, and not need to explicitly track it ourselves. 236 // that here, and not need to explicitly track it ourselves.
237 fScaledBitmap.installPixels(info, level.fPixels, level.fRowBytes); 237 fScaledBitmap.installPixels(info, level.fPixels, level.fRowBytes);
238 fBitmap = &fScaledBitmap; 238 fBitmap = &fScaledBitmap;
239 } else { 239 } else {
240 // failed to extract, so release the mipmap 240 // failed to extract, so release the mipmap
241 fCurrMip.reset(NULL); 241 fCurrMip.reset(NULL);
242 } 242 }
243 } 243 }
244 } 244 }
245 245
246 static bool get_locked_pixels(const SkBitmap& src, int pow2, SkBitmap* dst) {
247 SkPixelRef* pr = src.pixelRef();
248 if (pr && pr->decodeInto(pow2, dst)) {
249 return true;
250 }
251
252 /*
253 * If decodeInto() fails, it is possibe that we have an old subclass that
254 * does not, or cannot, implement that. In that case we fall back to the
255 * older protocol of having the pixelRef handle the caching for us.
256 */
257 *dst = src;
258 dst->lockPixels();
259 return SkToBool(dst->getPixels());
260 }
261
246 bool SkBitmapProcState::lockBaseBitmap() { 262 bool SkBitmapProcState::lockBaseBitmap() {
247 // TODO(reed): use bitmap cache here? 263 SkPixelRef* pr = fOrigBitmap.pixelRef();
248 fScaledBitmap = fOrigBitmap; 264
249 fScaledBitmap.lockPixels(); 265 if (pr->isLocked() || !pr->implementsDecodeInto()) {
250 if (NULL == fScaledBitmap.getPixels()) { 266 // fast-case, no need to look in our cache
251 return false; 267 fScaledBitmap = fOrigBitmap;
268 fScaledBitmap.lockPixels();
269 if (NULL == fScaledBitmap.getPixels()) {
270 return false;
271 }
272 } else {
273 if (!SkBitmapCache::Find(fOrigBitmap, 1, 1, &fScaledBitmap)) {
274 if (!get_locked_pixels(fOrigBitmap, 0, &fScaledBitmap)) {
275 return false;
276 }
277
278 // TODO: if fScaled comes back at a different width/height than fOri g,
279 // we need to update the matrix we are using to sample from this guy .
280
281 SkBitmapCache::Add(fOrigBitmap, 1, 1, fScaledBitmap);
282 }
252 } 283 }
253 fBitmap = &fScaledBitmap; 284 fBitmap = &fScaledBitmap;
254 return true; 285 return true;
255 } 286 }
256 287
257 static bool valid_for_drawing(const SkBitmap& bm) { 288 static bool valid_for_drawing(const SkBitmap& bm) {
258 if (0 == bm.width() || 0 == bm.height()) { 289 if (0 == bm.width() || 0 == bm.height()) {
259 return false; // nothing to draw 290 return false; // nothing to draw
260 } 291 }
261 if (NULL == bm.pixelRef()) { 292 if (NULL == bm.pixelRef()) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX()); 382 fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX());
352 fInvKy = SkScalarToFixed(fInvMatrix.getSkewY()); 383 fInvKy = SkScalarToFixed(fInvMatrix.getSkewY());
353 fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY()); 384 fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY());
354 385
355 fAlphaScale = SkAlpha255To256(paint.getAlpha()); 386 fAlphaScale = SkAlpha255To256(paint.getAlpha());
356 387
357 fShaderProc32 = NULL; 388 fShaderProc32 = NULL;
358 fShaderProc16 = NULL; 389 fShaderProc16 = NULL;
359 fSampleProc32 = NULL; 390 fSampleProc32 = NULL;
360 fSampleProc16 = NULL; 391 fSampleProc16 = NULL;
361 392
362 // recompute the triviality of the matrix here because we may have 393 // recompute the triviality of the matrix here because we may have
363 // changed it! 394 // changed it!
364 395
365 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; 396 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
366 397
367 if (SkPaint::kLow_FilterLevel == fFilterLevel) { 398 if (SkPaint::kLow_FilterLevel == fFilterLevel) {
368 // Only try bilerp if the matrix is "interesting" and 399 // Only try bilerp if the matrix is "interesting" and
369 // the image has a suitable size. 400 // the image has a suitable size.
370 401
371 if (fInvType <= SkMatrix::kTranslate_Mask || 402 if (fInvType <= SkMatrix::kTranslate_Mask ||
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 & & clampClamp) { 556 } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 & & clampClamp) {
526 fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shad erproc); 557 fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shad erproc);
527 } else if (S32_opaque_D32_nofilter_DX == fSampleProc32 && clampClamp) { 558 } else if (S32_opaque_D32_nofilter_DX == fSampleProc32 && clampClamp) {
528 fShaderProc32 = Clamp_S32_opaque_D32_nofilter_DX_shaderproc; 559 fShaderProc32 = Clamp_S32_opaque_D32_nofilter_DX_shaderproc;
529 } 560 }
530 561
531 if (NULL == fShaderProc32) { 562 if (NULL == fShaderProc32) {
532 fShaderProc32 = this->chooseShaderProc32(); 563 fShaderProc32 = this->chooseShaderProc32();
533 } 564 }
534 } 565 }
535 566
536 // see if our platform has any accelerated overrides 567 // see if our platform has any accelerated overrides
537 this->platformProcs(); 568 this->platformProcs();
538 569
539 return true; 570 return true;
540 } 571 }
541 572
542 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, 573 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
543 int x, int y, 574 int x, int y,
544 SkPMColor* SK_RESTRICT color s, 575 SkPMColor* SK_RESTRICT color s,
545 int count) { 576 int count) {
546 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); 577 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0);
547 SkASSERT(s.fInvKy == 0); 578 SkASSERT(s.fInvKy == 0);
548 SkASSERT(count > 0 && colors != NULL); 579 SkASSERT(count > 0 && colors != NULL);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 fx += dx; 1035 fx += dx;
1005 } 1036 }
1006 } else { 1037 } else {
1007 for (int i = 0; i < count; ++i) { 1038 for (int i = 0; i < count; ++i) {
1008 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; 1039 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)];
1009 fx += dx; 1040 fx += dx;
1010 } 1041 }
1011 } 1042 }
1012 } 1043 }
1013 1044
OLDNEW
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/core/SkPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698