mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Refactor/Create APT/DNF Repository (#1648)
This commit is contained in:
97
include/grabber/directx/DirectXGrabber.h
Normal file
97
include/grabber/directx/DirectXGrabber.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
// DirectX 9 header
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
// Hyperion-utils includes
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <hyperion/GrabberWrapper.h>
|
||||
#include <hyperion/Grabber.h>
|
||||
|
||||
// qt includes
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
///
|
||||
/// @brief The DirectX9 capture implementation
|
||||
///
|
||||
class DirectXGrabber : public Grabber
|
||||
{
|
||||
public:
|
||||
|
||||
DirectXGrabber(int display=0, int cropLeft=0, int cropRight=0, int cropTop=0, int cropBottom=0);
|
||||
|
||||
virtual ~DirectXGrabber();
|
||||
|
||||
///
|
||||
/// Captures a single snapshot of the display and writes the data to the given image. The
|
||||
/// provided image should have the same dimensions as the configured values (_width and _height)
|
||||
///
|
||||
/// @param[out] image The snapped screenshot
|
||||
///
|
||||
int grabFrame(Image<ColorRgb> & image);
|
||||
|
||||
///
|
||||
/// @brief Set a new video mode
|
||||
///
|
||||
void setVideoMode(VideoMode mode) override;
|
||||
|
||||
///
|
||||
/// @brief Apply new width/height values, overwrite Grabber.h implementation
|
||||
///
|
||||
bool setWidthHeight(int /* width */, int /*height*/) override { return true; }
|
||||
|
||||
///
|
||||
/// @brief Apply new pixelDecimation
|
||||
///
|
||||
bool setPixelDecimation(int pixelDecimation) override;
|
||||
|
||||
///
|
||||
/// Set the crop values
|
||||
/// @param cropLeft Left pixel crop
|
||||
/// @param cropRight Right pixel crop
|
||||
/// @param cropTop Top pixel crop
|
||||
/// @param cropBottom Bottom pixel crop
|
||||
///
|
||||
void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom);
|
||||
|
||||
///
|
||||
/// @brief Apply display index
|
||||
///
|
||||
bool setDisplayIndex(int index) override;
|
||||
|
||||
/// @brief Discover QT screens available (for configuration).
|
||||
///
|
||||
/// @param[in] params Parameters used to overwrite discovery default behaviour
|
||||
///
|
||||
/// @return A JSON structure holding a list of devices found
|
||||
///
|
||||
QJsonObject discover(const QJsonObject& params);
|
||||
|
||||
private:
|
||||
///
|
||||
/// @brief Setup a new capture display, will free the previous one
|
||||
/// @return True on success, false if no display is found
|
||||
///
|
||||
bool setupDisplay();
|
||||
|
||||
///
|
||||
/// @brief free the _screen pointer
|
||||
///
|
||||
void freeResources();
|
||||
|
||||
private:
|
||||
unsigned _display;
|
||||
unsigned _displayWidth;
|
||||
unsigned _displayHeight;
|
||||
RECT* _srcRect;
|
||||
|
||||
IDirect3D9* _d3d9;
|
||||
IDirect3DDevice9* _device;
|
||||
IDirect3DSurface9* _surface;
|
||||
IDirect3DSurface9* _surfaceDest;
|
||||
};
|
42
include/grabber/directx/DirectXWrapper.h
Normal file
42
include/grabber/directx/DirectXWrapper.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <hyperion/GrabberWrapper.h>
|
||||
#include <grabber/directx/DirectXGrabber.h>
|
||||
|
||||
class DirectXWrapper: public GrabberWrapper
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs the DirectX grabber with a specified grab size and update rate.
|
||||
///
|
||||
/// @param[in] updateRate_Hz The image grab rate [Hz]
|
||||
/// @param[in] display Display to be grabbed
|
||||
/// @param[in] pixelDecimation Decimation factor for image [pixels]
|
||||
/// @param[in] cropLeft Remove from left [pixels]
|
||||
/// @param[in] cropRight Remove from right [pixels]
|
||||
/// @param[in] cropTop Remove from top [pixels]
|
||||
/// @param[in] cropBottom Remove from bottom [pixels]
|
||||
|
||||
///
|
||||
DirectXWrapper( int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ,
|
||||
int display=0,
|
||||
int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION,
|
||||
int cropLeft=0, int cropRight=0,
|
||||
int cropTop=0, int cropBottom=0
|
||||
);
|
||||
|
||||
///
|
||||
/// Destructor of this DirectX grabber. Releases any claimed resources.
|
||||
///
|
||||
virtual ~DirectXWrapper() {};
|
||||
|
||||
public slots:
|
||||
///
|
||||
/// Performs a single frame grab and computes the led-colors
|
||||
///
|
||||
virtual void action();
|
||||
|
||||
private:
|
||||
/// The actual grabber
|
||||
DirectXGrabber _grabber;
|
||||
};
|
Reference in New Issue
Block a user