From 537d9c0229b296a1b19f678432011d748d73cf18 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Tue, 30 Jan 2018 11:30:48 -0500 Subject: SkQP: remove skia_embed_resources option Motivation: delete unnecessary code. ResourceFactory.h provides a much more flexible way of fixing the same problem. Change-Id: Ib8a3ce25ce98e4f752dc1e7ce88eb9ceb95a4372 Reviewed-on: https://skia-review.googlesource.com/101920 Reviewed-by: Derek Sollenberger Commit-Queue: Hal Canary --- tools/Resources.cpp | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'tools/Resources.cpp') diff --git a/tools/Resources.cpp b/tools/Resources.cpp index 002d4111ae..0e343c4883 100644 --- a/tools/Resources.cpp +++ b/tools/Resources.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ -#include "BinaryAsset.h" +#include "ResourceFactory.h" #include "Resources.h" #include "SkBitmap.h" #include "SkCommandLineFlags.h" @@ -19,6 +19,8 @@ DEFINE_string2(resourcePath, i, "resources", "Directory with test resources: images, fonts, etc."); +sk_sp (*gResourceFactory)(const char*) = nullptr; + SkString GetResourcePath(const char* resource) { return SkOSPath::Join(FLAGS_resourcePath[0], resource); } @@ -27,7 +29,6 @@ void SetResourcePath(const char* resource) { FLAGS_resourcePath.set(0, resource); } - bool DecodeDataToBitmap(sk_sp data, SkBitmap* dst) { std::unique_ptr gen(SkImageGenerator::MakeFromEncoded(std::move(data))); return gen && dst->tryAllocPixels(gen->getInfo()) && @@ -41,36 +42,20 @@ std::unique_ptr GetResourceAsStream(const char* resource) { : nullptr; } -#ifdef SK_EMBED_RESOURCES - -#include "ResourceFactory.h" - -sk_sp (*gResourceFactory)(const char*) = nullptr; - -extern BinaryAsset gResources[]; - sk_sp GetResourceAsData(const char* resource) { if (gResourceFactory) { - return gResourceFactory(resource); - } - for (const BinaryAsset* ptr = gResources; ptr->name; ++ptr) { - if (0 == strcmp(resource, ptr->name)) { - return SkData::MakeWithoutCopy(ptr->data, ptr->len); + if (auto data = gResourceFactory(resource)) { + return data; } + SkDebugf("Resource \"%s\" not found.\n", resource); + SK_ABORT("missing resource"); + } + if (auto data = SkData::MakeFromFileName(GetResourcePath(resource).c_str())) { + return data; } SkDebugf("Resource \"%s\" not found.\n", resource); - SK_ABORT("missing resource"); return nullptr; } -#else -sk_sp GetResourceAsData(const char* resource) { - auto data = SkData::MakeFromFileName(GetResourcePath(resource).c_str()); - if (!data) { - SkDebugf("Resource \"%s\" not found.\n", resource); - } - return data; -} -#endif sk_sp MakeResourceAsTypeface(const char* resource) { std::unique_ptr stream(GetResourceAsStream(resource)); -- cgit v1.2.3