1 /* 2 ** Copyright 2011, The Android Open Source Project 3 ** 4 ** Licensed under the Apache License, Version 2.0 (the "License"); 5 ** you may not use this file except in compliance with the License. 6 ** You may obtain a copy of the License at 7 ** 8 ** http://www.apache.org/licenses/LICENSE-2.0 9 ** 10 ** Unless required by applicable law or agreed to in writing, software 11 ** distributed under the License is distributed on an "AS IS" BASIS, 12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 ** See the License for the specific language governing permissions and 14 ** limitations under the License. 15 */ 16 17 #include "header.h" 18 19 EGLBoolean Debug_eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) 20 { 21 DbgContext * const dbg = getDbgContextThreadSpecific(); 22 glesv2debugger::Message msg; 23 struct : public FunctionCall { 24 EGLDisplay dpy; 25 EGLSurface draw; 26 27 const int * operator()(gl_hooks_t::gl_t const * const _c, glesv2debugger::Message & msg) { 28 msg.set_time(-1); 29 return reinterpret_cast<const int *>(true); 30 } 31 } caller; 32 caller.dpy = dpy; 33 caller.draw = draw; 34 35 msg.set_arg0(reinterpret_cast<int>(dpy)); 36 msg.set_arg1(reinterpret_cast<int>(draw)); 37 if (dbg->captureSwap > 0) { 38 dbg->captureSwap--; 39 int viewport[4] = {}; 40 dbg->hooks->gl.glGetIntegerv(GL_VIEWPORT, viewport); 41 void * pixels = dbg->GetReadPixelsBuffer(viewport[2] * viewport[3] * 42 dbg->readBytesPerPixel); 43 dbg->hooks->gl.glReadPixels(viewport[0], viewport[1], viewport[2], 44 viewport[3], GL_RGBA, GL_UNSIGNED_BYTE, pixels); 45 dbg->CompressReadPixelBuffer(msg.mutable_data()); 46 msg.set_data_type(msg.ReferencedImage); 47 msg.set_pixel_format(GL_RGBA); 48 msg.set_pixel_type(GL_UNSIGNED_BYTE); 49 msg.set_image_width(viewport[2]); 50 msg.set_image_height(viewport[3]); 51 } 52 int * ret = MessageLoop(caller, msg, glesv2debugger::Message_Function_eglSwapBuffers); 53 return static_cast<EGLBoolean>(reinterpret_cast<int>(ret)); 54 } 55