Flutter Engine
The Flutter Engine
Classes | Functions
PictureBBHTest.cpp File Reference
#include "include/core/SkBBHFactory.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "tests/Test.h"

Go to the source code of this file.

Classes

class  PictureBBHTestBase
 
class  DrawEmptyPictureBBHTest
 
class  EmptyClipPictureBBHTest
 

Functions

 DEF_TEST (PictureBBH, reporter)
 
 DEF_TEST (PictureNegativeSpace, r)
 

Function Documentation

◆ DEF_TEST() [1/2]

DEF_TEST ( PictureBBH  ,
reporter   
)

Definition at line 90 of file PictureBBHTest.cpp.

90 {
91
92 DrawEmptyPictureBBHTest emptyPictureTest;
93 emptyPictureTest.run(reporter);
94
95 EmptyClipPictureBBHTest emptyClipPictureTest;
96 emptyClipPictureTest.run(reporter);
97}
reporter
Definition: FontMgrTest.cpp:39
void run(skiatest::Reporter *reporter)

◆ DEF_TEST() [2/2]

DEF_TEST ( PictureNegativeSpace  ,
 
)

Definition at line 99 of file PictureBBHTest.cpp.

99 {
100 SkRTreeFactory factory;
101 SkPictureRecorder recorder;
102
103 SkRect cull = {-200,-200,+200,+200};
104
105 {
106 sk_sp<SkBBoxHierarchy> bbh = factory();
107 auto canvas = recorder.beginRecording(cull, bbh);
108 canvas->save();
109 canvas->clipRect(cull);
110 canvas->drawRect({-20,-20,-10,-10}, SkPaint{});
111 canvas->drawRect({-20,-20,-10,-10}, SkPaint{});
112 canvas->restore();
113 auto pic = recorder.finishRecordingAsPicture();
114 REPORTER_ASSERT(r, pic->approximateOpCount() == 5);
115 REPORTER_ASSERT(r, pic->cullRect() == (SkRect{-20,-20,-10,-10}));
116 }
117
118 {
119 auto canvas = recorder.beginRecording(cull, &factory);
120 canvas->clipRect(cull);
121 canvas->drawRect({-20,-20,-10,-10}, SkPaint{});
122 canvas->drawRect({-20,-20,-10,-10}, SkPaint{});
123 auto pic = recorder.finishRecordingAsPicture();
124 REPORTER_ASSERT(r, pic->approximateOpCount() == 3);
125 REPORTER_ASSERT(r, pic->cullRect() == (SkRect{-20,-20,-10,-10}));
126 }
127}
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
int save()
Definition: SkCanvas.cpp:447
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()