f5d1a5567e
Not sure if these simple Src/Dst interfaces will last. Vias are a little tricky, and some may be impossible. Change-Id: I42d19b1ee74b51a830bb781f25a888c0b32ba98c Reviewed-on: https://skia-review.googlesource.com/10174 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
34 lines
1.0 KiB
C++
34 lines
1.0 KiB
C++
/*
|
|
* Copyright 2017 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "ok.h"
|
|
#include "SkSurface.h"
|
|
|
|
struct SWDst : Dst {
|
|
sk_sp<SkSurface> surface;
|
|
|
|
static std::unique_ptr<Dst> Create(Options options, SkISize size) {
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height());
|
|
if (options("ct") == "565") { info = info.makeColorType(kRGB_565_SkColorType); }
|
|
if (options("ct") == "f16") { info = info.makeColorType(kRGBA_F16_SkColorType); }
|
|
SWDst dst;
|
|
dst.surface = SkSurface::MakeRaster(info);
|
|
return move_unique(dst);
|
|
}
|
|
|
|
SkCanvas* canvas() override {
|
|
return surface->getCanvas();
|
|
}
|
|
|
|
void write(std::string path_prefix) override {
|
|
auto image = surface->makeImageSnapshot();
|
|
sk_sp<SkData> png{image->encode()};
|
|
SkFILEWStream{(path_prefix + ".png").c_str()}.write(png->data(), png->size());
|
|
}
|
|
};
|
|
static Register sw{"sw", SWDst::Create};
|