summaryrefslogtreecommitdiffstats
path: root/cmds/screenrecord/TextRenderer.h
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2013-10-18 07:31:41 -0700
committerAndy McFadden <fadden@android.com>2013-11-18 13:40:48 -0800
commit441e847feb0e055ecb004802802cea07782ab228 (patch)
treed13d0ba0e0a196a0f13ce7402f0a2e063e1d1250 /cmds/screenrecord/TextRenderer.h
parent3bd2531ac7c87b85bc9f5abf558b5dc247caaa86 (diff)
downloadframeworks_av-441e847feb0e055ecb004802802cea07782ab228.zip
frameworks_av-441e847feb0e055ecb004802802cea07782ab228.tar.gz
frameworks_av-441e847feb0e055ecb004802802cea07782ab228.tar.bz2
Add "--bugreport" option to screenrecord
The --bugreport option adds two visible features: (1) a timestamp overlay that (mostly) matches logcat, making it easier to match what appears in the video with what's in the log, and (2) an "info page" at the start of the video that shows the system configuration. Enabling this option adds an additional composition step, increasing the overhead of screenrecord. Depending on the device and circumstances, this may be unnoticeable or very pronounced. If --bugreport is not enabled, the overhead of screenrecord is unchanged. We also now track device orientation changes. This is currently detected by polling surfaceflinger, which is suboptimal. As a result, we detect the rotation too late, and get a weird mixed frame before the start of the animation for 90-degree changes. Also, allow the bit rate to be specified as e.g. "4M" for 4Mbps. Also, --rotate is now deprecated. Bug 11220305 Bug 11136964 Change-Id: Ibb94b81d2f73547b95d7a47e027da75fab187a4f
Diffstat (limited to 'cmds/screenrecord/TextRenderer.h')
-rw-r--r--cmds/screenrecord/TextRenderer.h136
1 files changed, 136 insertions, 0 deletions
diff --git a/cmds/screenrecord/TextRenderer.h b/cmds/screenrecord/TextRenderer.h
new file mode 100644
index 0000000..9a28fcb
--- /dev/null
+++ b/cmds/screenrecord/TextRenderer.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SCREENRECORD_TEXT_RENDER_H
+#define SCREENRECORD_TEXT_RENDER_H
+
+#include "Program.h"
+
+#include <utils/String8.h>
+#include <utils/Errors.h>
+
+#include <GLES2/gl2.h>
+
+
+namespace android {
+
+/*
+ * Simple font representation.
+ *
+ * Not thread-safe.
+ */
+class TextRenderer {
+public:
+ TextRenderer() :
+ mTextureName(0),
+ mScale(1.0f),
+ mBorderWidth(10.0f),
+ mIndentMult(30.0f),
+ mScreenWidth(0),
+ mScreenHeight(0)
+ {}
+ ~TextRenderer() {}
+
+ // Load the glyph bitmap into a 2D texture in the current context.
+ status_t loadIntoTexture();
+
+ // Set the screen dimensions, used for scaling and line wrap.
+ void setScreenSize(uint32_t width, uint32_t height) {
+ mScreenWidth = width;
+ mScreenHeight = height;
+ }
+
+ // Get/set the font scaling.
+ float getScale() const { return mScale; }
+ void setScale(float scale) { mScale = scale; }
+
+ // Set the font scaling based on the desired number of lines per screen.
+ // The display's tallest axis is used, so if the device is in landscape
+ // the screen will fit fewer lines.
+ void setProportionalScale(float linesPerScreen);
+
+ // Render the text string at the specified coordinates. Pass in the
+ // upper-left corner in non-GL-flipped coordinates, i.e. to print text
+ // at the top left of the screen use (0,0).
+ //
+ // Set blend func (1, 1-srcAlpha) before calling if drawing onto
+ // something other than black.
+ void drawString(const Program& program, const float* texMatrix,
+ float x, float y, const String8& str) const;
+
+ // Draw a string, possibly wrapping it at the screen boundary. Top-left
+ // is at (0,0).
+ //
+ // Returns the updated Y position.
+ float drawWrappedString(const Program& texRender, float xpos, float ypos,
+ const String8& str);
+
+ // Returns the name of the texture the font was loaded into.
+ GLuint getTextureName() const { return mTextureName; }
+
+private:
+ TextRenderer(const TextRenderer&);
+ TextRenderer& operator=(const TextRenderer&);
+
+ // Perform one-time initialization.
+ static void initOnce();
+
+ // Populate the mXOffset array.
+ static void initXOffset();
+
+ // Find a good place to break the string. Returns NULL if the entire
+ // string will fit.
+ char* breakString(const char* str, float maxWidth) const;
+
+ // Computes the width of the string, in pixels.
+ float computeScaledStringWidth(const String8& str8) const;
+
+ // Computes the width of first N characters in the string.
+ float computeScaledStringWidth(const char* str, size_t len) const;
+
+ // Returns the font's glyph height. This is the full pixel height of the
+ // tallest glyph, both above and below the baseline, NOT adjusted by the
+ // current scale factor.
+ float getGlyphHeight() const;
+
+ // Like getGlyphHeight(), but result is scaled.
+ float getScaledGlyphHeight() const { return getGlyphHeight() * mScale; }
+
+ GLuint mTextureName;
+ float mScale;
+
+ // Number of pixels preserved at the left/right edges of the screen by
+ // drawWrappedString(). Not scaled.
+ float mBorderWidth;
+
+ // Distance to indent a broken line. Used by drawWrappedString().
+ // Value will be adjusted by the current scale factor.
+ float mIndentMult;
+
+ // Screen dimensions.
+ uint32_t mScreenWidth;
+ uint32_t mScreenHeight;
+
+ // Static font info.
+ static bool mInitialized;
+ static uint32_t mXOffset[];
+
+ static const char kWhitespace[];
+};
+
+}; // namespace android
+
+#endif /*SCREENRECORD_TEXT_RENDER_H*/