91359bed48
Reason for revert: Some benchmarks are written in a way that makes this change unsafe (e.g. const char* resPath = GetResourcePath().c_str(); in SkipZeroesBench) and Valgrind and ASAN caught that. We can try again after a more careful cleanup of GetResourcePath(). Original issue's description: > Clean up resourcePath code. > > 1) Make the implementation of SetResourcePath/GetResourcePath of GM and SkBenchmark match with the one in Test. > 2) Make gResourcePath a static pointer to const char and move it inside the classes. > > BUG=None > TEST=make tests && out/Debug/tests > make gm && out/Debug/gm > make bench && out/Debug/bench > R=mtklein@google.com > > Committed: https://skia.googlesource.com/skia/+/52e4f413ffe2d281f9e90ff2147db08083ffcba7 R=tfarina@chromium.org TBR=tfarina@chromium.org NOTREECHECKS=true NOTRY=true BUG=None Author: mtklein@google.com Review URL: https://codereview.chromium.org/320733002
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "gm.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkImageDecoder.h"
|
|
#include "SkOSFile.h"
|
|
|
|
namespace skiagm {
|
|
|
|
/**
|
|
* Test copying an image from 8888 to 4444.
|
|
*/
|
|
class CopyTo4444GM : public GM {
|
|
public:
|
|
CopyTo4444GM() {}
|
|
|
|
protected:
|
|
virtual SkString onShortName() {
|
|
return SkString("copyTo4444");
|
|
}
|
|
|
|
virtual SkISize onISize() {
|
|
return make_isize(1024, 512);
|
|
}
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
SkBitmap bm, bm4444;
|
|
SkString filename = SkOSPath::SkPathJoin(
|
|
INHERITED::gResourcePath.c_str(), "mandrill_512.png");
|
|
if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm,
|
|
SkBitmap::kARGB_8888_Config,
|
|
SkImageDecoder::kDecodePixels_Mode)) {
|
|
SkDebugf("Could not decode the file. Did you forget to set the "
|
|
"resourcePath?\n");
|
|
return;
|
|
}
|
|
canvas->drawBitmap(bm, 0, 0);
|
|
SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType));
|
|
canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0);
|
|
}
|
|
|
|
private:
|
|
typedef GM INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
static GM* MyFactory(void*) { return new CopyTo4444GM; }
|
|
static GMRegistry reg(MyFactory);
|
|
|
|
}
|