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

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

Issue 766283004: check (thread-tricky) colortable after we've copied the bitmap into a per-thread context (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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/SkBitmapProcShader.cpp ('k') | no next file » | 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 317 }
318 } 318 }
319 fBitmap = &fScaledBitmap; 319 fBitmap = &fScaledBitmap;
320 return true; 320 return true;
321 } 321 }
322 322
323 SkBitmapProcState::~SkBitmapProcState() { 323 SkBitmapProcState::~SkBitmapProcState() {
324 SkDELETE(fBitmapFilter); 324 SkDELETE(fBitmapFilter);
325 } 325 }
326 326
327 static bool valid_for_drawing(const SkBitmap& bm) {
328 if (0 == bm.width() || 0 == bm.height()) {
329 return false; // nothing to draw
330 }
331 if (NULL == bm.pixelRef()) {
332 return false; // no pixels to read
333 }
334 if (bm.getTexture()) {
335 // we can handle texture (ugh) since lockPixels will perform a read-back
336 return true;
337 }
338 if (kIndex_8_SkColorType == bm.colorType()) {
339 SkAutoLockPixels alp(bm); // but we need to call it before getColorTable () is safe.
340 if (!bm.getColorTable()) {
341 return false;
342 }
343 }
344 return true;
345 }
346
327 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { 347 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
328 SkASSERT(fOrigBitmap.width() && fOrigBitmap.height()); 348 if (!valid_for_drawing(fOrigBitmap)) {
349 return false;
350 }
329 351
330 fBitmap = NULL; 352 fBitmap = NULL;
331 fInvMatrix = inv; 353 fInvMatrix = inv;
332 fFilterLevel = paint.getFilterLevel(); 354 fFilterLevel = paint.getFilterLevel();
333 355
334 // possiblyScaleImage will look to see if it can rescale the image as a 356 // possiblyScaleImage will look to see if it can rescale the image as a
335 // preprocess; either by scaling up to the target size, or by selecting 357 // preprocess; either by scaling up to the target size, or by selecting
336 // a nearby mipmap level. If it does, it will adjust the working 358 // a nearby mipmap level. If it does, it will adjust the working
337 // matrix as well as the working bitmap. It may also adjust the filter 359 // matrix as well as the working bitmap. It may also adjust the filter
338 // quality to avoid re-filtering an already perfectly scaled image. 360 // quality to avoid re-filtering an already perfectly scaled image.
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 fx += dx; 1084 fx += dx;
1063 } 1085 }
1064 } else { 1086 } else {
1065 for (int i = 0; i < count; ++i) { 1087 for (int i = 0; i < count; ++i) {
1066 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; 1088 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)];
1067 fx += dx; 1089 fx += dx;
1068 } 1090 }
1069 } 1091 }
1070 } 1092 }
1071 1093
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698