54 if (
n > count)
n = count;
70 if (
n > count)
n = count;
72 for (
int i = 0;
i <
n; ++
i) {
123 if (
color.a() != 0) {
147 if (
color.a() != 0) {
164 }
else if (
bgcolor.a() == 0xFF) {
173 }
else if (
bgcolor.a() == 0xFF) {
219 if (count <=
batch) {
241 if (count <=
batch) {
270 }
while (remaining_ > 0);
276 if (
n > remaining_)
n = remaining_;
277 stream_->Read(buf_,
n);
282 std::unique_ptr<PixelStream> stream_;
298template <
typename Delegate>
319 if (
n > count)
n = count;
357 if (n > remaining_) n = remaining_;
358 stream_.Read(buf_, n);
363 uint16_t dnext(Color* buf, int16_t count) {
366 if (n > remaining_) n = remaining_;
367 stream_.Read(buf_, n);
374 memcpy(buf, buf_ + idx_, count *
sizeof(Color));
383 const int16_t width_;
384 const int16_t width_skip_;
391template <
typename Stream>
406template <
typename Stream>
433 const Box& clip_box)
const = 0;
446 void drawTo(
const Surface&
s)
const override {
449 if (bounds.
empty())
return;
450 std::unique_ptr<PixelStream>
stream;
463template <
typename Iterable,
typename ColorMode,
typename StreamType>
503 return std::unique_ptr<PixelStream>(
504 new StreamType(resource_.iterator(), color_mode_));
515 return std::unique_ptr<StreamType>(
516 new StreamType(resource_.iterator(), color_mode_));
521 return color_mode_.transparency();
529 ColorMode color_mode_;
BufferedRectWriter & writer
Axis-aligned integer rectangle.
int16_t width() const
Width in pixels (inclusive coordinates).
int16_t xMin() const
Minimum x (inclusive).
int16_t xMax() const
Maximum x (inclusive).
bool empty() const
Return whether the box is empty.
int16_t height() const
Height in pixels (inclusive coordinates).
Box translate(int16_t x_offset, int16_t y_offset) const
Return a translated copy of this box.
int16_t yMax() const
Maximum y (inclusive).
int32_t area() const
Area in pixels.
static Box Intersect(const Box &a, const Box &b)
Return the intersection of two boxes (may be empty).
int16_t yMin() const
Minimum y (inclusive).
Buffered writer for arbitrary pixels with per-pixel colors.
ARGB8888 color stored as a 32-bit unsigned integer.
The abstraction for drawing to a display.
virtual void write(Color *color, uint32_t pixel_count)=0
Write pixels into the current address window.
void setAddress(const Box &bounds, BlendingMode blending_mode)
Convenience overload for setAddress() using a Box.
Interface for objects that can be drawn to an output device.
virtual Box extents() const =0
Return the bounding box encompassing all pixels that need to be drawn.
Stream of pixels in row-major order.
virtual void Skip(uint32_t count)
Skip count pixels.
virtual void Read(Color *buf, uint16_t size)=0
Read up to size pixels into buf.
Convenience wrapper for images backed by a byte stream.
TransparencyMode getTransparencyMode() const override
Return transparency mode derived from color mode.
const Iterable & resource() const
Access underlying resource.
Box extents() const override
Return extents of the image.
SimpleStreamable(Box extents, Iterable resource, const ColorMode &color_mode=ColorMode())
Construct from extents and a resource.
SimpleStreamable(Box extents, Box anchor_extents, Iterable resource, const ColorMode &color_mode=ColorMode())
Construct from extents, anchor extents, and a resource.
Box anchorExtents() const override
Return anchor extents used for alignment.
ColorMode & color_mode()
Access color mode (mutable).
std::unique_ptr< PixelStream > createStream(const Box &bounds) const override
Create a pixel stream for a clipped box.
std::unique_ptr< StreamType > createRawStream() const
Create the raw stream type.
const ColorMode & color_mode() const
Access color mode (const).
void setColorMode(const ColorMode &color_mode)
Set the color mode.
SimpleStreamable(int16_t width, int16_t height, Iterable resource, const ColorMode &color_mode=ColorMode())
Construct from width/height and a resource.
std::unique_ptr< PixelStream > createStream() const override
Create a pixel stream for the full extents.
Drawable that can provide a sequential pixel stream.
virtual std::unique_ptr< PixelStream > createStream() const =0
Create a stream covering the full extents().
virtual TransparencyMode getTransparencyMode() const
Return the transparency mode for pixels in this stream.
virtual std::unique_ptr< PixelStream > createStream(const Box &clip_box) const =0
Create a stream for the given clipped bounds.
Low-level handle used to draw to an underlying device.
int16_t dy() const
Return the y offset to apply to drawn objects.
Color bgcolor() const
Return the background color used for blending.
int16_t dx() const
Return the x offset to apply to drawn objects.
BlendingMode blending_mode() const
Return the default blending mode for drawing.
FillMode fill_mode() const
Return the fill mode the drawable should observe. FillMode::kVisible If FillMode::kExtents,...
DisplayOutput & out() const
Return the device output.
void read(Color *buf, uint16_t count)
void blend(Color *buf, uint16_t count, BlendingMode blending_mode)
void skip(uint32_t count)
BufferingStream(std::unique_ptr< PixelStream > stream, uint32_t count)
SubRectangleStream(SubRectangleStream &&)=default
void Read(Color *buf, uint16_t count) override
Read up to size pixels into buf.
SubRectangleStream(Delegate delegate, uint32_t count, int16_t width, int16_t width_skip)
SubRectangleStream< Stream > MakeSubRectangle(Stream stream, const Box &extents, const Box &bounds)
void writeRectVisible(DisplayOutput &output, const Box &extents, PixelStream *stream, BlendingMode mode)
void fillPaintRectOverBg(DisplayOutput &output, const Box &extents, Color bgcolor, PixelStream *stream, BlendingMode mode)
void writeRectVisibleOverBg(DisplayOutput &output, const Box &extents, Color bgcolor, PixelStream *stream, BlendingMode mode)
void writeRectVisibleOverOpaqueBg(DisplayOutput &output, const Box &extents, Color bgcolor, PixelStream *stream, BlendingMode mode)
void fillReplaceRect(DisplayOutput &output, const Box &extents, PixelStream *stream, BlendingMode mode)
void fillPaintRectOverOpaqueBg(DisplayOutput &output, const Box &extents, Color bgColor, PixelStream *stream, BlendingMode mode)
void FillRectFromStream(DisplayOutput &output, const Box &extents, PixelStream *stream, Color bgcolor, FillMode fill_mode, BlendingMode blending_mode, TransparencyMode transparency)
Defines 140 opaque HTML named colors.
BlendingMode
Porter-Duff style blending modes.
void ApplyBlendingInPlace(BlendingMode mode, Color *dst, const Color *src, int16_t count)
Color AlphaBlend(Color bgc, Color fgc)
static const uint8_t kPixelWritingBufferSize
decltype(std::declval< Resource >().iterator()) StreamType
Stream type produced by a resource iterable.
TransparencyMode
Transparency information for a stream or color mode.
@ kNone
All colors are fully opaque.
@ kFull
Colors may include partial transparency (alpha channel).
Color AlphaBlendOverOpaque(Color bgc, Color fgc)
std::unique_ptr< PixelStream > SubRectangle(Stream stream, const Box &extents, const Box &bounds)
Create a pixel stream over a sub-rectangle of a larger stream.
FillMode
Specifies whether a Drawable should fill its entire extents box, including fully transparent pixels.
@ kExtents
Fill the entire extents box (possibly with fully transparent pixels).
BlendingMode blending_mode