Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
TextureStripAtlasManagerTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 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
14#include "include/core/SkRect.h"
26#include "tests/Test.h"
27#include "tools/DecodeUtils.h"
28
29#include <cstdint>
30#include <utility>
31
32class SkImage;
33struct GrContextOptions;
34
35// The gradient shader will use the texture strip atlas if it has too many colors. Make sure
36// abandoning the context works.
37DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(TextureStripAtlasManagerGradientTest,
39 ctxInfo,
41 auto context = ctxInfo.directContext();
42
46 static const SkScalar gPos[] = { 0, 0.17f, 0.32f, 0.49f, 0.66f, 0.83f, 1.0f };
47
48 SkPaint p;
50 1.0f,
51 SkPoint::Make(10.0f, 20.0f),
52 2.0f,
53 gColors,
54 gPos,
55 7,
57
60 SkCanvas* canvas = surface->getCanvas();
61
62 SkRect r = SkRect::MakeXYWH(10, 10, 100, 100);
63
64 canvas->drawRect(r, p);
65
66 context->abandonContext();
67}
68
69// The table color filter uses the texture strip atlas. Make sure abandoning the context works.
70DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(TextureStripAtlasManagerColorFilterTest,
72 ctxInfo,
74 auto context = ctxInfo.directContext();
75
76 sk_sp<SkImage> img = ToolUtils::GetResourceAsImage("images/mandrill_128.png");
77
78 uint8_t identity[256];
79 for (int i = 0; i < 256; i++) {
80 identity[i] = i;
81 }
82
83 SkPaint p;
84 p.setColorFilter(SkColorFilters::Table(identity));
85
88 SkCanvas* canvas = surface->getCanvas();
89
90 canvas->drawImage(std::move(img), 0, 0, SkSamplingOptions(), &p);
91
92 context->abandonContext();
93}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
reporter
static const SkScalar gPos[]
static const SkColor gColors[]
constexpr SkColor SK_ColorYELLOW
Definition SkColor.h:139
constexpr SkColor SK_ColorMAGENTA
Definition SkColor.h:147
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorCYAN
Definition SkColor.h:143
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
Definition Test.h:434
void drawRect(const SkRect &rect, const SkPaint &paint)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
static sk_sp< SkColorFilter > Table(const uint8_t table[256])
static sk_sp< SkShader > MakeTwoPointConical(const SkPoint &start, SkScalar startRadius, const SkPoint &end, SkScalar endRadius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
VkSurfaceKHR surface
Definition main.cc:49
float SkScalar
Definition extension.cpp:12
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition DecodeUtils.h:25
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkPoint Make(float x, float y)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659