skia2/gm/copyTo4444.cpp
Hal Canary c465d13e6f resources: orgainize directory.
Should make it easier to ask just for images.

Change-Id: If821743dc924c4bfbc6b2b2d29b14affde7b3afd
Reviewed-on: https://skia-review.googlesource.com/82684
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2017-12-08 17:16:00 +00:00

57 lines
1.3 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 "sk_tool_utils.h"
#include "Resources.h"
#include "SkCanvas.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 SkISize::Make(360, 180);
}
virtual void onDraw(SkCanvas* canvas) {
SkBitmap bm, bm4444;
if (!GetResourceAsBitmap("images/dog.jpg", &bm)) {
SkDebugf("Could not decode the file. Did you forget to set the "
"resourcePath?\n");
return;
}
canvas->drawBitmap(bm, 0, 0);
// This should dither or we will see artifacts in the background of the image.
SkAssertResult(sk_tool_utils::copy_to(&bm4444, kARGB_4444_SkColorType, bm));
canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0);
}
private:
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new CopyTo4444GM; }
static GMRegistry reg(MyFactory);
}