]> git.cworth.org Git - apitrace/commitdiff
Kill glsnapshot.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 24 Nov 2011 19:12:34 +0000 (19:12 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 24 Nov 2011 19:12:34 +0000 (19:12 +0000)
The ability of taking snaphshots while tracing was meant for test
automation of apitrace itself, but even so, it was not very robust
-- apps that used glXCreateWindow would not find be able to determine
window id --, so remove this now that a custom made test suite is
being developed.

CMakeLists.txt
egltrace.py
glsnapshot.cpp [deleted file]
glsnapshot.hpp [deleted file]
glxtrace.py

index 8dd547dbf1928c009bd3c4b0ecfcf81e9896fabe..a98103f23f22719d8249c27824b4ff4359733ed4 100755 (executable)
@@ -422,7 +422,6 @@ else ()
         ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
         glxtrace.cpp
         glcaps.cpp
-        glsnapshot.cpp
     )
 
     set_target_properties (glxtrace PROPERTIES
@@ -453,7 +452,6 @@ if (EGL_FOUND)
         ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
         egltrace.cpp
         glcaps.cpp
-        glsnapshot.cpp
     )
 
     set_property (
index 27a7b0f2b0983c8c677e29e2f06cceae965449a3..994c1ee88a0750e5d29fa1d5c823a9f7f462efa6 100644 (file)
@@ -49,20 +49,6 @@ class EglTracer(GlTracer):
     def trace_function_impl_body(self, function):
         GlTracer.trace_function_impl_body(self, function)
 
-        # Take snapshots
-        if function.name == 'eglSwapBuffers':
-            print '    glsnapshot::snapshot(__call);'
-        if function.name in ('glFinish', 'glFlush'):
-            print '    tracer_context *ctx = __get_context();'
-            print '    GLint __draw_framebuffer = 0;'
-            print '    __glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &__draw_framebuffer);'
-            print '    if (__draw_framebuffer == 0 && ctx->profile == PROFILE_COMPAT) {'
-            print '        GLint __draw_buffer = GL_NONE;'
-            print '        __glGetIntegerv(GL_DRAW_BUFFER, &__draw_buffer);'
-            print '        if (__draw_buffer == GL_FRONT) {'
-            print '             glsnapshot::snapshot(__call);'
-            print '        }'
-            print '    }'
         if function.name == 'eglMakeCurrent':
             print '    // update the profile'
             print '    if (ctx != EGL_NO_CONTEXT) {'
@@ -98,7 +84,6 @@ if __name__ == '__main__':
     print
     print '#include "glproc.hpp"'
     print '#include "glsize.hpp"'
-    print '#include "glsnapshot.hpp"'
     print
     print 'static __eglMustCastToProperFunctionPointerType __unwrap_proc_addr(const char * procname, __eglMustCastToProperFunctionPointerType procPtr);'
     print
diff --git a/glsnapshot.cpp b/glsnapshot.cpp
deleted file mode 100644 (file)
index e37fbcc..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <assert.h>
-#include <stdint.h>
-
-#include "os_path.hpp"
-#include "image.hpp"
-#include "glproc.hpp"
-#include "glsize.hpp"
-
-
-#if !defined(TRACE_EGL) && !defined(_WIN32) && !defined(__APPLE__)
-
-
-#include <X11/Xproto.h>
-
-
-static int
-errorHandler(Display *display, XErrorEvent *event)
-{
-    if (event->error_code == BadDrawable &&
-        event->request_code == X_GetGeometry) {
-        return 0;
-    }
-
-    char error_text[512];
-    XGetErrorText(display, event->error_code, error_text, sizeof error_text);
-    fprintf(stderr, "X Error of failed request:  %s\n", error_text);
-
-    return 0;
-}
-
-
-#endif /* !_WIN32 && !__APPLE__ */
-
-
-namespace glsnapshot {
-
-
-/**
- * Get the contents of the current drawable into an image.
- */
-static image::Image *
-getDrawableImage(void) {
-#if defined(TRACE_EGL)
-
-    // TODO
-    return NULL;
-
-#elif defined(_WIN32)
-
-    HDC hDC = __wglGetCurrentDC();
-    if (!hDC) {
-        return false;
-    }
-
-    HWND hWnd = WindowFromDC(hDC);
-    RECT rect;
-
-    if (!GetClientRect(hWnd, &rect)) {
-       return false;
-    }
-
-    int width  = rect.right  - rect.left;
-    int height = rect.bottom - rect.top;
-
-    // TODO: http://msdn.microsoft.com/en-us/library/dd183402
-
-    return NULL;
-
-#elif defined(__APPLE__)
-
-    // TODO
-    return NULL;
-
-#else
-
-    Display *display;
-    Drawable drawable;
-    Window root;
-    int x, y;
-    unsigned int w, h, bw, depth;
-
-    __glFinish();
-    __glXWaitGL();
-
-    display = __glXGetCurrentDisplay();
-    if (!display) {
-        return false;
-    }
-
-    drawable = __glXGetCurrentDrawable();
-    if (drawable == None) {
-        return false;
-    }
-
-    /*
-     * XXX: This does not work for drawables created with glXCreateWindow
-     */
-
-    int (*oldErrorHandler)(Display *, XErrorEvent *);
-    Status status;
-
-    oldErrorHandler = XSetErrorHandler(errorHandler);
-    status = XGetGeometry(display, drawable, &root, &x, &y, &w, &h, &bw, &depth);
-    XSetErrorHandler(oldErrorHandler);
-    if (!status) {
-        return false;
-    }
-
-    XImage *ximage;
-
-    ximage = XGetImage(display, drawable, 0, 0, w, h, AllPlanes, ZPixmap);
-    if (!ximage) {
-        return NULL;
-    }
-
-    image::Image *image = NULL;
-
-    if (ximage->depth          == 24 &&
-        ximage->bits_per_pixel == 32 &&
-        ximage->red_mask       == 0x00ff0000 &&
-        ximage->green_mask     == 0x0000ff00 &&
-        ximage->blue_mask      == 0x000000ff) {
-
-        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 (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)
-                                  | ((bgra & 0xff) << 16);
-                    dst[x] = rgba;
-                }
-
-                src += ximage->bytes_per_line / sizeof *src;
-                dst += image->stride() / sizeof *src;
-            }
-        }
-    } else {
-        os::log("apitrace: unexpected XImage: "
-                         "bits_per_pixel = %i, "
-                         "depth = %i, "
-                         "red_mask = 0x%08lx, "
-                         "green_mask = 0x%08lx, "
-                         "blue_mask = 0x%08lx\n",
-                         ximage->bits_per_pixel,
-                         ximage->depth,
-                         ximage->red_mask,
-                         ximage->green_mask,
-                         ximage->blue_mask);
-    }
-
-    XDestroyImage(ximage);
-
-    return image;
-#endif
-}
-
-
-// Prefix of the snapshot images to take, if not NULL.
-static const char *snapshot_prefix = NULL;
-
-// Maximum number of frames to trace.
-static unsigned max_frames = ~0;
-
-// Current frame number.
-static unsigned frame_no = 0;
-
-
-void snapshot(unsigned call_no) {
-
-    if (frame_no == 0) {
-        const char *max_frames_str = getenv("TRACE_FRAMES");
-        if (max_frames_str) {
-            max_frames = atoi(max_frames_str);
-        }
-        snapshot_prefix = getenv("TRACE_SNAPSHOT");
-    }
-
-    ++frame_no;
-
-    if (snapshot_prefix) {
-        image::Image *src = getDrawableImage();
-        if (src) {
-            os::Path filename = os::Path::format("%s%010u.png", snapshot_prefix, call_no);
-            if (src->writePNG(filename)) {
-                os::log("apitrace: wrote %s\n", filename.str());
-            }
-
-            delete src;
-        }
-    }
-
-    if (frame_no >= max_frames) {
-        exit(0);
-    }
-}
-
-
-} /* namespace glsnapshot */
diff --git a/glsnapshot.hpp b/glsnapshot.hpp
deleted file mode 100644 (file)
index 2bdb6f3..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef _GLSNAPSHOT_HPP_
-#define _GLSNAPSHOT_HPP_
-
-
-class JSONWriter;
-
-
-namespace image {
-    class Image;
-}
-
-
-namespace glsnapshot {
-
-
-image::Image *
-getDrawableImage(void);
-
-void snapshot(unsigned call_no);
-
-} /* namespace glsnapshot */
-
-
-#endif /* _GLSNAPSHOT_HPP_ */
index 3e91f00ed47e1bed2418a78deaa6e9f88abc8695..be577cb0d67f8bbf6585787cc0b9b4376584490b 100644 (file)
@@ -41,23 +41,6 @@ class GlxTracer(GlTracer):
         # The symbols visible in libGL.so can vary, so expose them all
         return True
 
-    def trace_function_impl_body(self, function):
-        GlTracer.trace_function_impl_body(self, function)
-
-        # Take snapshots
-        if function.name == 'glXSwapBuffers':
-            print '    glsnapshot::snapshot(__call);'
-        if function.name in ('glFinish', 'glFlush'):
-            print '    GLint __draw_framebuffer = 0;'
-            print '    __glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &__draw_framebuffer);'
-            print '    if (__draw_framebuffer == 0) {'
-            print '        GLint __draw_buffer = GL_NONE;'
-            print '        __glGetIntegerv(GL_DRAW_BUFFER, &__draw_buffer);'
-            print '        if (__draw_buffer == GL_FRONT) {'
-            print '             glsnapshot::snapshot(__call);'
-            print '        }'
-            print '    }'
-
     def wrap_ret(self, function, instance):
         GlTracer.wrap_ret(self, function, instance)
 
@@ -83,7 +66,6 @@ if __name__ == '__main__':
     print
     print '#include "glproc.hpp"'
     print '#include "glsize.hpp"'
-    print '#include "glsnapshot.hpp"'
     print
     print 'static __GLXextFuncPtr __unwrap_proc_addr(const GLubyte * procName, __GLXextFuncPtr procPtr);'
     print