skia2/gm/cmykjpeg.cpp
rmistry 465206af18 Add missing SK_OVERRIDE
Tested by running on clang head + ubuntu 14.04:
GYP_DEFINES=”skia_gpu=0 skia_warnings_as_errors=1" tools/xsan_build thread dm BUILDTYPE=Release
out/Release/dm -v

BUG=skia:3386

Review URL: https://codereview.chromium.org/894833002
2015-02-02 12:08:18 -08:00

71 lines
1.7 KiB
C++

/*
* Copyright 2012 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 "Resources.h"
#include "SkCanvas.h"
#include "SkImageDecoder.h"
#include "SkStream.h"
namespace skiagm {
/** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB
conversion so this tests Skia's internal processing
*/
class CMYKJpegGM : public GM {
public:
CMYKJpegGM() {}
protected:
void onOnceBeforeDraw() SK_OVERRIDE {
// parameters to the "decode" call
bool dither = false;
SkString jpgFilename = GetResourcePath("CMYK.jpg");
SkFILEStream stream(jpgFilename.c_str());
if (!stream.isValid()) {
SkDebugf("Could not find CMYK.jpg, please set --resourcePath correctly.\n");
return;
}
SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
if (codec) {
stream.rewind();
codec->setDitherImage(dither);
codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
SkDELETE(codec);
}
}
virtual SkString onShortName() SK_OVERRIDE {
return SkString("cmykjpeg");
}
virtual SkISize onISize() SK_OVERRIDE {
return SkISize::Make(640, 480);
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
canvas->translate(20*SK_Scalar1, 20*SK_Scalar1);
canvas->drawBitmap(fBitmap, 0, 0);
}
private:
SkBitmap fBitmap;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new CMYKJpegGM; }
static GMRegistry reg(MyFactory);
}