skia2/tools/viewer/SKPSlide.h
Chris Dalton f3242c44cf Add an skp loader to CanvasKit viewer
The new loader works by checking for a "slide" flag, and if it ends in
".skp", then we treat the slide name as a URL and try to pull it in with
an HTTP request and parse it as an SkPicture.

It is the user's responsibility to copy or link skps into their
canvaskit server directory.

Change-Id: Iaafa84300d36d2d5a0bb29c47761ec67076c0f50
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292204
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2020-05-28 17:29:28 +00:00

33 lines
770 B
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SKPSlide_DEFINED
#define SKPSlide_DEFINED
#include "include/core/SkPicture.h"
#include "tools/viewer/Slide.h"
class SKPSlide : public Slide {
public:
SKPSlide(const SkString& name, const SkString& path);
SKPSlide(const SkString& name, std::unique_ptr<SkStream>);
~SKPSlide() override;
SkISize getDimensions() const override { return fCullRect.size(); }
void draw(SkCanvas* canvas) override;
void load(SkScalar winWidth, SkScalar winHeight) override;
void unload() override;
private:
std::unique_ptr<SkStream> fStream;
sk_sp<const SkPicture> fPic;
SkIRect fCullRect;
};
#endif