Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
GpuRectanizerTest.cpp File Reference
#include "include/core/SkSize.h"
#include "include/gpu/GpuTypes.h"
#include "include/private/base/SkTDArray.h"
#include "src/base/SkRandom.h"
#include "src/core/SkIPoint16.h"
#include "src/gpu/Rectanizer.h"
#include "src/gpu/RectanizerPow2.h"
#include "src/gpu/RectanizerSkyline.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"

Go to the source code of this file.

Functions

static void test_rectanizer_basic (skiatest::Reporter *reporter, Rectanizer *rectanizer)
 
static void test_rectanizer_inserts (skiatest::Reporter *, Rectanizer *rectanizer, const SkTDArray< SkISize > &rects)
 
static void test_skyline (skiatest::Reporter *reporter, const SkTDArray< SkISize > &rects)
 
static void test_pow2 (skiatest::Reporter *reporter, const SkTDArray< SkISize > &rects)
 
 DEF_GANESH_TEST (GpuRectanizer, reporter, factory, CtsEnforcement::kNever)
 

Variables

static const int kWidth = 1024
 
static const int kHeight = 1024
 

Function Documentation

◆ DEF_GANESH_TEST()

DEF_GANESH_TEST ( GpuRectanizer  ,
reporter  ,
factory  ,
CtsEnforcement::kNever   
)

Definition at line 67 of file GpuRectanizerTest.cpp.

67 {
69 SkRandom rand;
70
71 for (int i = 0; i < 50; i++) {
72 rects.push_back(SkISize::Make(rand.nextRangeU(1, kWidth / 2),
73 rand.nextRangeU(1, kHeight / 2)));
74 }
75
76 test_skyline(reporter, rects);
77 test_pow2(reporter, rects);
78}
reporter
static void test_skyline(skiatest::Reporter *reporter, const SkTDArray< SkISize > &rects)
static const int kHeight
static const int kWidth
static void test_pow2(skiatest::Reporter *reporter, const SkTDArray< SkISize > &rects)
uint32_t nextRangeU(uint32_t min, uint32_t max)
Definition SkRandom.h:80
void push_back(const T &v)
Definition SkTDArray.h:219
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ test_pow2()

static void test_pow2 ( skiatest::Reporter reporter,
const SkTDArray< SkISize > &  rects 
)
static

Definition at line 60 of file GpuRectanizerTest.cpp.

60 {
61 RectanizerPow2 pow2Rectanizer(kWidth, kHeight);
62
63 test_rectanizer_basic(reporter, &pow2Rectanizer);
64 test_rectanizer_inserts(reporter, &pow2Rectanizer, rects);
65}
static void test_rectanizer_inserts(skiatest::Reporter *, Rectanizer *rectanizer, const SkTDArray< SkISize > &rects)
static void test_rectanizer_basic(skiatest::Reporter *reporter, Rectanizer *rectanizer)

◆ test_rectanizer_basic()

static void test_rectanizer_basic ( skiatest::Reporter reporter,
Rectanizer rectanizer 
)
static

Definition at line 27 of file GpuRectanizerTest.cpp.

27 {
28 REPORTER_ASSERT(reporter, kWidth == rectanizer->width());
29 REPORTER_ASSERT(reporter, kHeight == rectanizer->height());
30
31 SkIPoint16 loc;
32
33 REPORTER_ASSERT(reporter, rectanizer->addRect(50, 50, &loc));
34 REPORTER_ASSERT(reporter, rectanizer->percentFull() > 0.0f);
35 rectanizer->reset();
36 REPORTER_ASSERT(reporter, rectanizer->percentFull() == 0.0f);
37}
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
virtual void reset()=0
int width() const
Definition Rectanizer.h:26
int height() const
Definition Rectanizer.h:27
virtual float percentFull() const =0
virtual bool addRect(int width, int height, SkIPoint16 *loc)=0

◆ test_rectanizer_inserts()

static void test_rectanizer_inserts ( skiatest::Reporter ,
Rectanizer rectanizer,
const SkTDArray< SkISize > &  rects 
)
static

Definition at line 39 of file GpuRectanizerTest.cpp.

41 {
42 int i;
43 for (i = 0; i < rects.size(); ++i) {
44 SkIPoint16 loc;
45 if (!rectanizer->addRect(rects[i].fWidth, rects[i].fHeight, &loc)) {
46 break;
47 }
48 }
49
50 //SkDebugf("\n***%d %f\n", i, rectanizer->percentFull());
51}
int size() const
Definition SkTDArray.h:138

◆ test_skyline()

static void test_skyline ( skiatest::Reporter reporter,
const SkTDArray< SkISize > &  rects 
)
static

Definition at line 53 of file GpuRectanizerTest.cpp.

53 {
54 RectanizerSkyline skylineRectanizer(kWidth, kHeight);
55
56 test_rectanizer_basic(reporter, &skylineRectanizer);
57 test_rectanizer_inserts(reporter, &skylineRectanizer, rects);
58}

Variable Documentation

◆ kHeight

const int kHeight = 1024
static

Definition at line 24 of file GpuRectanizerTest.cpp.

◆ kWidth

const int kWidth = 1024
static

Definition at line 23 of file GpuRectanizerTest.cpp.