1 /* 2 * Copyright 2016 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 "ImageSlide.h" 9 10 #include "SkCanvas.h" 11 #include "SkData.h" 12 #include "SkImage.h" 13 ImageSlide(const SkString & name,const SkString & path)14ImageSlide::ImageSlide(const SkString& name, const SkString& path) : fPath(path) { 15 fName = name; 16 } 17 getDimensions() const18SkISize ImageSlide::getDimensions() const { 19 return fImage ? fImage->dimensions() : SkISize::Make(0, 0); 20 } 21 draw(SkCanvas * canvas)22void ImageSlide::draw(SkCanvas* canvas) { 23 SkASSERT(fImage); 24 canvas->drawImage(fImage, 0, 0); 25 } 26 load(SkScalar,SkScalar)27void ImageSlide::load(SkScalar, SkScalar) { 28 sk_sp<SkData> encoded = SkData::MakeFromFileName(fPath.c_str()); 29 fImage = SkImage::MakeFromEncoded(encoded); 30 } 31 unload()32void ImageSlide::unload() { 33 fImage.reset(nullptr); 34 } 35