Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
FloatingPointTextureTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkString.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/private/base/SkTDArray.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkHalf.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrImageInfo.h"
#include "src/gpu/ganesh/GrPixmap.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/SurfaceContext.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/gpu/ProxyUtils.h"
#include <cstring>
#include <initializer_list>
#include <memory>
#include <utility>

Go to the source code of this file.

Functions

template<typename T >
void runFPTest (skiatest::Reporter *reporter, GrDirectContext *dContext, T min, T max, T epsilon, T maxInt, int arraySize, GrColorType colorType)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (HalfFloatAlphaTextureTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (HalfFloatRGBATextureTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 

Variables

static const int DEV_W = 100
 
static const int DEV_H = 100
 
static const int HALF_ALPHA_CONTROL_ARRAY_SIZE = DEV_W * DEV_H * 1
 
static const SkHalf kMaxIntegerRepresentableInHalfFloatingPoint = 0x6800
 
static const int HALF_RGBA_CONTROL_ARRAY_SIZE = DEV_W * DEV_H * 4
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [1/2]

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

Definition at line 90 of file FloatingPointTextureTest.cpp.

93 {
94 auto direct = ctxInfo.directContext();
95
96 runFPTest<SkHalf>(reporter, direct, SK_HalfMin, SK_HalfMax, SK_HalfEpsilon,
99}
static const SkHalf kMaxIntegerRepresentableInHalfFloatingPoint
static const int HALF_ALPHA_CONTROL_ARRAY_SIZE
reporter
static constexpr uint16_t SK_HalfMax
Definition SkHalf.h:21
static constexpr uint16_t SK_HalfMin
Definition SkHalf.h:20
static constexpr uint16_t SK_HalfEpsilon
Definition SkHalf.h:22

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [2/2]

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

Definition at line 103 of file FloatingPointTextureTest.cpp.

106 {
107 auto direct = ctxInfo.directContext();
108
109 runFPTest<SkHalf>(reporter, direct, SK_HalfMin, SK_HalfMax, SK_HalfEpsilon,
112}
static const int HALF_RGBA_CONTROL_ARRAY_SIZE

◆ runFPTest()

template<typename T >
void runFPTest ( skiatest::Reporter reporter,
GrDirectContext dContext,
T  min,
T  max,
T  epsilon,
T  maxInt,
int  arraySize,
GrColorType  colorType 
)

Definition at line 44 of file FloatingPointTextureTest.cpp.

46 {
47 if (0 != arraySize % 4) {
48 REPORT_FAILURE(reporter, "(0 != arraySize % 4)",
49 SkString("arraySize must be divisible by 4."));
50 return;
51 }
52
53 SkTDArray<T> controlPixelData, readBuffer;
54 controlPixelData.resize(arraySize);
55 readBuffer.resize(arraySize);
56
57 for (int i = 0; i < arraySize; i += 4) {
58 controlPixelData[i + 0] = min;
59 controlPixelData[i + 1] = max;
60 controlPixelData[i + 2] = epsilon;
61 controlPixelData[i + 3] = maxInt;
62 }
63
66 GrCPixmap controlPixmap(info, controlPixelData.begin(), info.minRowBytes());
67 auto fpView = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
68 GrRenderable::kYes,
69 origin,
70 controlPixmap);
71 // Floating point textures are NOT supported everywhere
72 if (!fpView) {
73 continue;
74 }
75
76 auto sc = dContext->priv().makeSC(std::move(fpView), info.colorInfo());
78
79 GrPixmap readPixmap(info, readBuffer.begin(), info.minRowBytes());
80 bool result = sc->readPixels(dContext, readPixmap, {0, 0});
83 !memcmp(readBuffer.begin(), controlPixelData.begin(), readBuffer.size_bytes()));
84 }
85}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static const int DEV_H
static const int DEV_W
@ kBottomLeft_GrSurfaceOrigin
Definition GrTypes.h:149
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
#define REPORT_FAILURE(reporter, cond, message)
Definition Test.h:90
GrDirectContextPriv priv()
std::unique_ptr< skgpu::ganesh::SurfaceContext > makeSC(GrSurfaceProxyView readView, const GrColorInfo &)
T * begin()
Definition SkTDArray.h:150
void resize(int count)
Definition SkTDArray.h:183
size_t size_bytes() const
Definition SkTDArray.h:146
GAsyncResult * result
static float max(float r, float g, float b)
Definition hsl.cpp:49
static float min(float r, float g, float b)
Definition hsl.cpp:48
GrSurfaceProxyView MakeTextureProxyViewFromData(GrDirectContext *dContext, GrRenderable renderable, GrSurfaceOrigin origin, GrCPixmap pixmap)

Variable Documentation

◆ DEV_H

const int DEV_H = 100
static

Definition at line 41 of file FloatingPointTextureTest.cpp.

◆ DEV_W

const int DEV_W = 100
static

Definition at line 41 of file FloatingPointTextureTest.cpp.

◆ HALF_ALPHA_CONTROL_ARRAY_SIZE

const int HALF_ALPHA_CONTROL_ARRAY_SIZE = DEV_W * DEV_H * 1
static

Definition at line 87 of file FloatingPointTextureTest.cpp.

◆ HALF_RGBA_CONTROL_ARRAY_SIZE

const int HALF_RGBA_CONTROL_ARRAY_SIZE = DEV_W * DEV_H * 4
static

Definition at line 101 of file FloatingPointTextureTest.cpp.

◆ kMaxIntegerRepresentableInHalfFloatingPoint

const SkHalf kMaxIntegerRepresentableInHalfFloatingPoint = 0x6800
static

Definition at line 88 of file FloatingPointTextureTest.cpp.