Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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,
98 skgpu::Mipmapped::kNo,
99 GrProtected::kNo,
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());
113 SkASSERT(SkIRect::MakeWH(kWidth, kHeight) == special->subset());
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());
123 SkASSERT(SkIRect::MakeWH(kWidth, kHeight) == special->subset());
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());
132 SkASSERT(SkIRect::MakeWH(kWidth, kHeight) == special->subset());
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}
@ kBottomLeft_GrSurfaceOrigin
Definition GrTypes.h:149
#define SkAssertResult(cond)
Definition SkAssert.h:123
#define SkASSERT(cond)
Definition SkAssert.h:116
static sk_sp< SkSpecialImage > SnapSpecial(SkDevice *dev)
static sk_sp< SkSpecialImage > MakeSpecial(SkDevice *dev, const SkBitmap &bm)
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
T * get() const
Definition SkRefCnt.h:303
VkDevice device
Definition main.cc:53
sk_sp< SkImage > image
Definition examples.cpp:29
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
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