Flutter Engine
The Flutter Engine
FlattenableFactoryToName.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
17#include "tests/Test.h"
18
20 const SkFlattenable* f,
21 const char* desc) {
22 if (f) {
23 SkFlattenable::Factory factory = f->getFactory();
24 REPORTER_ASSERT(r, factory);
25 if (factory) {
26 if (!SkFlattenable::FactoryToName(factory)) {
27 ERRORF(r, "SkFlattenable::FactoryToName() fails with %s.", desc);
28 }
29 }
30 }
31}
32
33DEF_TEST(FlattenableFactoryToName, r) {
34 sk_sp<SkImageFilter> filter(SkImageFilters::Blur(0.2f, 0.7f, nullptr));
35 test_flattenable(r, filter.get(), "SkImageFilters::Blur()");
36
37 SkBitmap bm;
38 bm.allocN32Pixels(8, 8);
41 test_flattenable(r, image->makeShader(SkSamplingOptions()).get(), "SkImage::newShader()");
42}
DEF_TEST(FlattenableFactoryToName, r)
static void test_flattenable(skiatest::Reporter *r, const SkFlattenable *f, const char *desc)
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
#define ERRORF(r,...)
Definition: Test.h:293
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:442
sk_sp< SkFlattenable >(* Factory)(SkReadBuffer &)
Definition: SkFlattenable.h:41
static const char * FactoryToName(Factory)
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
T * get() const
Definition: SkRefCnt.h:303
sk_sp< const SkImage > image
Definition: SkRecords.h:269
const myers::Point & get(const myers::Segment &)