Loading cmds/screenrecord/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ LOCAL_C_INCLUDES := \ external/jpeg LOCAL_CFLAGS += -Wno-multichar #LOCAL_CFLAGS += -UNDEBUG LOCAL_MODULE_TAGS := optional Loading cmds/screenrecord/Overlay.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <GLES2/gl2ext.h> #include <stdlib.h> #include <assert.h> #include "screenrecord.h" #include "Overlay.h" Loading Loading @@ -66,10 +67,11 @@ status_t Overlay::start(const sp<IGraphicBufferProducer>& outputSurface, mStartMonotonicNsecs = systemTime(CLOCK_MONOTONIC); mStartRealtimeNsecs = systemTime(CLOCK_REALTIME); Mutex::Autolock _l(mMutex); // Start the thread. Traffic begins immediately. run("overlay"); Mutex::Autolock _l(mMutex); mState = INIT; while (mState == INIT) { mStartCond.wait(mMutex); Loading @@ -79,7 +81,7 @@ status_t Overlay::start(const sp<IGraphicBufferProducer>& outputSurface, ALOGE("Failed to start overlay thread: err=%d", mThreadResult); return mThreadResult; } assert(mState == READY); assert(mState == RUNNING); ALOGV("Overlay::start successful"); *pBufferProducer = mBufferQueue; Loading cmds/screenrecord/TextRenderer.cpp +17 −8 Original line number Diff line number Diff line Loading @@ -102,8 +102,9 @@ status_t TextRenderer::loadIntoTexture() { } uint32_t potHeight = powerOfTwoCeil(FontBitmap::height); uint32_t* rgbaPixels = new uint32_t[FontBitmap::width * potHeight]; uint8_t* rgbaPixels = new uint8_t[FontBitmap::width * potHeight * 4]; memset(rgbaPixels, 0, FontBitmap::width * potHeight * 4); uint8_t* pix = rgbaPixels; for (unsigned int i = 0; i < FontBitmap::width * FontBitmap::height; i++) { uint8_t alpha, color; Loading @@ -116,7 +117,10 @@ status_t TextRenderer::loadIntoTexture() { color = FontBitmap::pixels[i] & ~1; alpha = 0xff; } rgbaPixels[i] = (alpha << 24) | (color << 16) | (color << 8) | color; *pix++ = color; *pix++ = color; *pix++ = color; *pix++ = alpha; } glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FontBitmap::width, potHeight, 0, Loading Loading @@ -151,11 +155,20 @@ float TextRenderer::computeScaledStringWidth(const String8& str8) const { return computeScaledStringWidth(str, strlen(str)); } size_t TextRenderer::glyphIndex(char ch) const { size_t chi = ch - FontBitmap::firstGlyphChar; if (chi >= FontBitmap::numGlyphs) { chi = '?' - FontBitmap::firstGlyphChar; } assert(chi < FontBitmap::numGlyphs); return chi; } float TextRenderer::computeScaledStringWidth(const char* str, size_t len) const { float width = 0.0f; for (size_t i = 0; i < len; i++) { size_t chi = str[i] - FontBitmap::firstGlyphChar; size_t chi = glyphIndex(str[i]); float glyphWidth = FontBitmap::glyphWidth[chi]; width += (glyphWidth - 1 - FontBitmap::outlineWidth) * mScale; } Loading @@ -182,11 +195,7 @@ void TextRenderer::drawString(const Program& program, const float* texMatrix, float fullTexWidth = FontBitmap::width; float fullTexHeight = powerOfTwoCeil(FontBitmap::height); for (size_t i = 0; i < len; i++) { size_t chi = str[i] - FontBitmap::firstGlyphChar; if (chi >= FontBitmap::numGlyphs) { chi = '?' - FontBitmap::firstGlyphChar; assert(chi < FontBitmap::numGlyphs); } size_t chi = glyphIndex(str[i]); float glyphWidth = FontBitmap::glyphWidth[chi]; float glyphHeight = FontBitmap::maxGlyphHeight; Loading cmds/screenrecord/TextRenderer.h +4 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,10 @@ private: // Like getGlyphHeight(), but result is scaled. float getScaledGlyphHeight() const { return getGlyphHeight() * mScale; } // Convert an ASCII character to a glyph index. Returns the glyph for // '?' if we have no glyph for the specified character. size_t glyphIndex(char ch) const; GLuint mTextureName; float mScale; Loading cmds/screenrecord/screenrecord.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ #include <signal.h> #include <getopt.h> #include <sys/wait.h> #include <assert.h> #include "screenrecord.h" #include "Overlay.h" Loading Loading @@ -532,9 +533,10 @@ static status_t recordScreen(const char* fileName) { // Configure optional overlay. sp<IGraphicBufferProducer> bufferProducer; sp<Overlay> overlay = new Overlay(); sp<Overlay> overlay; if (gWantFrameTime) { // Send virtual display frames to an external texture. overlay = new Overlay(); err = overlay->start(encoderInputSurface, &bufferProducer); if (err != NO_ERROR) { encoder->release(); Loading Loading @@ -578,7 +580,9 @@ static status_t recordScreen(const char* fileName) { // Shut everything down, starting with the producer side. encoderInputSurface = NULL; SurfaceComposerClient::destroyDisplay(dpy); if (overlay != NULL) { overlay->stop(); } encoder->stop(); // If we don't stop muxer explicitly, i.e. let the destructor run, // it may hang (b/11050628). Loading Loading @@ -717,8 +721,8 @@ static void usage() { " display resolution (if supported), 1280x720 if not. For best results,\n" " use a size supported by the AVC encoder.\n" "--bit-rate RATE\n" " Set the video bit rate, in megabits per second. Value may be specified\n" " in bits or megabits, e.g. '4000000' is equivalent to '4M'. Default %dMbps.\n" " Set the video bit rate, in bits per second. Value may be specified as\n" " bits or megabits, e.g. '4000000' is equivalent to '4M'. Default %dMbps.\n" "--bugreport\n" " Add additional information, such as a timestamp overlay, that is helpful\n" " in videos captured to illustrate bugs.\n" Loading Loading
cmds/screenrecord/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ LOCAL_C_INCLUDES := \ external/jpeg LOCAL_CFLAGS += -Wno-multichar #LOCAL_CFLAGS += -UNDEBUG LOCAL_MODULE_TAGS := optional Loading
cmds/screenrecord/Overlay.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <GLES2/gl2ext.h> #include <stdlib.h> #include <assert.h> #include "screenrecord.h" #include "Overlay.h" Loading Loading @@ -66,10 +67,11 @@ status_t Overlay::start(const sp<IGraphicBufferProducer>& outputSurface, mStartMonotonicNsecs = systemTime(CLOCK_MONOTONIC); mStartRealtimeNsecs = systemTime(CLOCK_REALTIME); Mutex::Autolock _l(mMutex); // Start the thread. Traffic begins immediately. run("overlay"); Mutex::Autolock _l(mMutex); mState = INIT; while (mState == INIT) { mStartCond.wait(mMutex); Loading @@ -79,7 +81,7 @@ status_t Overlay::start(const sp<IGraphicBufferProducer>& outputSurface, ALOGE("Failed to start overlay thread: err=%d", mThreadResult); return mThreadResult; } assert(mState == READY); assert(mState == RUNNING); ALOGV("Overlay::start successful"); *pBufferProducer = mBufferQueue; Loading
cmds/screenrecord/TextRenderer.cpp +17 −8 Original line number Diff line number Diff line Loading @@ -102,8 +102,9 @@ status_t TextRenderer::loadIntoTexture() { } uint32_t potHeight = powerOfTwoCeil(FontBitmap::height); uint32_t* rgbaPixels = new uint32_t[FontBitmap::width * potHeight]; uint8_t* rgbaPixels = new uint8_t[FontBitmap::width * potHeight * 4]; memset(rgbaPixels, 0, FontBitmap::width * potHeight * 4); uint8_t* pix = rgbaPixels; for (unsigned int i = 0; i < FontBitmap::width * FontBitmap::height; i++) { uint8_t alpha, color; Loading @@ -116,7 +117,10 @@ status_t TextRenderer::loadIntoTexture() { color = FontBitmap::pixels[i] & ~1; alpha = 0xff; } rgbaPixels[i] = (alpha << 24) | (color << 16) | (color << 8) | color; *pix++ = color; *pix++ = color; *pix++ = color; *pix++ = alpha; } glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FontBitmap::width, potHeight, 0, Loading Loading @@ -151,11 +155,20 @@ float TextRenderer::computeScaledStringWidth(const String8& str8) const { return computeScaledStringWidth(str, strlen(str)); } size_t TextRenderer::glyphIndex(char ch) const { size_t chi = ch - FontBitmap::firstGlyphChar; if (chi >= FontBitmap::numGlyphs) { chi = '?' - FontBitmap::firstGlyphChar; } assert(chi < FontBitmap::numGlyphs); return chi; } float TextRenderer::computeScaledStringWidth(const char* str, size_t len) const { float width = 0.0f; for (size_t i = 0; i < len; i++) { size_t chi = str[i] - FontBitmap::firstGlyphChar; size_t chi = glyphIndex(str[i]); float glyphWidth = FontBitmap::glyphWidth[chi]; width += (glyphWidth - 1 - FontBitmap::outlineWidth) * mScale; } Loading @@ -182,11 +195,7 @@ void TextRenderer::drawString(const Program& program, const float* texMatrix, float fullTexWidth = FontBitmap::width; float fullTexHeight = powerOfTwoCeil(FontBitmap::height); for (size_t i = 0; i < len; i++) { size_t chi = str[i] - FontBitmap::firstGlyphChar; if (chi >= FontBitmap::numGlyphs) { chi = '?' - FontBitmap::firstGlyphChar; assert(chi < FontBitmap::numGlyphs); } size_t chi = glyphIndex(str[i]); float glyphWidth = FontBitmap::glyphWidth[chi]; float glyphHeight = FontBitmap::maxGlyphHeight; Loading
cmds/screenrecord/TextRenderer.h +4 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,10 @@ private: // Like getGlyphHeight(), but result is scaled. float getScaledGlyphHeight() const { return getGlyphHeight() * mScale; } // Convert an ASCII character to a glyph index. Returns the glyph for // '?' if we have no glyph for the specified character. size_t glyphIndex(char ch) const; GLuint mTextureName; float mScale; Loading
cmds/screenrecord/screenrecord.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ #include <signal.h> #include <getopt.h> #include <sys/wait.h> #include <assert.h> #include "screenrecord.h" #include "Overlay.h" Loading Loading @@ -532,9 +533,10 @@ static status_t recordScreen(const char* fileName) { // Configure optional overlay. sp<IGraphicBufferProducer> bufferProducer; sp<Overlay> overlay = new Overlay(); sp<Overlay> overlay; if (gWantFrameTime) { // Send virtual display frames to an external texture. overlay = new Overlay(); err = overlay->start(encoderInputSurface, &bufferProducer); if (err != NO_ERROR) { encoder->release(); Loading Loading @@ -578,7 +580,9 @@ static status_t recordScreen(const char* fileName) { // Shut everything down, starting with the producer side. encoderInputSurface = NULL; SurfaceComposerClient::destroyDisplay(dpy); if (overlay != NULL) { overlay->stop(); } encoder->stop(); // If we don't stop muxer explicitly, i.e. let the destructor run, // it may hang (b/11050628). Loading Loading @@ -717,8 +721,8 @@ static void usage() { " display resolution (if supported), 1280x720 if not. For best results,\n" " use a size supported by the AVC encoder.\n" "--bit-rate RATE\n" " Set the video bit rate, in megabits per second. Value may be specified\n" " in bits or megabits, e.g. '4000000' is equivalent to '4M'. Default %dMbps.\n" " Set the video bit rate, in bits per second. Value may be specified as\n" " bits or megabits, e.g. '4000000' is equivalent to '4M'. Default %dMbps.\n" "--bugreport\n" " Add additional information, such as a timestamp overlay, that is helpful\n" " in videos captured to illustrate bugs.\n" Loading