Flutter Engine
The Flutter Engine
Functions
UpdateBackendTextureTest.cpp File Reference
#include "tests/Test.h"
#include "include/core/SkColorSpace.h"
#include "include/gpu/graphite/BackendTexture.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Image.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Surface.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/ContextPriv.h"
#include "src/gpu/graphite/Surface_Graphite.h"
#include "tests/TestUtils.h"
#include "tools/ToolUtils.h"

Go to the source code of this file.

Functions

 DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (UpdateImageBackendTextureTest, reporter, context, CtsEnforcement::kNextRelease)
 

Function Documentation

◆ DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS()

DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( UpdateImageBackendTextureTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 163 of file UpdateBackendTextureTest.cpp.

164 {
165 // TODO: Remove this check once Vulkan supports creating default TexutreInfo from caps and we
166 // implement createBackendTexture.
167 if (context->backend() == BackendApi::kVulkan) {
168 return;
169 }
170
171 const Caps* caps = context->priv().caps();
172 std::unique_ptr<Recorder> recorder = context->makeRecorder();
173
174 constexpr SkColor4f kColors[6] = {
175 { 1.0f, 0.0f, 0.0f, 1.0f }, // R
176 { 0.0f, 1.0f, 0.0f, 0.9f }, // G
177 { 0.0f, 0.0f, 1.0f, 0.7f }, // B
178 { 0.0f, 1.0f, 1.0f, 0.5f }, // C
179 { 1.0f, 0.0f, 1.0f, 0.3f }, // M
180 { 1.0f, 1.0f, 0.0f, 0.2f }, // Y
181 };
182
183 constexpr SkColor4f kColorsNew[6] = {
184 { 1.0f, 1.0f, 0.0f, 0.2f }, // Y
185 { 1.0f, 0.0f, 0.0f, 1.0f }, // R
186 { 0.0f, 1.0f, 0.0f, 0.9f }, // G
187 { 0.0f, 0.0f, 1.0f, 0.7f }, // B
188 { 0.0f, 1.0f, 1.0f, 0.5f }, // C
189 { 1.0f, 0.0f, 1.0f, 0.3f }, // M
190 };
191
192 // TODO: test more than just RGBA8
193 for (SkColorType ct : { kRGBA_8888_SkColorType }) {
194 for (bool withMips : { true, false }) {
195 for (Renderable renderable : { Renderable::kYes, Renderable::kNo }) {
196
197 BackendTexture backendTex = create_backend_texture(reporter, caps, recorder.get(),
198 ct, withMips, renderable,
199 kColors);
200
201 sk_sp<SkImage> image = wrap_backend_texture(reporter, recorder.get(), backendTex,
202 ct, withMips);
203 if (!image) {
204 continue;
205 }
206
207 check_levels(reporter, context, recorder.get(), image.get(), withMips, kColors);
208
209 image.reset();
210
211 update_backend_texture(recorder.get(), backendTex, ct, withMips, kColorsNew);
212
213 image = wrap_backend_texture(reporter, recorder.get(), backendTex, ct, withMips);
214 if (!image) {
215 continue;
216 }
217
218 check_levels(reporter, context, recorder.get(), image.get(), withMips, kColorsNew);
219
220 image.reset();
221
222 recorder->deleteBackendTexture(backendTex);
223 }
224 }
225 }
226}
reporter
Definition: FontMgrTest.cpp:39
SkColorType
Definition: SkColorType.h:19
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
T * get() const
Definition: SkRefCnt.h:303
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310
@ kVulkan
Definition: embedder.h:86
sk_sp< const SkImage > image
Definition: SkRecords.h:269
const DlColor kColors[]
Renderable
Definition: GpuTypes.h:69