65cdba6ba7
Reason for revert: underlying problem with portable refs deleted more than once fixed Original issue's description: > Revert of make gm background colors 565 compatible (patchset #2 id:20001 of https://codereview.chromium.org/1176243006/) > > Reason for revert: > breaks many bots with refcnt error > > Original issue's description: > > make gm background colors 565 compatible > > > > Change a batch of GM tests to convert their background color > > so that it is representable in 8888 and 565. > > > > Enable portable text in those same tests to minimize platform > > differences. > > > > In a couple of bitmap tests, use portable typefaces instead of > > choosing 'Times' which may or may not be available on the platform. > > > > R=borenet@google.com > > > > Committed: https://skia.googlesource.com/skia/+/be7f768a357aefb39c42d24b81b24d647bb6ab70 > > TBR=borenet@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Committed: https://skia.googlesource.com/skia/+/0bdb08b1ba8fbd18c4838f86a23f1ef4b3a3bfdf TBR=borenet@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1182403003
66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
|
|
/*
|
|
* Copyright 2011 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 "SkColorPriv.h"
|
|
#include "SkShader.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkUtils.h"
|
|
|
|
namespace skiagm {
|
|
|
|
static SkBitmap make_bitmap() {
|
|
const SkPMColor c[] = { SkPackARGB32(0x80, 0x80, 0, 0) };
|
|
SkColorTable* ctable = new SkColorTable(c, SK_ARRAY_COUNT(c));
|
|
|
|
SkBitmap bm;
|
|
bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType,
|
|
kPremul_SkAlphaType),
|
|
NULL, ctable);
|
|
ctable->unref();
|
|
|
|
bm.lockPixels();
|
|
*bm.getAddr8(0, 0) = 0;
|
|
bm.unlockPixels();
|
|
return bm;
|
|
}
|
|
|
|
class TinyBitmapGM : public GM {
|
|
public:
|
|
TinyBitmapGM() {
|
|
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
|
}
|
|
|
|
protected:
|
|
SkString onShortName() {
|
|
return SkString("tinybitmap");
|
|
}
|
|
|
|
virtual SkISize onISize() { return SkISize::Make(100, 100); }
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
SkBitmap bm = make_bitmap();
|
|
SkShader* s =
|
|
SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
|
|
SkShader::kMirror_TileMode);
|
|
SkPaint paint;
|
|
paint.setAlpha(0x80);
|
|
paint.setShader(s)->unref();
|
|
canvas->drawPaint(paint);
|
|
}
|
|
|
|
private:
|
|
typedef GM INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
static GM* MyFactory(void*) { return new TinyBitmapGM; }
|
|
static GMRegistry reg(MyFactory);
|
|
|
|
}
|