Flutter Engine
The Flutter Engine
Classes | Namespaces | Functions
imageblurclampmode.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/SkImageFilter.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "include/effects/SkImageFilters.h"
#include "tools/ToolUtils.h"
#include <initializer_list>
#include <utility>

Go to the source code of this file.

Classes

class  skiagm::ImageBlurClampModeGM
 

Namespaces

namespace  skiagm
 

Functions

static sk_sp< SkImagemake_image (SkCanvas *canvas)
 
static void draw_image (SkCanvas *canvas, const sk_sp< SkImage > image, sk_sp< SkImageFilter > filter)
 

Function Documentation

◆ draw_image()

static void draw_image ( SkCanvas canvas,
const sk_sp< SkImage image,
sk_sp< SkImageFilter filter 
)
static

Definition at line 44 of file imageblurclampmode.cpp.

44 {
45 SkAutoCanvasRestore acr(canvas, true);
47 paint.setImageFilter(std::move(filter));
48
49 canvas->translate(SkIntToScalar(30), 0);
50 canvas->clipIRect(image->bounds());
51 canvas->drawImage(image, 0, 0, SkSamplingOptions(), &paint);
52}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
Definition: SkCanvas.h:991
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SkIRect bounds() const
Definition: SkImage.h:303
const Paint & paint
Definition: color_source.cc:38
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkSamplingOptions(SkFilterMode::kLinear))

◆ make_image()

static sk_sp< SkImage > make_image ( SkCanvas canvas)
static

Definition at line 27 of file imageblurclampmode.cpp.

27 {
29 auto surface = ToolUtils::makeSurface(canvas, info);
30 SkCanvas* c = surface->getCanvas();
32 paint.setAntiAlias(true);
33
34 paint.setColor(SK_ColorBLUE);
35 c->drawRect(SkRect::MakeIWH(info.width(), info.height()), paint);
36 paint.setColor(SK_ColorGREEN);
37 c->drawCircle(125, 100, 100, paint);
38 paint.setColor(SK_ColorRED);
39 c->drawRect(SkRect::MakeIWH(80, 80), paint);
40
41 return surface->makeImageSnapshot();
42}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
VkSurfaceKHR surface
Definition: main.cc:49
sk_sp< SkSurface > makeSurface(SkCanvas *canvas, const SkImageInfo &info, const SkSurfaceProps *props)
Definition: ToolUtils.cpp:512
static SkImageInfo MakeN32Premul(int width, int height)
static SkRect MakeIWH(int w, int h)
Definition: SkRect.h:623