Flutter Engine
The Flutter Engine
Classes | Functions
DeviceTest.cpp File Reference
#include "include/core/SkBitmap.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
#include "src/core/SkDevice.h"
#include "src/core/SkSpecialImage.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/ganesh/Device.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"

Go to the source code of this file.

Classes

class  DeviceTestingAccess
 

Functions

 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (SpecialImage_GPUDevice, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS()

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( SpecialImage_GPUDevice  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 83 of file DeviceTest.cpp.

86 {
87 auto dContext = ctxInfo.directContext();
88
89 static const int kWidth = 100;
90 static const int kHeight = 90;
91
93
94 auto device = dContext->priv().createDevice(skgpu::Budgeted::kNo,
95 ii,
97 1,
103
104 SkBitmap bm;
106
107 // Create a gpu-backed special image from a raster-backed SkBitmap
109 SkASSERT(special->isGaneshBacked());
110 SkASSERT(kWidth == special->width());
111 SkASSERT(kHeight == special->height());
112 SkASSERT(bm.getGenerationID() == special->uniqueID());
114
115 // Create a gpu-backed special image from a raster-backed SkImage
118 SkASSERT(special->isGaneshBacked());
119 SkASSERT(kWidth == special->width());
120 SkASSERT(kHeight == special->height());
121 // TODO: Hmmm, this is a bit unexpected
122 SkASSERT(image->uniqueID() != special->uniqueID());
124
125 // Create a gpu-backed special image from a gpu-backed SkImage
128 SkASSERT(special->isGaneshBacked());
129 SkASSERT(kWidth == special->width());
130 SkASSERT(kHeight == special->height());
131 SkASSERT(image->uniqueID() == special->uniqueID());
133
134 // Snap the device as a gpu-backed special image
136 SkASSERT(special->isGaneshBacked());
137 SkASSERT(2*kWidth == special->width());
138 SkASSERT(2*kHeight == special->height());
139 SkASSERT(SkIRect::MakeWH(2*kWidth, 2*kHeight) == special->subset());
140}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
#define SkASSERT(cond)
Definition: SkAssert.h:116
static sk_sp< SkSpecialImage > SnapSpecial(SkDevice *dev)
Definition: DeviceTest.cpp:39
static sk_sp< SkSpecialImage > MakeSpecial(SkDevice *dev, const SkBitmap &bm)
Definition: DeviceTest.cpp:31
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
uint32_t getGenerationID() const
Definition: SkBitmap.cpp:361
bool tryAllocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:226
uint32_t uniqueID() const
Definition: SkImage.h:311
int width() const
int height() const
virtual bool isGaneshBacked() const
uint32_t uniqueID() const
const SkIRect & subset() const
T * get() const
Definition: SkRefCnt.h:303
VkDevice device
Definition: main.cc:53
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
static SkImageInfo MakeN32Premul(int width, int height)
constexpr size_t kHeight
constexpr size_t kWidth