Flutter Engine
The Flutter Engine
Functions
ImageBitmapTest.cpp File Reference
#include "include/core/SkBitmap.h"
#include "include/core/SkColor.h"
#include "include/core/SkImage.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "tests/Test.h"

Go to the source code of this file.

Functions

 DEF_TEST (ImageBitmapIdentity, r)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( ImageBitmapIdentity  ,
 
)

Definition at line 19 of file ImageBitmapTest.cpp.

19 {
20 SkBitmap bm, a, b;
21 bm.allocN32Pixels(32, 64);
23 bm.setImmutable();
24 (void)bm.extractSubset(&a, SkIRect::MakeXYWH(0, 0, 32, 32));
25 (void)bm.extractSubset(&b, SkIRect::MakeXYWH(0, 32, 32, 32));
26 REPORTER_ASSERT(r, a.getGenerationID() == b.getGenerationID());
27 auto img = bm.asImage();
28 auto imgA = a.asImage();
29 auto imgB = b.asImage();
30 REPORTER_ASSERT(r, img->uniqueID() == bm.getGenerationID());
31 REPORTER_ASSERT(r, img->uniqueID() != imgA->uniqueID());
32 REPORTER_ASSERT(r, img->uniqueID() != imgB->uniqueID());
33 REPORTER_ASSERT(r, imgA->uniqueID() != imgB->uniqueID());
34 REPORTER_ASSERT(r, imgA->uniqueID() != a.getGenerationID());
35 REPORTER_ASSERT(r, imgB->uniqueID() != b.getGenerationID());
36}
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
void setImmutable()
Definition: SkBitmap.cpp:400
bool extractSubset(SkBitmap *dst, const SkIRect &subset) const
Definition: SkBitmap.cpp:453
uint32_t getGenerationID() const
Definition: SkBitmap.cpp:361
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:442
static bool b
struct MyStruct a[10]
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104