OLD | NEW |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 static bool valid_for_drawing(const SkBitmap& bm) { | 87 static bool valid_for_drawing(const SkBitmap& bm) { |
88 if (0 == bm.width() || 0 == bm.height()) { | 88 if (0 == bm.width() || 0 == bm.height()) { |
89 return false; // nothing to draw | 89 return false; // nothing to draw |
90 } | 90 } |
91 if (NULL == bm.pixelRef()) { | 91 if (NULL == bm.pixelRef()) { |
92 return false; // no pixels to read | 92 return false; // no pixels to read |
93 } | 93 } |
94 if (kIndex_8_SkColorType == bm.colorType()) { | 94 if (kIndex_8_SkColorType == bm.colorType()) { |
95 // ugh, I have to lock-pixels to inspect the colortable | 95 SkBitmap copy(bm); // Locking and unlocking pixels is not threa
d safe, |
96 SkAutoLockPixels alp(bm); | 96 SkAutoLockPixels alp(copy); // but we need to call it before getColorTab
le() is safe. |
97 if (!bm.getColorTable()) { | 97 if (!copy.getColorTable()) { |
98 return false; | 98 return false; |
99 } | 99 } |
100 } | 100 } |
101 return true; | 101 return true; |
102 } | 102 } |
103 | 103 |
104 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo
id* storage) const { | 104 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo
id* storage) const { |
105 if (!fRawBitmap.getTexture() && !valid_for_drawing(fRawBitmap)) { | 105 if (!fRawBitmap.getTexture() && !valid_for_drawing(fRawBitmap)) { |
106 return NULL; | 106 return NULL; |
107 } | 107 } |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 474 |
475 #else | 475 #else |
476 | 476 |
477 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S
kMatrix*, GrColor*, | 477 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S
kMatrix*, GrColor*, |
478 GrFragmentProcessor**) const { | 478 GrFragmentProcessor**) const { |
479 SkDEBUGFAIL("Should not call in GPU-less build"); | 479 SkDEBUGFAIL("Should not call in GPU-less build"); |
480 return false; | 480 return false; |
481 } | 481 } |
482 | 482 |
483 #endif | 483 #endif |
OLD | NEW |