2017-08-12 07:55:32 +02:00
|
|
|
#ifndef __APPLE__
|
|
|
|
#include <grabber/OsxFrameGrabberMock.h>
|
|
|
|
|
|
|
|
unsigned __osx_frame_counter = 0;
|
|
|
|
const int __screenWidth = 800;
|
|
|
|
const int __screenHeight = 600;
|
|
|
|
|
|
|
|
void CGGetActiveDisplayList(int max, CGDirectDisplayID *displays, CGDisplayCount *displayCount)
|
|
|
|
{
|
|
|
|
*displayCount = 1;
|
|
|
|
displays[0] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGImageRef CGDisplayCreateImage(CGDirectDisplayID display)
|
|
|
|
{
|
|
|
|
CGImageRef image = new CGImage(__screenWidth, __screenHeight);
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGImageRelease(CGImageRef image)
|
|
|
|
{
|
|
|
|
delete image;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGImageRef CGImageGetDataProvider(CGImageRef image)
|
|
|
|
{
|
|
|
|
__osx_frame_counter++;
|
|
|
|
if (__osx_frame_counter > 100)
|
|
|
|
{
|
|
|
|
__osx_frame_counter = 0;
|
|
|
|
}
|
2020-08-08 23:12:43 +02:00
|
|
|
|
2017-08-12 07:55:32 +02:00
|
|
|
ColorRgb color[4] = {ColorRgb::RED, ColorRgb::BLUE, ColorRgb::GREEN, ColorRgb::WHITE};
|
|
|
|
if (__osx_frame_counter < 25)
|
|
|
|
{
|
|
|
|
color[0] = ColorRgb::WHITE;
|
|
|
|
color[1] = ColorRgb::RED;
|
|
|
|
color[2] = ColorRgb::BLUE;
|
|
|
|
color[3] = ColorRgb::GREEN;
|
|
|
|
}
|
|
|
|
else if(__osx_frame_counter < 50)
|
|
|
|
{
|
|
|
|
color[1] = ColorRgb::WHITE;
|
|
|
|
color[2] = ColorRgb::RED;
|
|
|
|
color[3] = ColorRgb::BLUE;
|
|
|
|
color[0] = ColorRgb::GREEN;
|
|
|
|
}
|
|
|
|
else if(__osx_frame_counter < 75)
|
|
|
|
{
|
|
|
|
color[2] = ColorRgb::WHITE;
|
|
|
|
color[3] = ColorRgb::RED;
|
|
|
|
color[0] = ColorRgb::BLUE;
|
|
|
|
color[1] = ColorRgb::GREEN;
|
|
|
|
}
|
|
|
|
unsigned w = image->width();
|
|
|
|
unsigned h = image->height();
|
2020-08-08 23:12:43 +02:00
|
|
|
|
2017-08-12 07:55:32 +02:00
|
|
|
for (unsigned y=0; y<h; y++)
|
|
|
|
{
|
|
|
|
for (unsigned x=0; x<w; x++)
|
|
|
|
{
|
|
|
|
unsigned id = 0;
|
|
|
|
if (x < w/2 && y < h/2) id = 1;
|
|
|
|
if (x < w/2 && y >= h/2) id = 2;
|
|
|
|
if (x >= w/2 && y < h/2) id = 3;
|
2020-08-08 23:12:43 +02:00
|
|
|
|
2017-08-12 07:55:32 +02:00
|
|
|
image->memptr()[y*w + x] = color[id];
|
|
|
|
}
|
|
|
|
}
|
2020-08-08 23:12:43 +02:00
|
|
|
|
2017-08-12 07:55:32 +02:00
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
CFDataRef CGDataProviderCopyData(CGImageRef image)
|
|
|
|
{
|
|
|
|
const unsigned indexMax = image->width() * image->height() * CGImageGetBitsPerPixel(image);
|
|
|
|
CFDataRef data = new CFData[indexMax];
|
|
|
|
int lineLength = CGImageGetBytesPerRow(image);
|
|
|
|
|
|
|
|
for (unsigned y=0; y<image->height(); y++)
|
|
|
|
{
|
|
|
|
for (unsigned x=0; x<image->width(); x++)
|
|
|
|
{
|
|
|
|
int index = lineLength * y + x * CGImageGetBitsPerPixel(image);
|
|
|
|
|
|
|
|
data[index ] = (*image)(x,y).blue;
|
|
|
|
data[index+1] = (*image)(x,y).green;
|
|
|
|
data[index+2] = (*image)(x,y).red;
|
|
|
|
data[index+3] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char* CFDataGetBytePtr(CFDataRef imgData)
|
|
|
|
{
|
|
|
|
return imgData;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CGImageGetWidth(CGImageRef image)
|
|
|
|
{
|
|
|
|
return image->width();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CGImageGetHeight(CGImageRef image)
|
|
|
|
{
|
|
|
|
return image->height();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CGImageGetBytesPerRow(CGImageRef image)
|
|
|
|
{
|
|
|
|
return image->width()*CGImageGetBitsPerPixel(image);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CGImageGetBitsPerPixel(CGImageRef)
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFRelease(CFDataRef imgData)
|
|
|
|
{
|
|
|
|
delete imgData;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|