Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
fuchsia_test_utils::Screenshot Class Reference

#include <screenshot.h>

Public Member Functions

 Screenshot (const zx::vmo &screenshot_vmo, uint64_t width, uint64_t height, int rotation)
 
Pixel GetPixelAt (uint64_t x, uint64_t y) const
 
std::map< Pixel, uint32_t > Histogram () const
 
std::vector< std::vector< Pixel > > screenshot () const
 
uint64_t width () const
 
uint64_t height () const
 

Static Public Attributes

static const Pixel kBlack = Pixel(0, 0, 0, 255)
 
static const Pixel kBlue = Pixel(255, 0, 0, 255)
 
static const Pixel kRed = Pixel(0, 0, 255, 255)
 
static const Pixel kMagenta = Pixel(255, 0, 255, 255)
 
static const Pixel kGreen = Pixel(0, 255, 0, 255)
 

Detailed Description

Definition at line 46 of file screenshot.h.

Constructor & Destructor Documentation

◆ Screenshot()

fuchsia_test_utils::Screenshot::Screenshot ( const zx::vmo &  screenshot_vmo,
uint64_t  width,
uint64_t  height,
int  rotation 
)

Definition at line 21 of file screenshot.cc.

25 : width_(width), height_(height) {
26 FML_CHECK(rotation == 0 || rotation == 90 || rotation == 270);
27 if (rotation == 90 || rotation == 270) {
28 std::swap(width_, height_);
29 }
30 // Populate |screenshot_| from |screenshot_vmo|.
31 uint64_t vmo_size;
32 screenshot_vmo.get_prop_content_size(&vmo_size);
33 FML_CHECK(vmo_size == kBytesPerPixel * width_ * height_);
34 uint8_t* vmo_host = nullptr;
35 auto status = zx::vmar::root_self()->map(
36 ZX_VM_PERM_READ, /*vmar_offset*/ 0, screenshot_vmo,
37 /*vmo_offset*/ 0, vmo_size, reinterpret_cast<uintptr_t*>(&vmo_host));
38 FML_CHECK(status == ZX_OK);
39 ExtractScreenshotFromVMO(vmo_host);
40 // map the pointer.
41 uintptr_t address = reinterpret_cast<uintptr_t>(vmo_host);
42 status = zx::vmar::root_self()->unmap(address, vmo_size);
43 FML_CHECK(status == ZX_OK);
44}
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341
#define FML_CHECK(condition)
Definition: logging.h:85

Member Function Documentation

◆ GetPixelAt()

Pixel fuchsia_test_utils::Screenshot::GetPixelAt ( uint64_t  x,
uint64_t  y 
) const

Definition at line 53 of file screenshot.cc.

53 {
54 FML_CHECK(x >= 0 && x < width_ && y >= 0 && y < height_)
55 << "Index out of bounds";
56 return screenshot_[y][x];
57}
double y
double x

◆ height()

uint64_t fuchsia_test_utils::Screenshot::height ( ) const
inline

Definition at line 94 of file screenshot.h.

94{ return height_; }

◆ Histogram()

std::map< Pixel, uint32_t > fuchsia_test_utils::Screenshot::Histogram ( ) const

Definition at line 59 of file screenshot.cc.

59 {
60 std::map<Pixel, uint32_t> histogram;
61 FML_CHECK(screenshot_.size() == height_ && screenshot_[0].size() == width_);
62 for (size_t i = 0; i < height_; i++) {
63 for (size_t j = 0; j < width_; j++) {
64 histogram[screenshot_[i][j]]++;
65 }
66 }
67 return histogram;
68}

◆ screenshot()

std::vector< std::vector< Pixel > > fuchsia_test_utils::Screenshot::screenshot ( ) const
inline

Definition at line 90 of file screenshot.h.

90{ return screenshot_; }

◆ width()

uint64_t fuchsia_test_utils::Screenshot::width ( ) const
inline

Definition at line 92 of file screenshot.h.

92{ return width_; }

Member Data Documentation

◆ kBlack

const Pixel fuchsia_test_utils::Screenshot::kBlack = Pixel(0, 0, 0, 255)
inlinestatic

Definition at line 49 of file screenshot.h.

◆ kBlue

const Pixel fuchsia_test_utils::Screenshot::kBlue = Pixel(255, 0, 0, 255)
inlinestatic

Definition at line 50 of file screenshot.h.

◆ kGreen

const Pixel fuchsia_test_utils::Screenshot::kGreen = Pixel(0, 255, 0, 255)
inlinestatic

Definition at line 53 of file screenshot.h.

◆ kMagenta

const Pixel fuchsia_test_utils::Screenshot::kMagenta = Pixel(255, 0, 255, 255)
inlinestatic

Definition at line 52 of file screenshot.h.

◆ kRed

const Pixel fuchsia_test_utils::Screenshot::kRed = Pixel(0, 0, 255, 255)
inlinestatic

Definition at line 51 of file screenshot.h.


The documentation for this class was generated from the following files: