Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions
CachedDecodingPixelRefTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorType.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageGenerator.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkTypes.h"
#include "include/private/SkColorData.h"
#include "src/core/SkMemset.h"
#include "tests/Test.h"
#include "tools/ToolUtils.h"
#include <array>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <utility>

Go to the source code of this file.

Classes

class  TestImageGenerator
 

Functions

 DEF_TEST (Image_NewFromGenerator, r)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( Image_NewFromGenerator  ,
 
)

Definition at line 94 of file CachedDecodingPixelRefTest.cpp.

94 {
95 const TestImageGenerator::TestType testTypes[] = {
98 };
99 const SkColorType testColorTypes[] = {
100 kN32_SkColorType,
102 };
103 for (size_t i = 0; i < std::size(testTypes); ++i) {
104 TestImageGenerator::TestType test = testTypes[i];
105 for (const SkColorType testColorType : testColorTypes) {
106 auto gen = std::make_unique<TestImageGenerator>(test, r, testColorType);
108 if (nullptr == image) {
109 ERRORF(r, "SkImage::NewFromGenerator unexpecedly failed [%zu]", i);
110 continue;
111 }
115
118 SkCanvas canvas(bitmap);
119 const SkColor kDefaultColor = 0xffabcdef;
120 canvas.clear(kDefaultColor);
121 canvas.drawImage(image, 0, 0);
124 r, TestImageGenerator::Color() == bitmap.getColor(0, 0));
125 }
126 else {
127 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0, 0));
128 }
129 }
130 }
131}
SkColorType
Definition SkColorType.h:19
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition SkColorType.h:22
uint32_t SkColor
Definition SkColor.h:37
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
#define ERRORF(r,...)
Definition Test.h:293
virtual bool isLazyGenerated() const =0
int width() const
Definition SkImage.h:285
int height() const
Definition SkImage.h:291
sk_sp< SkImage > image
Definition examples.cpp:29
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
Definition gen.py:1