Home | History | Annotate | Download | only in core
      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 
     12 int SkBitmapProvider::width() const {
     13     return fImage->width();
     14 }
     15 
     16 int SkBitmapProvider::height() const {
     17     return fImage->height();
     18 }
     19 
     20 uint32_t SkBitmapProvider::getID() const {
     21     return fImage->uniqueID();
     22 }
     23 
     24 SkImageInfo SkBitmapProvider::info() const {
     25     return as_IB(fImage)->onImageInfo();
     26 }
     27 
     28 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 
     34 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc(int w, int h) const {
     35     return SkBitmapCacheDesc::Make(fImage, w, h);
     36 }
     37 
     38 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc() const {
     39     return SkBitmapCacheDesc::Make(fImage);
     40 }
     41 
     42 void SkBitmapProvider::notifyAddedToCache() const {
     43     as_IB(fImage)->notifyAddedToCache();
     44 }
     45 
     46 bool SkBitmapProvider::asBitmap(SkBitmap* bm) const {
     47     return as_IB(fImage)->getROPixels(bm, fDstColorSpace, SkImage::kAllow_CachingHint);
     48 }
     49