X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glsnapshot.cpp;h=e37fbccdb4594e9a13b55d96c30aa76cbf4eb144;hb=b25c4b9fccc76976d633bc5b183a84553ab01998;hp=6385fcc140c12ba31fe29fb82a7423c642ae251d;hpb=149ad20e3ca527e7a6b79a6ad942a2690a7a298d;p=apitrace diff --git a/glsnapshot.cpp b/glsnapshot.cpp index 6385fcc..e37fbcc 100644 --- a/glsnapshot.cpp +++ b/glsnapshot.cpp @@ -27,12 +27,13 @@ #include #include +#include "os_path.hpp" #include "image.hpp" #include "glproc.hpp" #include "glsize.hpp" -#if !defined(_WIN32) && !defined(__APPLE__) +#if !defined(TRACE_EGL) && !defined(_WIN32) && !defined(__APPLE__) #include @@ -63,9 +64,14 @@ namespace glsnapshot { /** * Get the contents of the current drawable into an image. */ -static Image::Image * +static image::Image * getDrawableImage(void) { -#if defined(_WIN32) +#if defined(TRACE_EGL) + + // TODO + return NULL; + +#elif defined(_WIN32) HDC hDC = __wglGetCurrentDC(); if (!hDC) { @@ -133,7 +139,7 @@ getDrawableImage(void) { return NULL; } - Image::Image *image = NULL; + image::Image *image = NULL; if (ximage->depth == 24 && ximage->bits_per_pixel == 32 && @@ -141,13 +147,13 @@ getDrawableImage(void) { ximage->green_mask == 0x0000ff00 && ximage->blue_mask == 0x000000ff) { - image = new Image::Image(w, h, 4); + image = new image::Image(w, h, 4); if (image) { const uint32_t *src = (const uint32_t *)ximage->data; uint32_t *dst = (uint32_t*) image->start(); - for (int y = 0; y < h; ++y) { - for (int x = 0; x < w; ++x) { + for (unsigned y = 0; y < h; ++y) { + for (unsigned x = 0; x < w; ++x) { uint32_t bgra = src[x]; uint32_t rgba = (bgra & 0xff00ff00) | ((bgra >> 16) & 0xff) @@ -160,7 +166,7 @@ getDrawableImage(void) { } } } else { - OS::DebugMessage("apitrace: unexpected XImage: " + os::log("apitrace: unexpected XImage: " "bits_per_pixel = %i, " "depth = %i, " "red_mask = 0x%08lx, " @@ -203,12 +209,11 @@ void snapshot(unsigned call_no) { ++frame_no; if (snapshot_prefix) { - Image::Image *src = getDrawableImage(); + image::Image *src = getDrawableImage(); if (src) { - char filename[PATH_MAX]; - snprintf(filename, sizeof filename, "%s%010u.png", snapshot_prefix, call_no); + os::Path filename = os::Path::format("%s%010u.png", snapshot_prefix, call_no); if (src->writePNG(filename)) { - OS::DebugMessage("apitrace: wrote %s\n", filename); + os::log("apitrace: wrote %s\n", filename.str()); } delete src;