Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
MatrixColorFilterTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkShader.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkColorMatrix.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include <functional>

Go to the source code of this file.

Functions

 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (MatrixColorFilter_TransparentBlack, reporter, info, CtsEnforcement::kApiLevel_T)
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS()

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( MatrixColorFilter_TransparentBlack  ,
reporter  ,
info  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 35 of file MatrixColorFilterTest.cpp.

38 {
39 auto context = info.directContext();
40 // Make a transparent black image rather than use a paint color to avoid an optimization that
41 // applies the color filter on the CPU to paint colors.
42 auto imgSurf = SkSurfaces::RenderTarget(
44 imgSurf->getCanvas()->drawColor(0x0000000);
45 auto shader = imgSurf->makeImageSnapshot()->makeShader(SkSamplingOptions());
47 m.setScale(0, 0, 0, 127.f);
48 SkPaint p;
49 p.setColorFilter(SkColorFilters::Matrix(m));
50 p.setShader(shader);
51 p.setBlendMode(SkBlendMode::kSrc);
52 auto surf = SkSurfaces::RenderTarget(
54 // Seed the output surface with red so we would notice if we failed to draw at all.
55 surf->getCanvas()->clear(SK_ColorRED);
56 surf->getCanvas()->drawPaint(p);
58 pixels.alloc(surf->imageInfo());
59 surf->readPixels(pixels, 0, 0);
60 auto error = std::function<ComparePixmapsErrorReporter>(
61 [reporter](int x, int y, const float diffs[4]) {
62 ERRORF(reporter, "Expected transparent black, instead got (%f, %f, %f, %f)",
63 diffs[0], diffs[1], diffs[2], diffs[3]);
64 });
65 static constexpr float kTol[] = {0, 0, 0, 0};
66 CheckSolidPixels({0, 0, 0, 0}, pixels, kTol, error);
67}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
reporter
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
bool CheckSolidPixels(const SkColor4f &col, const SkPixmap &pixmap, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define ERRORF(r,...)
Definition Test.h:293
void alloc(const SkImageInfo &)
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
const uint8_t uint32_t uint32_t GError ** error
double y
double x
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)
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)