Revert "resources: remove most uses of GetResourcePath()"
This reverts commit 5093a539def3ae09df324018f2343827009b2e05.
Reason for revert: google3 seems broken
Original change's description:
> resources: remove most uses of GetResourcePath()
>
> Going forward, we will standardize on GetResourceAsData(), which will
> make it easier to run tests in environments without access to the
> filesystem.
>
> Also: GetResourceAsData() complains when a resource is missing.
> This is usually an error.
>
> Change-Id: Iaf70b71b0ca5ed8cd1a5538a60ef185ae8736188
> Reviewed-on: https://skia-review.googlesource.com/82642
> Reviewed-by: Hal Canary <halcanary@google.com>
> Commit-Queue: Hal Canary <halcanary@google.com>
TBR=halcanary@google.com,scroggo@google.com
Change-Id: Ic5a7c0167c995a672e6b06dc92abe00564432214
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/83001
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/samplecode/SampleCowboy.cpp b/samplecode/SampleCowboy.cpp
index bd8f7c9..b1eec87 100644
--- a/samplecode/SampleCowboy.cpp
+++ b/samplecode/SampleCowboy.cpp
@@ -37,13 +37,12 @@
};
void onOnceBeforeDraw() override {
- constexpr char path[] = "Cowboy.svg";
- auto data = GetResourceAsData(path);
- if (!data) {
- SkDebugf("file not found: \"%s\"\n", path);
+ fPath = GetResourcePath("Cowboy.svg");
+ SkFILEStream svgStream(fPath.c_str());
+ if (!svgStream.isValid()) {
+ SkDebugf("file not found: \"path\"\n", fPath.c_str());
return;
}
- SkMemoryStream svgStream(std::move(data));
SkDOM xmlDom;
if (!xmlDom.build(svgStream)) {
diff --git a/samplecode/SampleIdentityScale.cpp b/samplecode/SampleIdentityScale.cpp
index ad23541..2ec9112 100644
--- a/samplecode/SampleIdentityScale.cpp
+++ b/samplecode/SampleIdentityScale.cpp
@@ -25,10 +25,11 @@
class IdentityScaleView : public SampleView {
public:
IdentityScaleView(const char imageFilename[]) {
- if (!DecodeDataToBitmap(GetResourceAsData(imageFilename), &fBM)) {
- fBM.allocN32Pixels(1, 1);
- *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
- }
+ SkString resourcePath = GetResourcePath(imageFilename);
+ if (!decode_file(resourcePath.c_str(), &fBM)) {
+ fBM.allocN32Pixels(1, 1);
+ *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
+ }
}
protected:
diff --git a/samplecode/SampleSubpixelTranslate.cpp b/samplecode/SampleSubpixelTranslate.cpp
index 7ce1885..51b5ef6 100644
--- a/samplecode/SampleSubpixelTranslate.cpp
+++ b/samplecode/SampleSubpixelTranslate.cpp
@@ -24,15 +24,15 @@
SubpixelTranslateView(const char imageFilename[],
float horizontalVelocity,
float verticalVelocity)
- : fHorizontalVelocity(horizontalVelocity)
- , fVerticalVelocity(verticalVelocity)
- {
- if (!DecodeDataToBitmap(GetResourceAsData(imageFilename), &fBM)) {
- fBM.allocN32Pixels(1, 1);
- *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
- }
- fCurPos = SkPoint::Make(0,0);
- fSize = 200;
+ : fHorizontalVelocity(horizontalVelocity),
+ fVerticalVelocity(verticalVelocity) {
+ SkString resourcePath = GetResourcePath(imageFilename);
+ if (!decode_file(resourcePath.c_str(), &fBM)) {
+ fBM.allocN32Pixels(1, 1);
+ *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
+ }
+ fCurPos = SkPoint::Make(0,0);
+ fSize = 200;
}
protected: