2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
12 // This GM exercises the use case found in crbug.com/423834.
13 // The following pattern:
15 // clipRect(rect, noAA);
16 // drawRect(bigRect, noAA);
19 // drawRect(rect, noAA);
20 // can leave 1 pixel wide remnants of the first rect.
21 class ClipDrawDrawGM : public GM {
23 ClipDrawDrawGM() { this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); }
26 SkString onShortName() override { return SkString("clipdrawdraw"); }
28 SkISize onISize() override { return SkISize::Make(512, 512); }
30 static void Draw(SkCanvas* canvas, const SkRect& rect) {
32 p.setAntiAlias(false);
34 const SkRect bigRect = SkRect::MakeWH(600, 600);
37 // draw a black rect through the clip
39 canvas->clipRect(rect);
40 canvas->drawRect(bigRect, p);
43 // now draw the white rect on top
44 p.setColor(SK_ColorWHITE);
45 canvas->drawRect(rect, p);
49 void onDraw(SkCanvas* canvas) override {
51 const SkRect rect1 = SkRect::MakeLTRB(136.5f, 137.5f, 338.5f, 293.5f);
54 // 179.488 rounds the right way (i.e., 179), 179.499 rounds the wrong way (i.e., 180)
55 const SkRect rect2 = SkRect::MakeLTRB(207.5f, 179.499f, 530.5f, 429.5f);
65 //////////////////////////////////////////////////////////////////////////////
67 DEF_GM(return SkNEW(ClipDrawDrawGM);)