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
70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
/*
|
|
* Copyright 2014 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"
|
|
|
|
namespace skiagm {
|
|
|
|
// This GM exercises the use case found in crbug.com/423834.
|
|
// The following pattern:
|
|
// save();
|
|
// clipRect(rect, noAA);
|
|
// drawRect(bigRect, noAA);
|
|
// restore();
|
|
//
|
|
// drawRect(rect, noAA);
|
|
// can leave 1 pixel wide remnants of the first rect.
|
|
class ClipDrawDrawGM : public GM {
|
|
public:
|
|
ClipDrawDrawGM() { this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); }
|
|
|
|
protected:
|
|
SkString onShortName() override { return SkString("clipdrawdraw"); }
|
|
|
|
SkISize onISize() override { return SkISize::Make(512, 512); }
|
|
|
|
static void Draw(SkCanvas* canvas, const SkRect& rect) {
|
|
SkPaint p;
|
|
p.setAntiAlias(false);
|
|
|
|
const SkRect bigRect = SkRect::MakeWH(600, 600);
|
|
|
|
canvas->save();
|
|
// draw a black rect through the clip
|
|
canvas->save();
|
|
canvas->clipRect(rect);
|
|
canvas->drawRect(bigRect, p);
|
|
canvas->restore();
|
|
|
|
// now draw the white rect on top
|
|
p.setColor(SK_ColorWHITE);
|
|
canvas->drawRect(rect, p);
|
|
canvas->restore();
|
|
}
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
|
// Vertical remnant
|
|
const SkRect rect1 = SkRect::MakeLTRB(136.5f, 137.5f, 338.5f, 293.5f);
|
|
|
|
// Horizontal remnant
|
|
// 179.488 rounds the right way (i.e., 179), 179.499 rounds the wrong way (i.e., 180)
|
|
const SkRect rect2 = SkRect::MakeLTRB(207.5f, 179.499f, 530.5f, 429.5f);
|
|
|
|
Draw(canvas, rect1);
|
|
Draw(canvas, rect2);
|
|
}
|
|
|
|
private:
|
|
typedef GM INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_GM(return SkNEW(ClipDrawDrawGM);)
|
|
|
|
}
|