summaryrefslogtreecommitdiffstats
path: root/libs/hwui/DisplayListRenderer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/DisplayListRenderer.cpp')
-rw-r--r--libs/hwui/DisplayListRenderer.cpp167
1 files changed, 126 insertions, 41 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 751da44..1a11fbc 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -19,9 +19,10 @@
#include "DisplayListLogBuffer.h"
#include "DisplayListRenderer.h"
-#include <utils/String8.h>
#include "Caches.h"
+#include <utils/String8.h>
+
namespace android {
namespace uirenderer {
@@ -60,12 +61,15 @@ const char* DisplayList::OP_NAMES[] = {
"DrawLines",
"DrawPoints",
"DrawText",
+ "DrawPosText",
"ResetShader",
"SetupShader",
"ResetColorFilter",
"SetupColorFilter",
"ResetShadow",
"SetupShadow",
+ "ResetPaintFilter",
+ "SetupPaintFilter",
"DrawGLFunction"
};
@@ -214,7 +218,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
indent[i] = ' ';
}
indent[count] = '\0';
- ALOGD("%sStart display list (%p)", (char*) indent + 2, this);
+ ALOGD("%sStart display list (%p, %s)", (char*) indent + 2, this, mName.string());
int saveCount = renderer.getSaveCount() - 1;
@@ -248,7 +252,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
float f2 = getFloat();
float f3 = getFloat();
float f4 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
int flags = getInt();
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
OP_NAMES[op], f1, f2, f3, f4, paint, flags);
@@ -321,7 +325,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
Layer* layer = (Layer*) getInt();
float x = getFloat();
float y = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
layer, x, y, paint);
}
@@ -330,7 +334,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
SkBitmap* bitmap = getBitmap();
float x = getFloat();
float y = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
bitmap, x, y, paint);
}
@@ -338,7 +342,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
case DrawBitmapMatrix: {
SkBitmap* bitmap = getBitmap();
SkMatrix* matrix = getMatrix();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
bitmap, matrix, paint);
}
@@ -353,7 +357,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
float f6 = getFloat();
float f7 = getFloat();
float f8 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
(char*) indent, OP_NAMES[op], bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
}
@@ -367,7 +371,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
float* vertices = getFloats(verticesCount);
bool hasColors = getInt();
int* colors = hasColors ? getInts(colorsCount) : NULL;
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
}
break;
@@ -386,7 +390,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
float top = getFloat();
float right = getFloat();
float bottom = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", (char*) indent, OP_NAMES[op],
left, top, right, bottom);
}
@@ -402,7 +406,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
float f2 = getFloat();
float f3 = getFloat();
float f4 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
f1, f2, f3, f4, paint);
}
@@ -414,7 +418,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
float f4 = getFloat();
float f5 = getFloat();
float f6 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
}
@@ -423,7 +427,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
float f1 = getFloat();
float f2 = getFloat();
float f3 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %.2f, %.2f, %.2f, %p",
(char*) indent, OP_NAMES[op], f1, f2, f3, paint);
}
@@ -433,7 +437,7 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
float f2 = getFloat();
float f3 = getFloat();
float f4 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
}
@@ -446,28 +450,28 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
float f5 = getFloat();
float f6 = getFloat();
int i1 = getInt();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
}
break;
case DrawPath: {
SkPath* path = getPath();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
}
break;
case DrawLines: {
int count = 0;
float* points = getFloats(count);
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
}
break;
case DrawPoints: {
int count = 0;
float* points = getFloats(count);
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
}
break;
@@ -476,11 +480,21 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
int count = getInt();
float x = getFloat();
float y = getFloat();
- SkPaint* paint = getPaint();
- ALOGD("%s%s %s, %d, %d, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
- text.text(), text.length(), count, x, y, paint);
+ SkPaint* paint = getPaint(renderer);
+ float length = getFloat();
+ ALOGD("%s%s %s, %d, %d, %.2f, %.2f, %p, %.2f", (char*) indent, OP_NAMES[op],
+ text.text(), text.length(), count, x, y, paint, length);
}
break;
+ case DrawPosText: {
+ getText(&text);
+ int count = getInt();
+ int positionsCount = 0;
+ float* positions = getFloats(positionsCount);
+ SkPaint* paint = getPaint(renderer);
+ ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
+ text.text(), text.length(), count, paint);
+ }
case ResetShader: {
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
}
@@ -512,6 +526,16 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
radius, dx, dy, color);
}
break;
+ case ResetPaintFilter: {
+ ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
+ }
+ break;
+ case SetupPaintFilter: {
+ int clearBits = getInt();
+ int setBits = getInt();
+ ALOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op], clearBits, setBits);
+ }
+ break;
default:
ALOGD("Display List error: op not handled: %s%s",
(char*) indent, OP_NAMES[op]);
@@ -539,9 +563,11 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
indent[i] = ' ';
}
indent[count] = '\0';
- DISPLAY_LIST_LOGD("%sStart display list (%p)", (char*) indent + 2, this);
+ DISPLAY_LIST_LOGD("%sStart display list (%p, %s)", (char*) indent + 2, this, mName.string());
#endif
+ renderer.startMark(mName.string());
+
DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
int saveCount = renderer.getSaveCount() - 1;
while (!mReader.eof()) {
@@ -552,7 +578,9 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
case DrawGLFunction: {
Functor *functor = (Functor *) getInt();
DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
+ renderer.startMark("GL functor");
needsInvalidate |= renderer.callDrawGLFunction(functor, dirty);
+ renderer.endMark();
}
break;
case Save: {
@@ -577,7 +605,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
float f2 = getFloat();
float f3 = getFloat();
float f4 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
int flags = getInt();
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
OP_NAMES[op], f1, f2, f3, f4, paint, flags);
@@ -660,7 +688,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
Layer* layer = (Layer*) getInt();
float x = getFloat();
float y = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
layer, x, y, paint);
renderer.drawLayer(layer, x, y, paint);
@@ -670,7 +698,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
SkBitmap* bitmap = getBitmap();
float x = getFloat();
float y = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
bitmap, x, y, paint);
renderer.drawBitmap(bitmap, x, y, paint);
@@ -679,7 +707,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
case DrawBitmapMatrix: {
SkBitmap* bitmap = getBitmap();
SkMatrix* matrix = getMatrix();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
bitmap, matrix, paint);
renderer.drawBitmap(bitmap, matrix, paint);
@@ -695,7 +723,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
float f6 = getFloat();
float f7 = getFloat();
float f8 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
(char*) indent, OP_NAMES[op], bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
renderer.drawBitmap(bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
@@ -711,7 +739,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
float* vertices = getFloats(verticesCount);
bool hasColors = getInt();
int* colors = hasColors ? getInts(colorsCount) : NULL;
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
renderer.drawBitmapMesh(bitmap, meshWidth, meshHeight, vertices, colors, paint);
@@ -735,7 +763,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
float top = getFloat();
float right = getFloat();
float bottom = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
renderer.drawPatch(bitmap, xDivs, yDivs, colors, xDivsCount, yDivsCount,
@@ -754,7 +782,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
float f2 = getFloat();
float f3 = getFloat();
float f4 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
f1, f2, f3, f4, paint);
renderer.drawRect(f1, f2, f3, f4, paint);
@@ -767,7 +795,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
float f4 = getFloat();
float f5 = getFloat();
float f6 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
renderer.drawRoundRect(f1, f2, f3, f4, f5, f6, paint);
@@ -777,7 +805,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
float f1 = getFloat();
float f2 = getFloat();
float f3 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %p",
(char*) indent, OP_NAMES[op], f1, f2, f3, paint);
renderer.drawCircle(f1, f2, f3, paint);
@@ -788,7 +816,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
float f2 = getFloat();
float f3 = getFloat();
float f4 = getFloat();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
renderer.drawOval(f1, f2, f3, f4, paint);
@@ -802,7 +830,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
float f5 = getFloat();
float f6 = getFloat();
int i1 = getInt();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
renderer.drawArc(f1, f2, f3, f4, f5, f6, i1 == 1, paint);
@@ -810,7 +838,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
break;
case DrawPath: {
SkPath* path = getPath();
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
renderer.drawPath(path, paint);
}
@@ -818,7 +846,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
case DrawLines: {
int count = 0;
float* points = getFloats(count);
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
renderer.drawLines(points, count, paint);
}
@@ -826,7 +854,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
case DrawPoints: {
int count = 0;
float* points = getFloats(count);
- SkPaint* paint = getPaint();
+ SkPaint* paint = getPaint(renderer);
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
renderer.drawPoints(points, count, paint);
}
@@ -836,10 +864,22 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
int count = getInt();
float x = getFloat();
float y = getFloat();
- SkPaint* paint = getPaint();
- DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
- text.text(), text.length(), count, x, y, paint);
- renderer.drawText(text.text(), text.length(), count, x, y, paint);
+ SkPaint* paint = getPaint(renderer);
+ float length = getFloat();
+ DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %.2f, %.2f, %p, %.2f", (char*) indent,
+ OP_NAMES[op], text.text(), text.length(), count, x, y, paint, length);
+ renderer.drawText(text.text(), text.length(), count, x, y, paint, length);
+ }
+ break;
+ case DrawPosText: {
+ getText(&text);
+ int count = getInt();
+ int positionsCount = 0;
+ float* positions = getFloats(positionsCount);
+ SkPaint* paint = getPaint(renderer);
+ DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent,
+ OP_NAMES[op], text.text(), text.length(), count, paint);
+ renderer.drawPosText(text.text(), text.length(), count, positions, paint);
}
break;
case ResetShader: {
@@ -879,6 +919,19 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
renderer.setupShadow(radius, dx, dy, color);
}
break;
+ case ResetPaintFilter: {
+ DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
+ renderer.resetPaintFilter();
+ }
+ break;
+ case SetupPaintFilter: {
+ int clearBits = getInt();
+ int setBits = getInt();
+ DISPLAY_LIST_LOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op],
+ clearBits, setBits);
+ renderer.setupPaintFilter(clearBits, setBits);
+ }
+ break;
default:
DISPLAY_LIST_LOGD("Display List error: op not handled: %s%s",
(char*) indent, OP_NAMES[op]);
@@ -886,6 +939,8 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
}
}
+ renderer.endMark();
+
DISPLAY_LIST_LOGD("%sDone, returning %d", (char*) indent + 2, needsInvalidate);
return needsInvalidate;
}
@@ -1196,12 +1251,32 @@ void DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
}
void DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
- float x, float y, SkPaint* paint) {
+ float x, float y, SkPaint* paint, float length) {
if (count <= 0) return;
addOp(DisplayList::DrawText);
addText(text, bytesCount);
addInt(count);
addPoint(x, y);
+ // TODO: We should probably make a copy of the paint instead of modifying
+ // it; modifying the paint will change its generationID the first
+ // time, which might impact caches. More investigation needed to
+ // see if it matters.
+ // If we make a copy, then drawTextDecorations() should *not* make
+ // its own copy as it does right now.
+ // Beware: this needs Glyph encoding (already done on the Paint constructor)
+ paint->setAntiAlias(true);
+ addPaint(paint);
+ addFloat(length < 0.0f ? paint->measureText(text, bytesCount) : length);
+}
+
+void DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
+ const float* positions, SkPaint* paint) {
+ if (count <= 0) return;
+ addOp(DisplayList::DrawPosText);
+ addText(text, bytesCount);
+ addInt(count);
+ addFloats(positions, count * 2);
+ paint->setAntiAlias(true);
addPaint(paint);
}
@@ -1234,5 +1309,15 @@ void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int colo
addInt(color);
}
+void DisplayListRenderer::resetPaintFilter() {
+ addOp(DisplayList::ResetPaintFilter);
+}
+
+void DisplayListRenderer::setupPaintFilter(int clearBits, int setBits) {
+ addOp(DisplayList::SetupPaintFilter);
+ addInt(clearBits);
+ addInt(setBits);
+}
+
}; // namespace uirenderer
}; // namespace android