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