OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBitmapProvider.h" | 8 #include "SkBitmapProvider.h" |
9 #include "SkImage_Base.h" | 9 #include "SkImage_Base.h" |
10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 bool SkBitmapProvider::validForDrawing() const { | 24 bool SkBitmapProvider::validForDrawing() const { |
25 if (!fImage) { | 25 if (!fImage) { |
26 if (0 == fBitmap.width() || 0 == fBitmap.height()) { | 26 if (0 == fBitmap.width() || 0 == fBitmap.height()) { |
27 return false; | 27 return false; |
28 } | 28 } |
29 if (nullptr == fBitmap.pixelRef()) { | 29 if (nullptr == fBitmap.pixelRef()) { |
30 return false; // no pixels to read | 30 return false; // no pixels to read |
31 } | 31 } |
32 if (fBitmap.getTexture()) { | |
33 // we can handle texture (ugh) since lockPixels will perform a read-
back | |
34 return true; | |
35 } | |
36 if (kIndex_8_SkColorType == fBitmap.colorType()) { | 32 if (kIndex_8_SkColorType == fBitmap.colorType()) { |
37 SkAutoLockPixels alp(fBitmap); // but we need to call it before getC
olorTable() is safe. | 33 SkAutoLockPixels alp(fBitmap); // but we need to call it before getC
olorTable() is safe. |
38 if (!fBitmap.getColorTable()) { | 34 if (!fBitmap.getColorTable()) { |
39 return false; | 35 return false; |
40 } | 36 } |
41 } | 37 } |
42 } | 38 } |
43 return true; | 39 return true; |
44 } | 40 } |
45 | 41 |
(...skipping 30 matching lines...) Expand all Loading... |
76 } | 72 } |
77 | 73 |
78 bool SkBitmapProvider::asBitmap(SkBitmap* bm) const { | 74 bool SkBitmapProvider::asBitmap(SkBitmap* bm) const { |
79 if (fImage) { | 75 if (fImage) { |
80 return as_IB(fImage)->getROPixels(bm, SkImage::kAllow_CachingHint); | 76 return as_IB(fImage)->getROPixels(bm, SkImage::kAllow_CachingHint); |
81 } else { | 77 } else { |
82 *bm = fBitmap; | 78 *bm = fBitmap; |
83 return true; | 79 return true; |
84 } | 80 } |
85 } | 81 } |
OLD | NEW |