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 "SkImageCacherator.h" 11#include "SkPixelRef.h" 12 13int SkBitmapProvider::width() const { 14 return fImage->width(); 15} 16 17int SkBitmapProvider::height() const { 18 return fImage->height(); 19} 20 21uint32_t SkBitmapProvider::getID() const { 22 return fImage->uniqueID(); 23} 24 25SkImageInfo SkBitmapProvider::info() const { 26 return as_IB(fImage)->onImageInfo(); 27} 28 29bool SkBitmapProvider::isVolatile() const { 30 // add flag to images? 31 const SkBitmap* bm = as_IB(fImage)->onPeekBitmap(); 32 return bm ? bm->isVolatile() : false; 33} 34 35SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc(int w, int h) const { 36 return SkBitmapCacheDesc::Make(fImage, w, h); 37} 38 39SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc() const { 40 return SkBitmapCacheDesc::Make(fImage); 41} 42 43void SkBitmapProvider::notifyAddedToCache() const { 44 as_IB(fImage)->notifyAddedToCache(); 45} 46 47bool SkBitmapProvider::asBitmap(SkBitmap* bm) const { 48 return as_IB(fImage)->getROPixels(bm, fDstColorSpace, SkImage::kAllow_CachingHint); 49} 50