Files
haiku-beta6/headers/private/interface/PrivateScreen.h
T
Augustin Cavalier cbfbbf6d4d Change BObjectList to take "owning" as a template parameter and adjust all consumers.
Since BObjectList is a template class, this only breaks ABI where
BObjectList was exposed in public methods, and even then it's only
a name mangling break and we should be able to add compatibility
methods if necessary.

(The old "bool owning" member variable is left intact for ABI
compatibility, for the moment, though it's otherwise unused now.)

Tracker's PoseList is the only remaining type that has a "bool owning"
switch in the constructor rather than template parameters.

This should significantly improve the output of static code analysis
tools that previously detected list operations as causing use-after-frees
and double-frees, as well as make code maintenance easier by making it
easier to determine what list owns (or does not own) an object.
It should also be a minor performance optimization, since the branches
for calls to delete/free should now be optimized out altogether.

Still boots to desktop and Tracker, Deskbar, Debugger all tested
and verified as working.

Change-Id: If2a24a6f0d22e7a506ef554fcfdd328907279ed4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8915
Reviewed-by: waddlesplash <[email protected]>
2025-02-06 00:06:32 +00:00

119 lines
2.9 KiB
C++

/*
* Copyright 2002-2009, Haiku Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stefano Ceccherini ([email protected])
* Axel Dörfler, [email protected]
*/
#ifndef _PRIVATE_SCREEN_H_
#define _PRIVATE_SCREEN_H_
#include <Accelerant.h>
#include <GraphicsDefs.h>
#include <ObjectList.h>
#include <Rect.h>
struct color_map;
class BBitmap;
class BApplication;
class BWindow;
#define B_CURRENT_WORKSPACE_INDEX (~0L)
namespace BPrivate {
class BPrivateScreen {
public:
// Constructor and destructor are private. Use the static methods
// Get() and Put() instead.
static BPrivateScreen* Get(BWindow* window);
static BPrivateScreen* Get(int32 id);
static void Put(BPrivateScreen* screen);
static BPrivateScreen* GetNext(BPrivateScreen* screen);
bool IsValid() const;
color_space ColorSpace();
BRect Frame();
int32 ID() const { return fID; }
status_t GetNextID(int32& id);
status_t WaitForRetrace(bigtime_t timeout);
uint8 IndexForColor(uint8 red, uint8 green,
uint8 blue, uint8 alpha);
rgb_color ColorForIndex(const uint8 index);
uint8 InvertIndex(uint8 index);
const color_map* ColorMap();
status_t GetBitmap(BBitmap** bitmap, bool drawCursor,
BRect* bounds);
status_t ReadBitmap(BBitmap* bitmap, bool drawCursor,
BRect* bounds);
rgb_color DesktopColor(uint32 index);
void SetDesktopColor(rgb_color, uint32, bool);
status_t ProposeMode(display_mode* target,
const display_mode* low,
const display_mode* high);
status_t GetModeList(display_mode** _modeList,
uint32* _count);
status_t GetMode(uint32 workspace, display_mode* mode);
status_t SetMode(uint32 workspace, display_mode* mode,
bool makeDefault);
status_t GetDeviceInfo(accelerant_device_info* info);
status_t GetMonitorInfo(monitor_info* info);
status_t GetPixelClockLimits(display_mode* mode,
uint32* _low, uint32* _high);
status_t GetTimingConstraints(
display_timing_constraints* constraints);
status_t SetDPMS(uint32 dpmsState);
uint32 DPMSState();
uint32 DPMSCapabilites();
status_t GetBrightness(float*);
status_t SetBrightness(float);
void* BaseAddress();
uint32 BytesPerRow();
private:
friend class BObjectList<BPrivateScreen, true>;
BPrivateScreen(int32 id);
~BPrivateScreen();
void _Acquire();
bool _Release();
sem_id _RetraceSemaphore();
status_t _GetFrameBufferConfig(
frame_buffer_config& config);
static BPrivateScreen* _Get(int32 id, bool check);
static bool _IsValid(int32 id);
private:
int32 fID;
int32 fReferenceCount;
sem_id fRetraceSem;
bool fRetraceSemValid;
BRect fFrame;
bigtime_t fLastUpdate;
};
} // namespace BPrivate
#endif // _PRIVATE_SCREEN_H_