rename capture interface
This commit is contained in:
parent
3521879ced
commit
26fca2525c
4 changed files with 22 additions and 19 deletions
|
@ -3,26 +3,29 @@
|
||||||
namespace hazelnut {
|
namespace hazelnut {
|
||||||
|
|
||||||
// capture_nvfbc.cpp
|
// capture_nvfbc.cpp
|
||||||
IFramebufferCapture* CreateFramebufferCapture_NVFBC();
|
DisplayCaptureBase* CreateNVFBCDisplayCapture();
|
||||||
|
|
||||||
DisplayCaptureInterface GuessBestCaptureInterface() {
|
DisplayCaptureInterface GuessBestCaptureInterface() {
|
||||||
// The only one we support.
|
// The only one we support.
|
||||||
return DisplayCaptureInterface::NVFBC;
|
return DisplayCaptureInterface::NVFBC;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IFramebufferCapture> CreateFramebufferCapture(DisplayCaptureInterface type) {
|
std::unique_ptr<DisplayCaptureBase> CreateDisplayCapture(DisplayCaptureInterface type) {
|
||||||
IFramebufferCapture* pCapture = nullptr;
|
DisplayCaptureBase* pCapture = nullptr;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case DisplayCaptureInterface::NVFBC: pCapture = CreateFramebufferCapture_NVFBC(); break;
|
case DisplayCaptureInterface::NVFBC: pCapture = CreateNVFBCDisplayCapture(); break;
|
||||||
|
|
||||||
default: return nullptr;
|
default: return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initalize capture.
|
// Initalize capture. Upon failure to capture we destroy the capture interface
|
||||||
if(!pCapture->Initialize())
|
// and then return a null pointer.
|
||||||
|
if(!pCapture->Initialize()) {
|
||||||
|
delete pCapture;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
return std::unique_ptr<IFramebufferCapture>(pCapture);
|
return std::unique_ptr<DisplayCaptureBase>(pCapture);
|
||||||
}
|
}
|
||||||
} // namespace hazelnut
|
} // namespace hazelnut
|
|
@ -25,9 +25,8 @@ namespace hazelnut {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Interface used for framebuffer capture independence.
|
/// Interface used for framebuffer capture independence.
|
||||||
class IFramebufferCapture {
|
struct DisplayCaptureBase {
|
||||||
public:
|
virtual ~DisplayCaptureBase() = default;
|
||||||
virtual ~IFramebufferCapture() = default;
|
|
||||||
|
|
||||||
virtual bool Initialize() = 0;
|
virtual bool Initialize() = 0;
|
||||||
|
|
||||||
|
@ -51,11 +50,11 @@ namespace hazelnut {
|
||||||
/// On a NVIDIA GPU on Windows < 8.1, we prefer NVFBC.
|
/// On a NVIDIA GPU on Windows < 8.1, we prefer NVFBC.
|
||||||
/// Otherwise, we should prefer DXGI.
|
/// Otherwise, we should prefer DXGI.
|
||||||
///
|
///
|
||||||
/// If no API works Invalid is returned.
|
/// If no API is supported on the running system, Invalid is returned.
|
||||||
DisplayCaptureInterface GuessBestCaptureInterface();
|
DisplayCaptureInterface GuessBestCaptureInterface();
|
||||||
|
|
||||||
/// Creates a instance of the framebuffer capture interface for a particular interface.
|
/// Creates a instance of the display capture interface for a particular interface.
|
||||||
/// Returns a null pointer on failure to create.
|
/// Returns a null pointer upon failure to create, a valid pointer otherwise.
|
||||||
std::unique_ptr<IFramebufferCapture> CreateFramebufferCapture(DisplayCaptureInterface type);
|
std::unique_ptr<DisplayCaptureBase> CreateDisplayCapture(DisplayCaptureInterface type);
|
||||||
|
|
||||||
} // namespace hazelnut
|
} // namespace hazelnut
|
|
@ -55,7 +55,7 @@ namespace hazelnut {
|
||||||
return (((srcDim) + (1 << (blockShift)) - 1) >> (blockShift));
|
return (((srcDim) + (1 << (blockShift)) - 1) >> (blockShift));
|
||||||
}
|
}
|
||||||
|
|
||||||
class FramebufferCapture_NVFBC final : public IFramebufferCapture {
|
struct NVFBCDisplayCapture final : public DisplayCaptureBase {
|
||||||
NVFBCRESULT nvfbcStatus;
|
NVFBCRESULT nvfbcStatus;
|
||||||
NvFBCLibrary nvfbcLib;
|
NvFBCLibrary nvfbcLib;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ namespace hazelnut {
|
||||||
u32 diffmapHeight;
|
u32 diffmapHeight;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~FramebufferCapture_NVFBC() { Shutdown(); }
|
virtual ~NVFBCDisplayCapture() { Shutdown(); }
|
||||||
|
|
||||||
void Shutdown() {
|
void Shutdown() {
|
||||||
NvfbcDestroyInstance();
|
NvfbcDestroyInstance();
|
||||||
|
@ -233,7 +233,7 @@ namespace hazelnut {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IFramebufferCapture* CreateFramebufferCapture_NVFBC() {
|
DisplayCaptureBase* CreateNVFBCDisplayCapture() {
|
||||||
return new FramebufferCapture_NVFBC();
|
return new NVFBCDisplayCapture();
|
||||||
}
|
}
|
||||||
} // namespace hazelnut
|
} // namespace hazelnut
|
||||||
|
|
|
@ -178,7 +178,7 @@ int main(int argc, char** argv) {
|
||||||
printf("Hazelnut agent\n");
|
printf("Hazelnut agent\n");
|
||||||
|
|
||||||
// Create a capture interface
|
// Create a capture interface
|
||||||
auto capture = hazelnut::CreateFramebufferCapture(hazelnut::GuessBestCaptureInterface());
|
auto capture = hazelnut::CreateDisplayCapture(hazelnut::GuessBestCaptureInterface());
|
||||||
if(!capture) {
|
if(!capture) {
|
||||||
printf("Failed to create a capture interface\n");
|
printf("Failed to create a capture interface\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -186,6 +186,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
printf("Successfully created a framebuffer capture interface\n");
|
printf("Successfully created a framebuffer capture interface\n");
|
||||||
|
|
||||||
|
|
||||||
bool firstFrame = true;
|
bool firstFrame = true;
|
||||||
std::vector<tileRect> tiles {};
|
std::vector<tileRect> tiles {};
|
||||||
hazelnut::FramebufferInformation framebuffer {};
|
hazelnut::FramebufferInformation framebuffer {};
|
||||||
|
|
Loading…
Reference in a new issue