| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkPictureShader.h" | 8 #include "SkPictureShader.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 return sizeof(fKey) + sizeof(SkShader) + fBitmapBytes; | 76 return sizeof(fKey) + sizeof(SkShader) + fBitmapBytes; |
| 77 } | 77 } |
| 78 | 78 |
| 79 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextShader
) { | 79 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextShader
) { |
| 80 const BitmapShaderRec& rec = static_cast<const BitmapShaderRec&>(baseRec
); | 80 const BitmapShaderRec& rec = static_cast<const BitmapShaderRec&>(baseRec
); |
| 81 SkAutoTUnref<SkShader>* result = reinterpret_cast<SkAutoTUnref<SkShader>
*>(contextShader); | 81 SkAutoTUnref<SkShader>* result = reinterpret_cast<SkAutoTUnref<SkShader>
*>(contextShader); |
| 82 | 82 |
| 83 result->reset(SkRef(rec.fShader.get())); | 83 result->reset(SkRef(rec.fShader.get())); |
| 84 | 84 |
| 85 SkBitmap tile; | 85 SkBitmap tile; |
| 86 rec.fShader.get()->asABitmap(&tile, NULL, NULL); | 86 if (rec.fShader.get()->isABitmap(&tile, NULL, NULL)) { |
| 87 // FIXME: this doesn't protect the pixels from being discarded as soon a
s we unlock. | 87 // FIXME: this doesn't protect the pixels from being discarded as so
on as we unlock. |
| 88 // Should be handled via a pixel ref generator instead | 88 // Should be handled via a pixel ref generator instead |
| 89 // (https://code.google.com/p/skia/issues/detail?id=3220). | 89 // (https://code.google.com/p/skia/issues/detail?id=3220). |
| 90 SkAutoLockPixels alp(tile, true); | 90 SkAutoLockPixels alp(tile, true); |
| 91 return tile.getPixels() != NULL; | 91 return tile.getPixels() != NULL; |
| 92 } |
| 93 return false; |
| 92 } | 94 } |
| 93 }; | 95 }; |
| 94 | 96 |
| 95 static bool cache_try_alloc_pixels(SkBitmap* bitmap) { | 97 static bool cache_try_alloc_pixels(SkBitmap* bitmap) { |
| 96 SkBitmap::Allocator* allocator = SkResourceCache::GetAllocator(); | 98 SkBitmap::Allocator* allocator = SkResourceCache::GetAllocator(); |
| 97 | 99 |
| 98 return NULL != allocator | 100 return NULL != allocator |
| 99 ? allocator->allocPixelRef(bitmap, NULL) | 101 ? allocator->allocPixelRef(bitmap, NULL) |
| 100 : bitmap->tryAllocPixels(); | 102 : bitmap->tryAllocPixels(); |
| 101 } | 103 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 procDataManager, fp); | 352 procDataManager, fp); |
| 351 } | 353 } |
| 352 #else | 354 #else |
| 353 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, | 355 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, |
| 354 const SkMatrix*, GrColor*, GrProcessor
DataManager*, | 356 const SkMatrix*, GrColor*, GrProcessor
DataManager*, |
| 355 GrFragmentProcessor**) const { | 357 GrFragmentProcessor**) const { |
| 356 SkDEBUGFAIL("Should not call in GPU-less build"); | 358 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 357 return false; | 359 return false; |
| 358 } | 360 } |
| 359 #endif | 361 #endif |
| OLD | NEW |