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 #define EXTEND_Debug_glCopyTexImage2D \ 18 DbgContext * const dbg = getDbgContextThreadSpecific(); \ 19 void * readData = dbg->GetReadPixelsBuffer(4 * width * height); \ 20 /* pick easy format for client to convert */ \ 21 dbg->hooks->gl.glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, readData); \ 22 dbg->CompressReadPixelBuffer(msg.mutable_data()); \ 23 msg.set_data_type(msg.ReferencedImage); \ 24 msg.set_pixel_format(GL_RGBA); \ 25 msg.set_pixel_type(GL_UNSIGNED_BYTE); 26 27 #define EXTEND_Debug_glCopyTexSubImage2D EXTEND_Debug_glCopyTexImage2D 28 29 #define EXTEND_AFTER_CALL_Debug_glReadPixels \ 30 { \ 31 DbgContext * const dbg = getDbgContextThreadSpecific(); \ 32 if (dbg->IsReadPixelBuffer(pixels)) { \ 33 dbg->CompressReadPixelBuffer(msg.mutable_data()); \ 34 msg.set_data_type(msg.ReferencedImage); \ 35 } else { \ 36 const unsigned int size = width * height * GetBytesPerPixel(format, type); \ 37 dbg->Compress(pixels, size, msg.mutable_data()); \ 38 msg.set_data_type(msg.NonreferencedImage); \ 39 } \ 40 } 41 42 #define EXTEND_Debug_glShaderSource \ 43 std::string * const data = msg.mutable_data(); \ 44 for (unsigned i = 0; i < count; i++) \ 45 if (!length || length[i] < 0) \ 46 data->append(string[i]); \ 47 else \ 48 data->append(string[i], length[i]); 49 50 #define EXTEND_Debug_glTexImage2D \ 51 if (pixels) { \ 52 DbgContext * const dbg = getDbgContextThreadSpecific(); \ 53 const unsigned size = GetBytesPerPixel(format, type) * width * height; \ 54 assert(0 < size); \ 55 dbg->Compress(pixels, size, msg.mutable_data()); \ 56 } 57 58 #define EXTEND_Debug_glTexSubImage2D EXTEND_Debug_glTexImage2D 59