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

Side by Side Diff: src/core/SkBitmapProcShader.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 | « no previous file | src/core/SkBitmapProcState.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 static bool only_scale_and_translate(const SkMatrix& matrix) { 78 static bool only_scale_and_translate(const SkMatrix& matrix) {
79 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; 79 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask;
80 return (matrix.getType() & ~mask) == 0; 80 return (matrix.getType() & ~mask) == 0;
81 } 81 }
82 82
83 bool SkBitmapProcShader::isOpaque() const { 83 bool SkBitmapProcShader::isOpaque() const {
84 return fRawBitmap.isOpaque(); 84 return fRawBitmap.isOpaque();
85 } 85 }
86 86
87 static bool valid_for_drawing(const SkBitmap& bm) {
88 if (0 == bm.width() || 0 == bm.height()) {
89 return false; // nothing to draw
90 }
91 if (NULL == bm.pixelRef()) {
92 return false; // no pixels to read
93 }
94 if (kIndex_8_SkColorType == bm.colorType()) {
95 SkBitmap copy(bm); // Locking and unlocking pixels is not threa d safe,
96 SkAutoLockPixels alp(copy); // but we need to call it before getColorTab le() is safe.
97 if (!copy.getColorTable()) {
98 return false;
99 }
100 }
101 return true;
102 }
103
104 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo id* storage) const { 87 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo id* storage) const {
105 if (!fRawBitmap.getTexture() && !valid_for_drawing(fRawBitmap)) {
106 return NULL;
107 }
108
109 SkMatrix totalInverse; 88 SkMatrix totalInverse;
110 // Do this first, so we know the matrix can be inverted. 89 // Do this first, so we know the matrix can be inverted.
111 if (!this->computeTotalInverse(rec, &totalInverse)) { 90 if (!this->computeTotalInverse(rec, &totalInverse)) {
112 return NULL; 91 return NULL;
113 } 92 }
114 93
115 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); 94 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext);
116 SkBitmapProcState* state = SkNEW_PLACEMENT(stateStorage, SkBitmapProcState); 95 SkBitmapProcState* state = SkNEW_PLACEMENT(stateStorage, SkBitmapProcState);
117 96
118 SkASSERT(state); 97 SkASSERT(state);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 453
475 #else 454 #else
476 455
477 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S kMatrix*, GrColor*, 456 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S kMatrix*, GrColor*,
478 GrFragmentProcessor**) const { 457 GrFragmentProcessor**) const {
479 SkDEBUGFAIL("Should not call in GPU-less build"); 458 SkDEBUGFAIL("Should not call in GPU-less build");
480 return false; 459 return false;
481 } 460 }
482 461
483 #endif 462 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698