Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
thinrects.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkImage.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"

Go to the source code of this file.

Classes

class  skiagm::ThinRectsGM
 

Namespaces

namespace  skiagm
 

Functions

 DEF_SIMPLE_GM_CAN_FAIL (clipped_thinrect, canvas, errorMsg, 256, 256)
 

Function Documentation

◆ DEF_SIMPLE_GM_CAN_FAIL()

DEF_SIMPLE_GM_CAN_FAIL ( clipped_thinrect  ,
canvas  ,
errorMsg  ,
256  ,
256   
)

Definition at line 153 of file thinrects.cpp.

153 {
154 auto zoomed = canvas->makeSurface(canvas->imageInfo().makeWH(10, 10));
155 if (!zoomed) {
156 errorMsg->printf("makeSurface not supported");
158 }
159 auto zoomedCanvas = zoomed->getCanvas();
160
161 SkPaint p;
162 p.setColor(SK_ColorRED);
163 p.setAntiAlias(true);
164 p.setStyle(SkPaint::kFill_Style);
165 zoomedCanvas->save();
166 zoomedCanvas->clipRect(SkRect::MakeXYWH(0, 5, 256, 10), true /*doAntialias*/);
167 zoomedCanvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 5.5), p);
168 zoomedCanvas->restore();
169
170 // Zoom-in. Should see one line of red representing zoomed in 1/2px coverage and *not*
171 // two lines of varying coverage from hairline rendering.
172 auto img = zoomed->makeImageSnapshot();
173 canvas->drawImageRect(img, SkRect::MakeXYWH(0, 10, 200, 200), SkSamplingOptions());
175}
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659