Merge "Enable write ahead logging on databases used by WebView." into honeycomb
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index ff92e08..cbc15d8 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -113,8 +113,11 @@
int mBufferCount;
// mCurrentTexture is the buffer slot index of the buffer that is currently
- // bound to the OpenGL texture. A value of INVALID_BUFFER_SLOT, indicating
- // that no buffer is currently bound to the texture.
+ // bound to the OpenGL texture. It is initialized to INVALID_BUFFER_SLOT,
+ // indicating that no buffer slot is currently bound to the texture. Note,
+ // however, that a value of INVALID_BUFFER_SLOT does not necessarily mean
+ // that no buffer is bound to the texture. A call to setBufferCount will
+ // reset mCurrentTexture to INVALID_BUFFER_SLOT.
int mCurrentTexture;
// mLastQueued is the buffer slot index of the most recently enqueued buffer.
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 9579996..11a48d9 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -15,6 +15,7 @@
*/
#define LOG_TAG "SurfaceTexture"
+//#define LOG_NDEBUG 0
#define GL_GLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES
@@ -36,21 +37,32 @@
SurfaceTexture::SurfaceTexture(GLuint tex) :
mBufferCount(MIN_BUFFER_SLOTS), mCurrentTexture(INVALID_BUFFER_SLOT),
mLastQueued(INVALID_BUFFER_SLOT), mTexName(tex) {
+ LOGV("SurfaceTexture::SurfaceTexture");
+ for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
+ mSlots[i].mEglImage = EGL_NO_IMAGE_KHR;
+ mSlots[i].mEglDisplay = EGL_NO_DISPLAY;
+ mSlots[i].mOwnedByClient = false;
+ }
}
SurfaceTexture::~SurfaceTexture() {
+ LOGV("SurfaceTexture::~SurfaceTexture");
freeAllBuffers();
}
status_t SurfaceTexture::setBufferCount(int bufferCount) {
+ LOGV("SurfaceTexture::setBufferCount");
Mutex::Autolock lock(mMutex);
freeAllBuffers();
mBufferCount = bufferCount;
+ mCurrentTexture = INVALID_BUFFER_SLOT;
+ mLastQueued = INVALID_BUFFER_SLOT;
return OK;
}
sp<GraphicBuffer> SurfaceTexture::requestBuffer(int buf,
uint32_t w, uint32_t h, uint32_t format, uint32_t usage) {
+ LOGV("SurfaceTexture::requestBuffer");
Mutex::Autolock lock(mMutex);
if (buf < 0 || mBufferCount <= buf) {
LOGE("requestBuffer: slot index out of range [0, %d]: %d",
@@ -75,6 +87,7 @@
}
status_t SurfaceTexture::dequeueBuffer(int *buf) {
+ LOGV("SurfaceTexture::dequeueBuffer");
Mutex::Autolock lock(mMutex);
int found = INVALID_BUFFER_SLOT;
for (int i = 0; i < mBufferCount; i++) {
@@ -92,6 +105,7 @@
}
status_t SurfaceTexture::queueBuffer(int buf) {
+ LOGV("SurfaceTexture::queueBuffer");
Mutex::Autolock lock(mMutex);
if (buf < 0 || mBufferCount <= buf) {
LOGE("queueBuffer: slot index out of range [0, %d]: %d",
@@ -111,6 +125,7 @@
}
void SurfaceTexture::cancelBuffer(int buf) {
+ LOGV("SurfaceTexture::cancelBuffer");
Mutex::Autolock lock(mMutex);
if (buf < 0 || mBufferCount <= buf) {
LOGE("cancelBuffer: slot index out of range [0, %d]: %d", mBufferCount,
@@ -124,18 +139,21 @@
}
status_t SurfaceTexture::setCrop(const Rect& reg) {
+ LOGV("SurfaceTexture::setCrop");
Mutex::Autolock lock(mMutex);
// XXX: How should we handle crops?
return OK;
}
status_t SurfaceTexture::setTransform(uint32_t transform) {
+ LOGV("SurfaceTexture::setTransform");
Mutex::Autolock lock(mMutex);
// XXX: How should we handle transforms?
return OK;
}
status_t SurfaceTexture::updateTexImage() {
+ LOGV("SurfaceTexture::updateTexImage");
Mutex::Autolock lock(mMutex);
// We always bind the texture even if we don't update its contents.
diff --git a/opengl/tests/hwc/hwcCommit.cpp b/opengl/tests/hwc/hwcCommit.cpp
index ed74cbe..66ccdae 100644
--- a/opengl/tests/hwc/hwcCommit.cpp
+++ b/opengl/tests/hwc/hwcCommit.cpp
@@ -76,6 +76,7 @@
#include <cmath>
#include <cstdlib>
#include <ctime>
+#include <iomanip>
#include <istream>
#include <libgen.h>
#include <list>
@@ -125,6 +126,7 @@
const struct hwc_rect defaultDisplayFrame = {0, 0, 100, 100};
// Global Constants
+const uint32_t printFieldWidth = 2;
const struct searchLimits {
uint32_t numOverlays;
HwcTestDim sourceCrop;
@@ -233,6 +235,8 @@
static EGLDisplay dpy;
static EGLSurface surface;
static EGLint width, height;
+static size_t maxHeadingLen;
+static vector<string> formats;
// Measurements
struct meas {
@@ -264,6 +268,9 @@
HwcTestDim vScaleBestDf;
HwcTestDim vScaleBestSc;
} sc;
+ vector<uint32_t> overlapBlendNone;
+ vector<uint32_t> overlapBlendPremult;
+ vector<uint32_t> overlapBlendCoverage;
};
vector<meas> measurements;
@@ -292,9 +299,14 @@
const HwcTestDim& dfMin, const HwcTestDim& dfMax,
const HwcTestDim& scMin, const HwcTestDim& scMax,
HwcTestDim& outBestDf, HwcTestDim& outBestSc);
+uint32_t numOverlapping(uint32_t backgroundFormat, uint32_t foregroundFormat,
+ uint32_t backgroundBlend, uint32_t foregroundBlend);
string transformList2str(const list<uint32_t>& transformList);
string blendList2str(const list<uint32_t>& blendList);
void init(void);
+void printFormatHeadings(size_t indent);
+void printOverlapLine(size_t indent, const string formatStr,
+ const vector<uint32_t>& results);
void printSyntax(const char *cmd);
// Command-line option settings
@@ -332,7 +344,6 @@
bool error;
string str;
char cmd[MAXCMD];
- list<string> formats;
list<Rectangle> rectList;
testSetLogCatTag(LOG_TAG);
@@ -395,6 +406,13 @@
}
}
+ // Determine length of longest specified graphic format.
+ // This value is used for output formating
+ for (vector<string>::iterator it = formats.begin();
+ it != formats.end(); ++it) {
+ maxHeadingLen = max(maxHeadingLen, it->length());
+ }
+
// Stop framework
rv = snprintf(cmd, sizeof(cmd), "%s", CMD_STOP_FRAMEWORK);
if (rv >= (signed) sizeof(cmd) - 1) {
@@ -411,7 +429,7 @@
init();
// For each of the graphic formats
- for (list<string>::iterator itFormat = formats.begin();
+ for (vector<string>::iterator itFormat = formats.begin();
itFormat != formats.end(); ++itFormat) {
// Locate hwcTestLib structure that describes this format
@@ -539,8 +557,66 @@
testPrintI(" VScale Best Source Crop: %s",
((string) measPtr->sc.vScaleBestSc).c_str());
+ // Overlap two graphic formats and different blends
+ // Results displayed after all overlap measurments with
+ // current format in the foreground
+ // TODO: make measurments with background blend other than
+ // none. All of these measurements are done with a
+ // background blend of HWC_BLENDING_NONE, with the
+ // blend type of the foregound being varied.
+ uint32_t foregroundFormat = format->format;
+ for (vector<string>::iterator it = formats.begin();
+ it != formats.end(); ++it) {
+ uint32_t num;
+
+ const struct hwcTestGraphicFormat *backgroundFormatPtr
+ = hwcTestGraphicFormatLookup((*it).c_str());
+ uint32_t backgroundFormat = backgroundFormatPtr->format;
+
+ num = numOverlapping(backgroundFormat, foregroundFormat,
+ HWC_BLENDING_NONE, HWC_BLENDING_NONE);
+ measPtr->overlapBlendNone.push_back(num);
+
+ num = numOverlapping(backgroundFormat, foregroundFormat,
+ HWC_BLENDING_NONE, HWC_BLENDING_PREMULT);
+ measPtr->overlapBlendPremult.push_back(num);
+
+ num = numOverlapping(backgroundFormat, foregroundFormat,
+ HWC_BLENDING_NONE, HWC_BLENDING_COVERAGE);
+ measPtr->overlapBlendCoverage.push_back(num);
+ }
+
}
+ // Display overlap results
+ size_t indent = 2;
+ testPrintI("overlapping blend: none");
+ printFormatHeadings(indent);
+ for (vector<string>::iterator it = formats.begin();
+ it != formats.end(); ++it) {
+ printOverlapLine(indent, *it, measurements[it
+ - formats.begin()].overlapBlendNone);
+ }
+ testPrintI("");
+
+ testPrintI("overlapping blend: premult");
+ printFormatHeadings(indent);
+ for (vector<string>::iterator it = formats.begin();
+ it != formats.end(); ++it) {
+ printOverlapLine(indent, *it, measurements[it
+ - formats.begin()].overlapBlendPremult);
+ }
+ testPrintI("");
+
+ testPrintI("overlapping blend: coverage");
+ printFormatHeadings(indent);
+ for (vector<string>::iterator it = formats.begin();
+ it != formats.end(); ++it) {
+ printOverlapLine(indent, *it, measurements[it
+ - formats.begin()].overlapBlendCoverage);
+ }
+ testPrintI("");
+
// Start framework
rv = snprintf(cmd, sizeof(cmd), "%s", CMD_START_FRAMEWORK);
if (rv >= (signed) sizeof(cmd) - 1) {
@@ -1204,6 +1280,33 @@
return best;
}
+uint32_t numOverlapping(uint32_t backgroundFormat, uint32_t foregroundFormat,
+ uint32_t backgroundBlend, uint32_t foregroundBlend)
+{
+ list<Rectangle> rectList;
+
+ Rectangle background(backgroundFormat, startDim, startDim);
+ background.blend = backgroundBlend;
+ rectList.push_back(background);
+
+ // TODO: Handle cases where startDim is so small that adding 5
+ // causes frames not to overlap.
+ // TODO: Handle cases where startDim is so large that adding 5
+ // cause a portion or all of the foreground displayFrame
+ // to be off the display.
+ Rectangle foreground(foregroundFormat, startDim, startDim);
+ foreground.displayFrame.left += 5;
+ foreground.displayFrame.top += 5;
+ foreground.displayFrame.right += 5;
+ foreground.displayFrame.bottom += 5;
+ background.blend = foregroundBlend;
+ rectList.push_back(foreground);
+
+ uint32_t num = numOverlays(rectList);
+
+ return num;
+}
+
Rectangle::Rectangle(uint32_t graphicFormat, HwcTestDim dfDim,
HwcTestDim sDim) :
format(graphicFormat), transform(defaultTransform),
@@ -1405,6 +1508,45 @@
hwcTestOpenHwc(&hwcDevice);
}
+void printFormatHeadings(size_t indent)
+{
+ for (size_t row = 0; row <= maxHeadingLen; row++) {
+ ostringstream line;
+ for(vector<string>::iterator it = formats.begin();
+ it != formats.end(); ++it) {
+ if ((maxHeadingLen - row) <= it->length()) {
+ if (row != maxHeadingLen) {
+ char ch = (*it)[it->length() - (maxHeadingLen - row)];
+ line << ' ' << setw(printFieldWidth) << ch;
+ } else {
+ line << ' ' << string(printFieldWidth, '-');
+ }
+ } else {
+ line << ' ' << setw(printFieldWidth) << "";
+ }
+ }
+ testPrintI("%*s%s", indent + maxHeadingLen, "",
+ line.str().c_str());
+ }
+}
+
+void printOverlapLine(size_t indent, const string formatStr,
+ const vector<uint32_t>& results)
+{
+ ostringstream line;
+
+ line << setw(indent + maxHeadingLen - formatStr.length()) << "";
+
+ line << formatStr;
+
+ for (vector<uint32_t>::const_iterator it = results.begin();
+ it != results.end(); ++it) {
+ line << ' ' << setw(printFieldWidth) << *it;
+ }
+
+ testPrintI("%s", line.str().c_str());
+}
+
void printSyntax(const char *cmd)
{
testPrintE(" %s [options] [graphicFormat] ...",
diff --git a/opengl/tests/hwc/hwcTestLib.cpp b/opengl/tests/hwc/hwcTestLib.cpp
index a468a92..925405e 100644
--- a/opengl/tests/hwc/hwcTestLib.cpp
+++ b/opengl/tests/hwc/hwcTestLib.cpp
@@ -475,14 +475,14 @@
testPrintI(" displayFrame: %s",
hwcTestRect2str(list->hwLayers[layer].displayFrame).c_str());
testPrintI(" scaleFactor: [%f, %f]",
- (float) (list->hwLayers[layer].displayFrame.right
- - list->hwLayers[layer].displayFrame.left)
- / (float) (list->hwLayers[layer].sourceCrop.right
- - list->hwLayers[layer].sourceCrop.left),
- (float) (list->hwLayers[layer].displayFrame.bottom
- - list->hwLayers[layer].displayFrame.top)
- / (float) (list->hwLayers[layer].sourceCrop.bottom
- - list->hwLayers[layer].sourceCrop.top));
+ (float) (list->hwLayers[layer].sourceCrop.right
+ - list->hwLayers[layer].sourceCrop.left)
+ / (float) (list->hwLayers[layer].displayFrame.right
+ - list->hwLayers[layer].displayFrame.left),
+ (float) (list->hwLayers[layer].sourceCrop.bottom
+ - list->hwLayers[layer].sourceCrop.top)
+ / (float) (list->hwLayers[layer].displayFrame.bottom
+ - list->hwLayers[layer].displayFrame.top));
}
}
@@ -494,7 +494,11 @@
*/
void hwcTestDisplayListPrepareModifiable(hwc_layer_list_t *list)
{
+ uint32_t numOverlays = 0;
for (unsigned int layer = 0; layer < list->numHwLayers; layer++) {
+ if (list->hwLayers[layer].compositionType == HWC_OVERLAY) {
+ numOverlays++;
+ }
testPrintI(" layer %u compositionType: %#x%s%s", layer,
list->hwLayers[layer].compositionType,
(list->hwLayers[layer].compositionType == HWC_FRAMEBUFFER)
@@ -508,6 +512,7 @@
(list->hwLayers[layer].hints & HWC_HINT_CLEAR_FB)
? " CLEAR_FB" : "");
}
+ testPrintI(" numOverlays: %u", numOverlays);
}
/*