Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
subsetshader.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkShader.h"
#include "include/core/SkString.h"
#include "include/core/SkTileMode.h"
#include "tools/DecodeUtils.h"
#include "tools/Resources.h"

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM_CAN_FAIL (bitmap_subset_shader, canvas, errorMsg, 256, 256)
 

Function Documentation

◆ DEF_SIMPLE_GM_CAN_FAIL()

DEF_SIMPLE_GM_CAN_FAIL ( bitmap_subset_shader  ,
canvas  ,
errorMsg  ,
256  ,
256   
)

Definition at line 21 of file subsetshader.cpp.

21 {
22 canvas->clear(SK_ColorWHITE);
23
25 if (!ToolUtils::GetResourceAsBitmap("images/color_wheel.png", &source)) {
26 *errorMsg = "Could not load images/color_wheel.png. "
27 "Did you forget to set the resourcePath?";
29 }
32 source.width()/2, source.height());
33 SkBitmap leftBitmap, rightBitmap;
34 source.extractSubset(&leftBitmap, left);
35 source.extractSubset(&rightBitmap, right);
36
38 matrix.setScale(0.75f, 0.75f);
39 matrix.preRotate(30.0f);
42 paint.setShader(leftBitmap.makeShader(tm, tm, SkSamplingOptions(), matrix));
43 canvas->drawRect(SkRect::MakeWH(256.0f, 128.0f), paint);
44 paint.setShader(rightBitmap.makeShader(tm, tm, SkSamplingOptions(), matrix));
45 canvas->drawRect(SkRect::MakeXYWH(0, 128.0f, 256.0f, 128.0f), paint);
47}
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
SkTileMode
Definition SkTileMode.h:13
bool extractSubset(SkBitmap *dst, const SkIRect &subset) const
Definition SkBitmap.cpp:453
int width() const
Definition SkBitmap.h:149
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition SkBitmap.cpp:669
int height() const
Definition SkBitmap.h:158
const Paint & paint
SkBitmap source
Definition examples.cpp:28
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
bool GetResourceAsBitmap(const char *resource, SkBitmap *dst)
Definition DecodeUtils.h:21
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609