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 
width() const12 int SkBitmapProvider::width() const {
13     return fImage->width();
14 }
15 
height() const16 int SkBitmapProvider::height() const {
17     return fImage->height();
18 }
19 
getID() const20 uint32_t SkBitmapProvider::getID() const {
21     return fImage->uniqueID();
22 }
23 
info() const24 SkImageInfo SkBitmapProvider::info() const {
25     return as_IB(fImage)->onImageInfo();
26 }
27 
isVolatile() const28 bool SkBitmapProvider::isVolatile() const {
29     // add flag to images?
30     const SkBitmap* bm = as_IB(fImage)->onPeekBitmap();
31     return bm ? bm->isVolatile() : false;
32 }
33 
makeCacheDesc(int w,int h) const34 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc(int w, int h) const {
35     return SkBitmapCacheDesc::Make(fImage, w, h);
36 }
37 
makeCacheDesc() const38 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc() const {
39     return SkBitmapCacheDesc::Make(fImage);
40 }
41 
notifyAddedToCache() const42 void SkBitmapProvider::notifyAddedToCache() const {
43     as_IB(fImage)->notifyAddedToCache();
44 }
45 
asBitmap(SkBitmap * bm) const46 bool SkBitmapProvider::asBitmap(SkBitmap* bm) const {
47     return as_IB(fImage)->getROPixels(bm, fDstColorSpace, SkImage::kAllow_CachingHint);
48 }
49