Flutter Engine
The Flutter Engine
Functions
CacheKeyTest.cpp File Reference
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/ImageProvider.h"
#include "include/gpu/graphite/Recorder.h"
#include "tests/Test.h"
#include "tools/GpuToolUtils.h"
#include "tools/ToolUtils.h"

Go to the source code of this file.

Functions

 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (CacheKeyTest_Picture, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (CacheKeyTest_Bitmap, reporter, context, CtsEnforcement::kNextRelease)
 

Function Documentation

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [1/2]

DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( CacheKeyTest_Bitmap  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 102 of file CacheKeyTest.cpp.

103 {
104 std::unique_ptr<Recorder> recorder = context->makeRecorder();
105
106 RecorderOptions options = ToolUtils::CreateTestingRecorderOptions();
107
108 sk_sp<ImageProvider> provider = options.fImageProvider;
109
110 SkBitmap orig = create_bitmap(128, 128);
111 SkBitmap subset;
112 orig.extractSubset(&subset, SkIRect::MakeXYWH(32, 32, 64, 64));
113 SkASSERT(orig.getGenerationID() == subset.getGenerationID());
114
115 for (bool mipmapped : { false, true }) {
117
118 sk_sp<SkImage> result1 = provider->findOrCreate(recorder.get(),
119 image1.get(),
120 {mipmapped});
121
123 REPORTER_ASSERT(reporter, image1->uniqueID() != image2->uniqueID());
124
125 sk_sp<SkImage> result2 = provider->findOrCreate(recorder.get(),
126 image2.get(),
127 {mipmapped});
128 REPORTER_ASSERT(reporter, result1 == result2);
129 }
130}
const char * options
reporter
Definition: FontMgrTest.cpp:39
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
bool extractSubset(SkBitmap *dst, const SkIRect &subset) const
Definition: SkBitmap.cpp:453
uint32_t getGenerationID() const
Definition: SkBitmap.cpp:361
uint32_t uniqueID() const
Definition: SkImage.h:311
T * get() const
Definition: SkRefCnt.h:303
static SkBitmap create_bitmap(SkIRect contentRect, SkISize fullSize, GrSurfaceOrigin origin)
Definition: lazytiling.cpp:90
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [2/2]

DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( CacheKeyTest_Picture  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 56 of file CacheKeyTest.cpp.

57 {
58 std::unique_ptr<Recorder> recorder = context->makeRecorder();
59
60 RecorderOptions options = ToolUtils::CreateTestingRecorderOptions();
61
62 sk_sp<ImageProvider> provider = options.fImageProvider;
63
64 sk_sp<SkPicture> picture = create_picture(128, 128);
65 const SkMatrix xlate = SkMatrix::Translate(10.0f, -10.0f);
67
68 for (auto bitDepth : { SkImages::BitDepth::kU8, SkImages::BitDepth::kF16 }) {
69 for (const SkMatrix* mat : { static_cast<const SkMatrix*>(nullptr), &xlate }) {
70 for (bool mipmapped : { false, true }) {
71 for (uint32_t flags : { 0, int(SkSurfaceProps::kAlwaysDither_Flag) } ) {
75 mat, nullptr,
76 bitDepth, srgb,
77 { flags, geometry });
78
79 sk_sp<SkImage> result1 = provider->findOrCreate(recorder.get(),
80 image1.get(),
81 {mipmapped});
82
84 mat, nullptr,
85 bitDepth, srgb,
86 { flags, geometry });
87 REPORTER_ASSERT(reporter, image1->uniqueID() != image2->uniqueID());
88
89 sk_sp<SkImage> result2 = provider->findOrCreate(recorder.get(),
90 image2.get(),
91 {mipmapped});
92 REPORTER_ASSERT(reporter, result1 == result2);
93 }
94 }
95 }
96 }
97 }
98}
SkPixelGeometry
@ kUnknown_SkPixelGeometry
@ kRGB_H_SkPixelGeometry
static sk_sp< SkColorSpace > MakeSRGB()
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
FlutterSemanticsFlag flags
SK_API sk_sp< SkImage > DeferredFromPicture(sk_sp< SkPicture > picture, const SkISize &dimensions, const SkMatrix *matrix, const SkPaint *paint, BitDepth bitDepth, sk_sp< SkColorSpace > colorSpace, SkSurfaceProps props)
@ kF16
uses 16-bit float per color component
@ kU8
uses 8-bit unsigned int per color component
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299