1/* 2 * Copyright 2007, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Pfeiffer 7 */ 8 9#ifndef _PICTURE_TEST_H 10#define _PICTURE_TEST_H 11 12#include <InterfaceKit.h> 13#include <String.h> 14 15typedef void (draw_func)(BView *view, BRect frame); 16 17class PictureTest { 18 19public: 20 PictureTest(); 21 virtual ~PictureTest(); 22 23 void SetColorSpace(color_space colorSpace) { fColorSpace = colorSpace; } 24 25 bool Test(draw_func* func, BRect frame); 26 27 const char *ErrorMessage() const { return fErrorMessage.String(); } 28 29 BBitmap *DirectBitmap(bool detach = false); 30 BBitmap *BitmapFromPicture(bool detach = false); 31 BBitmap *BitmapFromRestoredPicture(bool detach = false); 32 33protected: 34 virtual BPicture *SaveAndRestore(BPicture *picture) = 0; 35 void SetErrorMessage(const char* message); 36 37private: 38 39 void CleanUp(); 40 41 BPicture *RecordPicture(draw_func* func, BRect frame); 42 43 BBitmap *CreateBitmap(draw_func* func, BRect frame); 44 BBitmap *CreateBitmap(BPicture *picture, BRect frame); 45 46 bool IsSame(BBitmap *bitmap1, BBitmap *bitmap2, BString &reason); 47 48 color_space fColorSpace; 49 50 BBitmap *fDirectBitmap; 51 BBitmap *fBitmapFromPicture; 52 BBitmap *fBitmapFromRestoredPicture; 53 54 BString fErrorMessage; 55}; 56 57class FlattenPictureTest : public PictureTest 58{ 59public: 60 FlattenPictureTest(); 61 62protected: 63 BPicture *SaveAndRestore(BPicture *picture); 64}; 65 66class ArchivePictureTest : public PictureTest 67{ 68public: 69 ArchivePictureTest(); 70 71protected: 72 BPicture *SaveAndRestore(BPicture *picture); 73}; 74 75#endif 76