2016-06-13 19:26:45 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/viewer/ImageSlide.h"
|
2016-06-13 19:26:45 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkData.h"
|
|
|
|
#include "include/core/SkImage.h"
|
2016-06-13 19:26:45 +00:00
|
|
|
|
|
|
|
ImageSlide::ImageSlide(const SkString& name, const SkString& path) : fPath(path) {
|
|
|
|
fName = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkISize ImageSlide::getDimensions() const {
|
|
|
|
return fImage ? fImage->dimensions() : SkISize::Make(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageSlide::draw(SkCanvas* canvas) {
|
2017-02-24 20:22:53 +00:00
|
|
|
SkASSERT(fImage);
|
2017-02-08 15:47:28 +00:00
|
|
|
canvas->drawImage(fImage, 0, 0);
|
2016-06-13 19:26:45 +00:00
|
|
|
}
|
|
|
|
|
2016-06-16 16:52:35 +00:00
|
|
|
void ImageSlide::load(SkScalar, SkScalar) {
|
2016-06-13 19:26:45 +00:00
|
|
|
sk_sp<SkData> encoded = SkData::MakeFromFileName(fPath.c_str());
|
2017-02-08 15:47:28 +00:00
|
|
|
fImage = SkImage::MakeFromEncoded(encoded);
|
2016-06-13 19:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImageSlide::unload() {
|
|
|
|
fImage.reset(nullptr);
|
|
|
|
}
|