1/* 2 * Copyright 2015 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#include "SkBitmapProvider.h" 9#include "SkImage_Base.h" 10#include "SkPixelRef.h" 11 12int SkBitmapProvider::width() const { 13 return fImage->width(); 14} 15 16int SkBitmapProvider::height() const { 17 return fImage->height(); 18} 19 20uint32_t SkBitmapProvider::getID() const { 21 return fImage->uniqueID(); 22} 23 24SkImageInfo SkBitmapProvider::info() const { 25 return as_IB(fImage)->onImageInfo(); 26} 27 28bool SkBitmapProvider::isVolatile() const { 29 // add flag to images? 30 const SkBitmap* bm = as_IB(fImage)->onPeekBitmap(); 31 return bm ? bm->isVolatile() : false; 32} 33 34SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc(int w, int h) const { 35 return SkBitmapCacheDesc::Make(fImage, w, h); 36} 37 38SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc() const { 39 return SkBitmapCacheDesc::Make(fImage); 40} 41 42void SkBitmapProvider::notifyAddedToCache() const { 43 as_IB(fImage)->notifyAddedToCache(); 44} 45 46bool SkBitmapProvider::asBitmap(SkBitmap* bm) const { 47 return as_IB(fImage)->getROPixels(bm, fDstColorSpace, SkImage::kAllow_CachingHint); 48} 49