aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/VisualBench/VisualBenchmarkStream.cpp17
-rw-r--r--tools/VisualBench/VisualBenchmarkStream.h2
-rw-r--r--tools/dump_record.cpp4
-rw-r--r--tools/get_images_from_skps.cpp2
-rw-r--r--tools/gpuveto.cpp6
-rw-r--r--tools/kilobench/kilobench.cpp17
-rw-r--r--tools/lua/lua_pictures.cpp9
-rw-r--r--tools/pinspect.cpp8
-rw-r--r--tools/skiaserve/Request.cpp6
-rw-r--r--tools/skiaserve/Request.h2
-rw-r--r--tools/skpmaker.cpp3
11 files changed, 34 insertions, 42 deletions
diff --git a/tools/VisualBench/VisualBenchmarkStream.cpp b/tools/VisualBench/VisualBenchmarkStream.cpp
index e0d02f2b97..b15ac7e8f1 100644
--- a/tools/VisualBench/VisualBenchmarkStream.cpp
+++ b/tools/VisualBench/VisualBenchmarkStream.cpp
@@ -104,25 +104,24 @@ VisualBenchmarkStream::VisualBenchmarkStream(const SkSurfaceProps& surfaceProps,
this->next();
}
-bool VisualBenchmarkStream::ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
+sk_sp<SkPicture> VisualBenchmarkStream::ReadPicture(const char path[]) {
// Not strictly necessary, as it will be checked again later,
// but helps to avoid a lot of pointless work if we're going to skip it.
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) {
- return false;
+ return nullptr;
}
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
if (stream.get() == nullptr) {
SkDebugf("Could not read %s.\n", path);
- return false;
+ return nullptr;
}
- pic->reset(SkPicture::CreateFromStream(stream.get()));
- if (pic->get() == nullptr) {
+ auto pic = SkPicture::MakeFromStream(stream.get());
+ if (!pic) {
SkDebugf("Could not read %s as an SkPicture.\n", path);
- return false;
}
- return true;
+ return pic;
}
Benchmark* VisualBenchmarkStream::next() {
@@ -175,8 +174,8 @@ Benchmark* VisualBenchmarkStream::innerNext() {
// Render skps
while (fCurrentSKP < fSKPs.count()) {
const SkString& path = fSKPs[fCurrentSKP++];
- SkAutoTUnref<SkPicture> pic;
- if (!ReadPicture(path.c_str(), &pic)) {
+ sk_sp<SkPicture> pic = ReadPicture(path.c_str());
+ if (!pic) {
continue;
}
diff --git a/tools/VisualBench/VisualBenchmarkStream.h b/tools/VisualBench/VisualBenchmarkStream.h
index b1fd0f08c7..71b6c972f2 100644
--- a/tools/VisualBench/VisualBenchmarkStream.h
+++ b/tools/VisualBench/VisualBenchmarkStream.h
@@ -20,7 +20,7 @@ class VisualBenchmarkStream {
public:
VisualBenchmarkStream(const SkSurfaceProps&, bool justSKP = false);
- static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic);
+ static sk_sp<SkPicture> ReadPicture(const char* path);
Benchmark* next();
Benchmark* current() { return fBenchmark.get(); }
diff --git a/tools/dump_record.cpp b/tools/dump_record.cpp
index 96b893735b..52f8f8c0b8 100644
--- a/tools/dump_record.cpp
+++ b/tools/dump_record.cpp
@@ -49,7 +49,7 @@ int tool_main(int argc, char** argv) {
SkDebugf("Could not read %s.\n", FLAGS_skps[i]);
return 1;
}
- SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream));
+ sk_sp<SkPicture> src(SkPicture::MakeFromStream(stream));
if (!src) {
SkDebugf("Could not read %s as an SkPicture.\n", FLAGS_skps[i]);
return 1;
@@ -79,7 +79,7 @@ int tool_main(int argc, char** argv) {
0,
nullptr,
nullptr);
- SkAutoTUnref<SkPicture> dst(r.endRecording());
+ sk_sp<SkPicture> dst(r.finishRecordingAsPicture());
SkFILEWStream ostream(FLAGS_write[0]);
dst->serialize(&ostream);
}
diff --git a/tools/get_images_from_skps.cpp b/tools/get_images_from_skps.cpp
index 7d0854d4d4..e6bb6e2012 100644
--- a/tools/get_images_from_skps.cpp
+++ b/tools/get_images_from_skps.cpp
@@ -90,7 +90,7 @@ int main(int argc, char** argv) {
for (SkString file; iter.next(&file); ) {
SkAutoTDelete<SkStream> stream =
SkStream::NewFromFile(SkOSPath::Join(inputs, file.c_str()).c_str());
- SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(stream));
+ sk_sp<SkPicture> picture(SkPicture::MakeFromStream(stream));
SkDynamicMemoryWStream scratch;
Sniffer sniff;
diff --git a/tools/gpuveto.cpp b/tools/gpuveto.cpp
index f2e103e1e3..41ca0c8dd3 100644
--- a/tools/gpuveto.cpp
+++ b/tools/gpuveto.cpp
@@ -41,8 +41,8 @@ int tool_main(int argc, char** argv) {
return kError;
}
- SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream));
- if (nullptr == picture.get()) {
+ sk_sp<SkPicture> picture(SkPicture::MakeFromStream(&inputStream));
+ if (nullptr == picture) {
if (!FLAGS_quiet) {
SkDebugf("Could not read the SkPicture\n");
}
@@ -55,7 +55,7 @@ int tool_main(int argc, char** argv) {
picture->playback(recorder.beginRecording(picture->cullRect().width(),
picture->cullRect().height(),
nullptr, 0));
- SkAutoTUnref<SkPicture> recorded(recorder.endRecording());
+ sk_sp<SkPicture> recorded(recorder.finishRecordingAsPicture());
if (recorded->suitableForGpuRasterization(nullptr)) {
SkDebugf("suitable\n");
diff --git a/tools/kilobench/kilobench.cpp b/tools/kilobench/kilobench.cpp
index 1f92d5341a..06cb33fb49 100644
--- a/tools/kilobench/kilobench.cpp
+++ b/tools/kilobench/kilobench.cpp
@@ -104,33 +104,28 @@ public:
}
private:
- static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
+ static sk_sp<SkPicture> ReadPicture(const char path[]) {
// Not strictly necessary, as it will be checked again later,
// but helps to avoid a lot of pointless work if we're going to skip it.
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) {
- return false;
+ return nullptr;
}
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
if (stream.get() == nullptr) {
SkDebugf("Could not read %s.\n", path);
- return false;
+ return nullptr;
}
- pic->reset(SkPicture::CreateFromStream(stream.get()));
- if (pic->get() == nullptr) {
- SkDebugf("Could not read %s as an SkPicture.\n", path);
- return false;
- }
- return true;
+ return SkPicture::MakeFromStream(stream.get());
}
Benchmark* innerNext() {
// Render skps
while (fCurrentSKP < fSKPs.count()) {
const SkString& path = fSKPs[fCurrentSKP++];
- SkAutoTUnref<SkPicture> pic;
- if (!ReadPicture(path.c_str(), &pic)) {
+ auto pic = ReadPicture(path.c_str());
+ if (!pic) {
continue;
}
diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp
index c526406f1c..0edea2576e 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -38,13 +38,12 @@ DEFINE_string2(headCode, s, "", "Optional lua code to call at beginning");
DEFINE_string2(tailFunc, s, "", "Optional lua function to call at end");
DEFINE_bool2(quiet, q, false, "Silence all non-error related output");
-static SkPicture* load_picture(const char path[]) {
+static sk_sp<SkPicture> load_picture(const char path[]) {
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
- SkPicture* pic = nullptr;
if (stream.get()) {
- pic = SkPicture::CreateFromStream(stream.get());
+ return SkPicture::MakeFromStream(stream.get());
}
- return pic;
+ return nullptr;
}
static void call_canvas(lua_State* L, SkLuaCanvas* canvas,
@@ -143,7 +142,7 @@ int tool_main(int argc, char** argv) {
SkDebugf("scraping %s %s\n", path, moduloStr.c_str());
}
- SkAutoTUnref<SkPicture> pic(load_picture(path));
+ auto pic(load_picture(path));
if (pic.get()) {
SkAutoTUnref<SkLuaCanvas> canvas(
new SkLuaCanvas(SkScalarCeilToInt(pic->cullRect().width()),
diff --git a/tools/pinspect.cpp b/tools/pinspect.cpp
index 419b2ab5d5..1cbc2e19c3 100644
--- a/tools/pinspect.cpp
+++ b/tools/pinspect.cpp
@@ -14,7 +14,7 @@
#include "SkString.h"
#include "SkDumpCanvas.h"
-static SkPicture* inspect(const char path[]) {
+static sk_sp<SkPicture> inspect(const char path[]) {
SkFILEStream stream(path);
if (!stream.isValid()) {
printf("-- Can't open '%s'\n", path);
@@ -33,7 +33,7 @@ static SkPicture* inspect(const char path[]) {
}
stream.rewind();
- SkPicture* pic = SkPicture::CreateFromStream(&stream);
+ auto pic = SkPicture::MakeFromStream(&stream);
if (nullptr == pic) {
SkDebugf("Could not create SkPicture: %s\n", path);
return nullptr;
@@ -71,9 +71,9 @@ int tool_main(int argc, char** argv) {
}
for (; index < argc; ++index) {
- SkAutoTUnref<SkPicture> pic(inspect(argv[index]));
+ auto pic(inspect(argv[index]));
if (doDumpOps) {
- dumpOps(pic);
+ dumpOps(pic.get());
}
if (index < argc - 1) {
printf("\n");
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index e0aad15aad..8627dd678e 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -131,7 +131,7 @@ SkData* Request::writeOutSkp() {
fDebugCanvas->draw(canvas);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkDynamicMemoryWStream outStream;
@@ -215,8 +215,8 @@ bool Request::enableGPU(bool enable) {
bool Request::initPictureFromStream(SkStream* stream) {
// parse picture from stream
- fPicture.reset(SkPicture::CreateFromStream(stream));
- if (!fPicture.get()) {
+ fPicture = SkPicture::MakeFromStream(stream);
+ if (!fPicture) {
fprintf(stderr, "Could not create picture from stream.\n");
return false;
}
diff --git a/tools/skiaserve/Request.h b/tools/skiaserve/Request.h
index 52ebf25c2f..eecfe33571 100644
--- a/tools/skiaserve/Request.h
+++ b/tools/skiaserve/Request.h
@@ -68,7 +68,7 @@ private:
SkIRect getBounds();
GrContext* getContext();
- SkAutoTUnref<SkPicture> fPicture;
+ sk_sp<SkPicture> fPicture;
GrContextFactory* fContextFactory;
SkAutoTUnref<SkSurface> fSurface;
bool fGPUEnabled;
diff --git a/tools/skpmaker.cpp b/tools/skpmaker.cpp
index 8fa969a6f0..99e6adf997 100644
--- a/tools/skpmaker.cpp
+++ b/tools/skpmaker.cpp
@@ -41,9 +41,8 @@ static void make_skp(SkScalar width, SkScalar height, SkScalar border, SkColor c
paint.setColor(color);
r.inset(border, border);
canvas->drawRect(r, paint);
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
SkFILEWStream stream(writePath);
- pict->serialize(&stream);
+ recorder.finishRecordingAsPicture()->serialize(&stream);
}
int tool_main(int argc, char** argv);