2006-11-13 10:28:19 +03:00
|
|
|
/*
|
app_server: add new BView layers API
* Add new methods
BView::BeginLayer(uint8 opacity)
BView::EndLayer()
* All drawing between begin and end of a layer is redirected onto an
intermediate bitmap. When ending the layer, this bitmap is
composited onto the view with the opacity given when the layer was
started.
* Layers can be nested arbitrarily and will be blended onto each
other in order. There can also be any arbitrary interleaving of
layer begin/end and drawing operations.
* Internally, drawing commands are redirected into a BPicture between
BeginLayer and EndLayer (but client code need not know or care
about this). Client code can also start/end other BPictures while
inside a layer.
* Uses the PictureBoundingBoxPlayer to determine the size of the
layer bitmap before allocating and drawing into it, so it does not
allocate more memory than necessary and -- more importantly -- it
will not alpha-composite more pixels than necessary.
* Drawing mode is always set to B_OP_ALPHA, blend mode to
(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE) while inside layers. This is
necessary for (a) correct compositing output and (b) for
redirection of drawing into the intermediate bitmap, which uses the
renderer_region offset (in B_OP_COPY, the Painter does not use the
AGG renderer methods, it directly accesses the pixel data. This
would access out-of-bounds without the offset, so B_OP_COPY cannot
be allowed.)
To ensure these modes aren't changed, BView::SetDrawingMode()
and BView::SetBlendingMode() are ignored while inside a layer.
* The main motivation behind this new API is WebKit, which internally
expects such a layers functionality to be present. A performant and
reusable implementation of this functionality can only be done
server-side in app_server.
2015-07-25 16:44:23 +03:00
|
|
|
* Copyright 2006-2015 Haiku, Inc. All rights reserved.
|
2007-10-16 00:13:55 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
2015-03-17 01:41:16 +03:00
|
|
|
* Stefano Ceccherini, burton666@libero.it
|
app_server: add new BView layers API
* Add new methods
BView::BeginLayer(uint8 opacity)
BView::EndLayer()
* All drawing between begin and end of a layer is redirected onto an
intermediate bitmap. When ending the layer, this bitmap is
composited onto the view with the opacity given when the layer was
started.
* Layers can be nested arbitrarily and will be blended onto each
other in order. There can also be any arbitrary interleaving of
layer begin/end and drawing operations.
* Internally, drawing commands are redirected into a BPicture between
BeginLayer and EndLayer (but client code need not know or care
about this). Client code can also start/end other BPictures while
inside a layer.
* Uses the PictureBoundingBoxPlayer to determine the size of the
layer bitmap before allocating and drawing into it, so it does not
allocate more memory than necessary and -- more importantly -- it
will not alpha-composite more pixels than necessary.
* Drawing mode is always set to B_OP_ALPHA, blend mode to
(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE) while inside layers. This is
necessary for (a) correct compositing output and (b) for
redirection of drawing into the intermediate bitmap, which uses the
renderer_region offset (in B_OP_COPY, the Painter does not use the
AGG renderer methods, it directly accesses the pixel data. This
would access out-of-bounds without the offset, so B_OP_COPY cannot
be allowed.)
To ensure these modes aren't changed, BView::SetDrawingMode()
and BView::SetBlendingMode() are ignored while inside a layer.
* The main motivation behind this new API is WebKit, which internally
expects such a layers functionality to be present. A performant and
reusable implementation of this functionality can only be done
server-side in app_server.
2015-07-25 16:44:23 +03:00
|
|
|
* Julian Harnath, <julian.harnath@rwth-achen.de>
|
2006-11-13 10:28:19 +03:00
|
|
|
*/
|
2007-10-16 00:13:55 +04:00
|
|
|
#ifndef _PICTURE_DATA_WRITER_H
|
|
|
|
#define _PICTURE_DATA_WRITER_H
|
|
|
|
|
2006-11-12 23:00:36 +03:00
|
|
|
|
2014-02-05 01:46:55 +04:00
|
|
|
#include <AffineTransform.h>
|
2006-11-12 23:00:36 +03:00
|
|
|
#include <InterfaceDefs.h>
|
|
|
|
#include <Font.h>
|
|
|
|
#include <OS.h>
|
|
|
|
|
|
|
|
#include <stack>
|
|
|
|
|
2015-03-17 01:41:16 +03:00
|
|
|
|
app_server: add new BView layers API
* Add new methods
BView::BeginLayer(uint8 opacity)
BView::EndLayer()
* All drawing between begin and end of a layer is redirected onto an
intermediate bitmap. When ending the layer, this bitmap is
composited onto the view with the opacity given when the layer was
started.
* Layers can be nested arbitrarily and will be blended onto each
other in order. There can also be any arbitrary interleaving of
layer begin/end and drawing operations.
* Internally, drawing commands are redirected into a BPicture between
BeginLayer and EndLayer (but client code need not know or care
about this). Client code can also start/end other BPictures while
inside a layer.
* Uses the PictureBoundingBoxPlayer to determine the size of the
layer bitmap before allocating and drawing into it, so it does not
allocate more memory than necessary and -- more importantly -- it
will not alpha-composite more pixels than necessary.
* Drawing mode is always set to B_OP_ALPHA, blend mode to
(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE) while inside layers. This is
necessary for (a) correct compositing output and (b) for
redirection of drawing into the intermediate bitmap, which uses the
renderer_region offset (in B_OP_COPY, the Painter does not use the
AGG renderer methods, it directly accesses the pixel data. This
would access out-of-bounds without the offset, so B_OP_COPY cannot
be allowed.)
To ensure these modes aren't changed, BView::SetDrawingMode()
and BView::SetBlendingMode() are ignored while inside a layer.
* The main motivation behind this new API is WebKit, which internally
expects such a layers functionality to be present. A performant and
reusable implementation of this functionality can only be done
server-side in app_server.
2015-07-25 16:44:23 +03:00
|
|
|
class Layer;
|
2006-11-12 23:00:36 +03:00
|
|
|
class BPositionIO;
|
2007-10-16 00:13:55 +04:00
|
|
|
class BRegion;
|
|
|
|
|
2006-11-12 23:00:36 +03:00
|
|
|
class PictureDataWriter {
|
|
|
|
public:
|
2015-03-17 01:41:16 +03:00
|
|
|
PictureDataWriter();
|
|
|
|
PictureDataWriter(BPositionIO* data);
|
|
|
|
virtual ~PictureDataWriter();
|
|
|
|
|
|
|
|
status_t SetTo(BPositionIO* data);
|
|
|
|
|
|
|
|
status_t WriteSetHighColor(const rgb_color& color);
|
|
|
|
status_t WriteSetLowColor(const rgb_color& color);
|
|
|
|
status_t WriteSetOrigin(const BPoint& point);
|
|
|
|
status_t WriteSetDrawingMode(const drawing_mode& mode);
|
|
|
|
status_t WriteSetPenLocation(const BPoint& point);
|
|
|
|
status_t WriteSetPenSize(const float& penSize);
|
|
|
|
status_t WriteSetLineMode(const cap_mode& cap,
|
|
|
|
const join_mode& join,
|
|
|
|
const float& miterLimit);
|
|
|
|
status_t WriteSetScale(const float& scale);
|
|
|
|
status_t WriteSetTransform(BAffineTransform transform);
|
|
|
|
status_t WriteSetPattern(const ::pattern& pattern);
|
|
|
|
status_t WriteSetClipping(const BRegion& region);
|
|
|
|
status_t WriteClearClipping();
|
|
|
|
|
|
|
|
status_t WritePushState();
|
|
|
|
status_t WritePopState();
|
|
|
|
|
|
|
|
status_t WriteSetFontFamily(const font_family family);
|
|
|
|
status_t WriteSetFontStyle(const font_style style);
|
|
|
|
status_t WriteSetFontSpacing(const int32& spacing);
|
|
|
|
status_t WriteSetFontSize(const float& size);
|
|
|
|
status_t WriteSetFontRotation(const float& rotation);
|
|
|
|
status_t WriteSetFontEncoding(const int32& encoding);
|
|
|
|
status_t WriteSetFontFlags(const int32& flags);
|
|
|
|
status_t WriteSetFontShear(const float& shear);
|
|
|
|
status_t WriteSetFontFace(const int32& face);
|
|
|
|
|
|
|
|
status_t WriteStrokeLine(const BPoint& start,
|
|
|
|
const BPoint& end);
|
|
|
|
status_t WriteInvertRect(const BRect& rect);
|
|
|
|
status_t WriteDrawRect(const BRect& rect,
|
|
|
|
const bool& fill);
|
|
|
|
status_t WriteDrawRoundRect(const BRect& rect,
|
|
|
|
const BPoint& radius, const bool& fill);
|
|
|
|
status_t WriteDrawEllipse(const BRect& rect,
|
|
|
|
const bool& fill);
|
|
|
|
status_t WriteDrawArc(const BPoint& center,
|
|
|
|
const BPoint& radius,
|
|
|
|
const float& startTheta,
|
|
|
|
const float& arcTheta, const bool& fill);
|
|
|
|
status_t WriteDrawPolygon(const int32& numPoints,
|
|
|
|
BPoint* points, const bool& isClosed,
|
|
|
|
const bool& fill);
|
|
|
|
status_t WriteDrawBezier(const BPoint points[4],
|
|
|
|
const bool& fill);
|
|
|
|
status_t WriteDrawString(const BPoint& where,
|
|
|
|
const char* string, const int32& length,
|
|
|
|
const escapement_delta& delta);
|
|
|
|
status_t WriteDrawShape(const int32& opCount,
|
|
|
|
const void* opList, const int32& ptCount,
|
|
|
|
const void* ptList, const bool& fill);
|
|
|
|
status_t WriteDrawBitmap(const BRect& srcRect,
|
|
|
|
const BRect& dstRect, const int32& width,
|
|
|
|
const int32& height,
|
|
|
|
const int32& bytesPerRow,
|
|
|
|
const int32& colorSpace,
|
|
|
|
const int32& flags,
|
|
|
|
const void* data, const int32& length);
|
|
|
|
|
|
|
|
status_t WriteDrawPicture(const BPoint& where,
|
|
|
|
const int32& token);
|
2007-08-13 11:20:43 +04:00
|
|
|
|
app_server: add new BView layers API
* Add new methods
BView::BeginLayer(uint8 opacity)
BView::EndLayer()
* All drawing between begin and end of a layer is redirected onto an
intermediate bitmap. When ending the layer, this bitmap is
composited onto the view with the opacity given when the layer was
started.
* Layers can be nested arbitrarily and will be blended onto each
other in order. There can also be any arbitrary interleaving of
layer begin/end and drawing operations.
* Internally, drawing commands are redirected into a BPicture between
BeginLayer and EndLayer (but client code need not know or care
about this). Client code can also start/end other BPictures while
inside a layer.
* Uses the PictureBoundingBoxPlayer to determine the size of the
layer bitmap before allocating and drawing into it, so it does not
allocate more memory than necessary and -- more importantly -- it
will not alpha-composite more pixels than necessary.
* Drawing mode is always set to B_OP_ALPHA, blend mode to
(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE) while inside layers. This is
necessary for (a) correct compositing output and (b) for
redirection of drawing into the intermediate bitmap, which uses the
renderer_region offset (in B_OP_COPY, the Painter does not use the
AGG renderer methods, it directly accesses the pixel data. This
would access out-of-bounds without the offset, so B_OP_COPY cannot
be allowed.)
To ensure these modes aren't changed, BView::SetDrawingMode()
and BView::SetBlendingMode() are ignored while inside a layer.
* The main motivation behind this new API is WebKit, which internally
expects such a layers functionality to be present. A performant and
reusable implementation of this functionality can only be done
server-side in app_server.
2015-07-25 16:44:23 +03:00
|
|
|
status_t WriteBlendLayer(Layer* layer);
|
|
|
|
|
2006-11-28 17:52:51 +03:00
|
|
|
protected:
|
2007-05-12 12:46:56 +04:00
|
|
|
// throw a status_t on error
|
2015-03-17 01:41:16 +03:00
|
|
|
void BeginOp(const int16& op);
|
|
|
|
void EndOp();
|
|
|
|
void WriteData(const void* data, size_t size);
|
|
|
|
template <typename T> void Write(const T& data)
|
|
|
|
{ WriteData(&data, sizeof(data)); }
|
|
|
|
|
2006-11-28 17:52:51 +03:00
|
|
|
private:
|
2015-03-17 01:41:16 +03:00
|
|
|
BPositionIO* fData;
|
|
|
|
std::stack<off_t> fStack;
|
2006-11-12 23:00:36 +03:00
|
|
|
};
|
|
|
|
|
2015-03-17 01:41:16 +03:00
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
#endif // _PICTURE_DATA_WRITER_H
|