5#ifndef RUNTIME_VM_BITMAP_H_
6#define RUNTIME_VM_BITMAP_H_
20 BitmapBuilder() : length_(0), data_size_in_bytes_(kInlineCapacityInBytes) {
21 memset(data_.inline_, 0, data_size_in_bytes_);
26 length_(other.length_),
27 data_size_in_bytes_(other.data_size_in_bytes_) {
28 if (data_size_in_bytes_ == kInlineCapacityInBytes) {
29 memmove(data_.inline_, other.data_.
inline_, kInlineCapacityInBytes);
31 data_.ptr_ = AllocBackingStore(data_size_in_bytes_);
32 memmove(data_.ptr_, other.data_.
ptr_, data_size_in_bytes_);
36 intptr_t
Length()
const {
return length_; }
42 bool Get(intptr_t bit_offset)
const;
43 void Set(intptr_t bit_offset,
bool value);
61 static constexpr intptr_t kIncrementSizeInBytes = 16;
62 static constexpr intptr_t kInlineCapacityInBytes = 16;
64 bool InRange(intptr_t
offset)
const {
67 "Fatal error in BitmapBuilder::InRange :"
68 " invalid bit_offset, %" Pd "\n",
74 bool InBackingStore(intptr_t bit_offset) {
76 return byte_offset < data_size_in_bytes_;
79 uint8_t* BackingStore() {
80 return data_size_in_bytes_ == kInlineCapacityInBytes ? &data_.inline_[0]
84 const uint8_t* BackingStore()
const {
85 return data_size_in_bytes_ == kInlineCapacityInBytes ? &data_.inline_[0]
89 static uint8_t* AllocBackingStore(intptr_t size_in_bytes) {
94 bool GetBit(intptr_t bit_offset)
const;
95 void SetBit(intptr_t bit_offset,
bool value);
101 intptr_t data_size_in_bytes_;
void AppendAsBytesTo(BaseWriteStream *stream) const
void Read(ReadStream *stream)
uint8_t inline_[kInlineCapacityInBytes]
void Write(BaseWriteStream *stream) const
bool Get(intptr_t bit_offset) const
void Set(intptr_t bit_offset, bool value)
BitmapBuilder(const BitmapBuilder &other)
void SetRange(intptr_t min, intptr_t max, bool value)
void SetLength(intptr_t length)
static ThreadState * Current()
ElementType * Alloc(intptr_t length)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
constexpr intptr_t kBitsPerByteLog2