954a0a0c33
* Also implemented recording DrawString(string, length, BPoint[] locations), which was previously not recorded at all. * Also implemented playing back recently added drawing commands in PicturePlayer.cpp. I don't quite understand what this is actually used for, but it seemed it was forgotten. I just followed the pattern already established in the code. * The other important bit in this change is to update the pen location when it is needed while recording a BPicture. Often the BView will use PenLocation() in order to transmit drawing commands to the app_server which use absolute coordinates only. This isn't actually so nice, since it means the client has to wait for the server to transmit the current pen location. If there were dedicated link-commands for pen-relative drawing commands, the client could just keep sending without waiting for the server. In any case, the app_server needs to update the pen location in the current DrawState and even the DrawingEngine even while recording a picture, because some next command may need up-2-date state information, such as the font state and the pen location. * I have not yet tried to find /all/ instances where the DrawState needs to be updated while recording. This change should repair /all/ font state changes, all versions of drawing a string, and all versions of StrokeLine(). Change-Id: Ia0f23e7b1cd058f70f76a5849acb2d02e0f0da09 Reviewed-on: https://review.haiku-os.org/c/817 Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
127 lines
4.2 KiB
C++
127 lines
4.2 KiB
C++
/*
|
|
* Copyright 2006-2018 Haiku, Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* Stefano Ceccherini, burton666@libero.it
|
|
* Julian Harnath, <julian.harnath@rwth-achen.de>
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
|
*/
|
|
#ifndef _PICTURE_DATA_WRITER_H
|
|
#define _PICTURE_DATA_WRITER_H
|
|
|
|
|
|
#include <AffineTransform.h>
|
|
#include <InterfaceDefs.h>
|
|
#include <Font.h>
|
|
#include <OS.h>
|
|
|
|
#include <stack>
|
|
|
|
|
|
class Layer;
|
|
class BPositionIO;
|
|
class BRegion;
|
|
|
|
class PictureDataWriter {
|
|
public:
|
|
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 WriteTranslateBy(double x, double y);
|
|
status_t WriteScaleBy(double x, double y);
|
|
status_t WriteRotateBy(double angleRadians);
|
|
status_t WriteSetPattern(const ::pattern& pattern);
|
|
status_t WriteClipToPicture(int32 pictureToken,
|
|
const BPoint& origin, bool inverse);
|
|
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 WriteDrawString(const char* string,
|
|
int32 length, const BPoint* locations,
|
|
int32 locationCount);
|
|
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);
|
|
|
|
status_t WriteBlendLayer(Layer* layer);
|
|
status_t WriteClipToRect(const BRect& rect,
|
|
bool inverse);
|
|
status_t WriteClipToShape(int32 opCount,
|
|
const void* opList, int32 ptCount,
|
|
const void* ptList, bool inverse);
|
|
|
|
protected:
|
|
// throw a status_t on error
|
|
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)); }
|
|
|
|
private:
|
|
BPositionIO* fData;
|
|
std::stack<off_t> fStack;
|
|
};
|
|
|
|
|
|
#endif // _PICTURE_DATA_WRITER_H
|