2010-09-26 18:40:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LOG_TAG "OpenGLRenderer"
|
|
|
|
|
2012-03-13 11:18:20 -07:00
|
|
|
#include <SkCamera.h>
|
2011-03-24 10:51:31 -07:00
|
|
|
|
2012-03-26 16:45:05 -07:00
|
|
|
#include <private/hwui/DrawGlInfo.h>
|
|
|
|
|
2011-03-24 10:51:31 -07:00
|
|
|
#include "DisplayListLogBuffer.h"
|
2010-09-26 18:40:37 -07:00
|
|
|
#include "DisplayListRenderer.h"
|
2011-03-24 10:51:31 -07:00
|
|
|
#include "Caches.h"
|
2012-01-30 17:41:55 -08:00
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
2010-09-28 19:09:36 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Display list
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-01-13 17:21:49 -08:00
|
|
|
const char* DisplayList::OP_NAMES[] = {
|
|
|
|
"Save",
|
|
|
|
"Restore",
|
|
|
|
"RestoreToCount",
|
|
|
|
"SaveLayer",
|
|
|
|
"SaveLayerAlpha",
|
|
|
|
"Translate",
|
|
|
|
"Rotate",
|
|
|
|
"Scale",
|
2011-01-23 11:35:13 -08:00
|
|
|
"Skew",
|
2011-01-13 17:21:49 -08:00
|
|
|
"SetMatrix",
|
|
|
|
"ConcatMatrix",
|
|
|
|
"ClipRect",
|
|
|
|
"DrawDisplayList",
|
|
|
|
"DrawLayer",
|
|
|
|
"DrawBitmap",
|
|
|
|
"DrawBitmapMatrix",
|
|
|
|
"DrawBitmapRect",
|
2011-01-20 19:09:30 -08:00
|
|
|
"DrawBitmapMesh",
|
2011-01-13 17:21:49 -08:00
|
|
|
"DrawPatch",
|
|
|
|
"DrawColor",
|
|
|
|
"DrawRect",
|
2011-01-19 21:54:02 -08:00
|
|
|
"DrawRoundRect",
|
|
|
|
"DrawCircle",
|
2011-01-23 14:18:41 -08:00
|
|
|
"DrawOval",
|
2011-01-23 16:15:02 -08:00
|
|
|
"DrawArc",
|
2011-01-13 17:21:49 -08:00
|
|
|
"DrawPath",
|
|
|
|
"DrawLines",
|
2011-03-21 13:11:28 -07:00
|
|
|
"DrawPoints",
|
2011-01-13 17:21:49 -08:00
|
|
|
"DrawText",
|
2012-02-24 16:48:34 -08:00
|
|
|
"DrawTextOnPath",
|
2012-01-17 17:39:26 -08:00
|
|
|
"DrawPosText",
|
2011-01-13 17:21:49 -08:00
|
|
|
"ResetShader",
|
|
|
|
"SetupShader",
|
|
|
|
"ResetColorFilter",
|
|
|
|
"SetupColorFilter",
|
|
|
|
"ResetShadow",
|
2011-01-10 14:10:36 -08:00
|
|
|
"SetupShadow",
|
2012-01-23 17:09:05 -08:00
|
|
|
"ResetPaintFilter",
|
|
|
|
"SetupPaintFilter",
|
2011-01-10 14:10:36 -08:00
|
|
|
"DrawGLFunction"
|
2011-01-13 17:21:49 -08:00
|
|
|
};
|
|
|
|
|
2011-03-24 10:51:31 -07:00
|
|
|
void DisplayList::outputLogBuffer(int fd) {
|
|
|
|
DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
|
|
|
|
if (logBuffer.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-07-27 18:51:50 -07:00
|
|
|
|
2011-03-24 10:51:31 -07:00
|
|
|
FILE *file = fdopen(fd, "a");
|
2011-07-27 18:51:50 -07:00
|
|
|
|
2011-03-24 10:51:31 -07:00
|
|
|
fprintf(file, "\nRecent DisplayList operations\n");
|
|
|
|
logBuffer.outputCommands(file, OP_NAMES);
|
2011-07-27 18:51:50 -07:00
|
|
|
|
|
|
|
String8 cachesLog;
|
|
|
|
Caches::getInstance().dumpMemoryUsage(cachesLog);
|
|
|
|
fprintf(file, "\nCaches:\n%s", cachesLog.string());
|
|
|
|
fprintf(file, "\n");
|
|
|
|
|
2011-03-24 10:51:31 -07:00
|
|
|
fflush(file);
|
|
|
|
}
|
|
|
|
|
2012-03-13 11:42:34 -07:00
|
|
|
DisplayList::DisplayList(const DisplayListRenderer& recorder) :
|
2012-03-29 16:28:32 -07:00
|
|
|
mTransformMatrix(NULL), mTransformCamera(NULL), mTransformMatrix3D(NULL),
|
|
|
|
mStaticMatrix(NULL), mAnimationMatrix(NULL) {
|
2012-03-13 11:42:34 -07:00
|
|
|
|
2011-01-05 18:01:22 -08:00
|
|
|
initFromDisplayListRenderer(recorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayList::~DisplayList() {
|
2011-02-03 16:32:46 -08:00
|
|
|
clearResources();
|
|
|
|
}
|
|
|
|
|
2012-02-21 13:43:44 -08:00
|
|
|
void DisplayList::initProperties() {
|
|
|
|
mLeft = 0;
|
|
|
|
mTop = 0;
|
2012-03-26 14:37:51 -07:00
|
|
|
mRight = 0;
|
2012-02-21 13:43:44 -08:00
|
|
|
mBottom = 0;
|
|
|
|
mClipChildren = true;
|
|
|
|
mAlpha = 1;
|
|
|
|
mMultipliedAlpha = 255;
|
2012-03-21 18:54:18 -07:00
|
|
|
mHasOverlappingRendering = true;
|
2012-02-21 13:43:44 -08:00
|
|
|
mTranslationX = 0;
|
|
|
|
mTranslationY = 0;
|
|
|
|
mRotation = 0;
|
|
|
|
mRotationX = 0;
|
|
|
|
mRotationY= 0;
|
|
|
|
mScaleX = 1;
|
|
|
|
mScaleY = 1;
|
|
|
|
mPivotX = 0;
|
|
|
|
mPivotY = 0;
|
2012-03-26 14:37:51 -07:00
|
|
|
mCameraDistance = 0;
|
2012-02-21 13:43:44 -08:00
|
|
|
mMatrixDirty = false;
|
|
|
|
mMatrixFlags = 0;
|
|
|
|
mPrevWidth = -1;
|
|
|
|
mPrevHeight = -1;
|
|
|
|
mWidth = 0;
|
|
|
|
mHeight = 0;
|
|
|
|
mPivotExplicitlySet = false;
|
|
|
|
mCaching = false;
|
|
|
|
}
|
|
|
|
|
2012-03-05 13:44:35 -08:00
|
|
|
void DisplayList::destroyDisplayListDeferred(DisplayList* displayList) {
|
|
|
|
if (displayList) {
|
|
|
|
DISPLAY_LIST_LOGD("Deferring display list destruction");
|
|
|
|
Caches::getInstance().deleteDisplayListDeferred(displayList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-03 16:32:46 -08:00
|
|
|
void DisplayList::clearResources() {
|
2011-01-05 18:01:22 -08:00
|
|
|
sk_free((void*) mReader.base());
|
|
|
|
|
2012-03-13 11:13:13 -07:00
|
|
|
if (USE_DISPLAY_LIST_PROPERTIES) {
|
2012-03-29 16:28:32 -07:00
|
|
|
delete mTransformMatrix;
|
|
|
|
delete mTransformCamera;
|
|
|
|
delete mTransformMatrix3D;
|
|
|
|
delete mStaticMatrix;
|
|
|
|
delete mAnimationMatrix;
|
|
|
|
mTransformMatrix = NULL;
|
|
|
|
mTransformCamera = NULL;
|
|
|
|
mTransformMatrix3D = NULL;
|
|
|
|
mStaticMatrix = NULL;
|
|
|
|
mAnimationMatrix = NULL;
|
2012-02-21 13:43:44 -08:00
|
|
|
}
|
|
|
|
|
2011-01-05 18:01:22 -08:00
|
|
|
Caches& caches = Caches::getInstance();
|
|
|
|
|
|
|
|
for (size_t i = 0; i < mBitmapResources.size(); i++) {
|
|
|
|
caches.resourceCache.decrementRefcount(mBitmapResources.itemAt(i));
|
|
|
|
}
|
|
|
|
mBitmapResources.clear();
|
|
|
|
|
2011-06-22 16:14:36 -07:00
|
|
|
for (size_t i = 0; i < mFilterResources.size(); i++) {
|
|
|
|
caches.resourceCache.decrementRefcount(mFilterResources.itemAt(i));
|
|
|
|
}
|
|
|
|
mFilterResources.clear();
|
|
|
|
|
2011-01-14 15:31:00 -08:00
|
|
|
for (size_t i = 0; i < mShaders.size(); i++) {
|
2011-01-14 18:51:01 -08:00
|
|
|
caches.resourceCache.decrementRefcount(mShaders.itemAt(i));
|
2011-06-22 16:14:36 -07:00
|
|
|
caches.resourceCache.destructor(mShaders.itemAt(i));
|
2011-01-05 18:01:22 -08:00
|
|
|
}
|
2011-01-14 15:31:00 -08:00
|
|
|
mShaders.clear();
|
2011-01-05 18:01:22 -08:00
|
|
|
|
|
|
|
for (size_t i = 0; i < mPaints.size(); i++) {
|
|
|
|
delete mPaints.itemAt(i);
|
|
|
|
}
|
|
|
|
mPaints.clear();
|
|
|
|
|
2011-02-03 15:06:05 -08:00
|
|
|
for (size_t i = 0; i < mPaths.size(); i++) {
|
2011-03-24 16:03:55 -07:00
|
|
|
SkPath* path = mPaths.itemAt(i);
|
|
|
|
caches.pathCache.remove(path);
|
|
|
|
delete path;
|
2011-02-03 15:06:05 -08:00
|
|
|
}
|
|
|
|
mPaths.clear();
|
|
|
|
|
2011-01-05 18:01:22 -08:00
|
|
|
for (size_t i = 0; i < mMatrices.size(); i++) {
|
|
|
|
delete mMatrices.itemAt(i);
|
|
|
|
}
|
|
|
|
mMatrices.clear();
|
|
|
|
}
|
|
|
|
|
2011-02-03 16:32:46 -08:00
|
|
|
void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
|
2010-09-28 19:09:36 -07:00
|
|
|
const SkWriter32& writer = recorder.writeStream();
|
|
|
|
init();
|
|
|
|
|
|
|
|
if (writer.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-03 16:32:46 -08:00
|
|
|
if (reusing) {
|
|
|
|
// re-using display list - clear out previous allocations
|
|
|
|
clearResources();
|
|
|
|
}
|
2012-02-21 13:43:44 -08:00
|
|
|
initProperties();
|
2011-02-03 16:32:46 -08:00
|
|
|
|
2011-07-27 18:51:50 -07:00
|
|
|
mSize = writer.size();
|
|
|
|
void* buffer = sk_malloc_throw(mSize);
|
2010-09-28 19:09:36 -07:00
|
|
|
writer.flatten(buffer);
|
2011-07-27 18:51:50 -07:00
|
|
|
mReader.setMemory(buffer, mSize);
|
2010-09-28 19:09:36 -07:00
|
|
|
|
2010-10-08 08:37:55 -07:00
|
|
|
Caches& caches = Caches::getInstance();
|
2010-09-28 19:09:36 -07:00
|
|
|
|
2010-10-08 08:37:55 -07:00
|
|
|
const Vector<SkBitmap*> &bitmapResources = recorder.getBitmapResources();
|
|
|
|
for (size_t i = 0; i < bitmapResources.size(); i++) {
|
|
|
|
SkBitmap* resource = bitmapResources.itemAt(i);
|
|
|
|
mBitmapResources.add(resource);
|
|
|
|
caches.resourceCache.incrementRefcount(resource);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
2010-10-25 15:47:32 -07:00
|
|
|
|
2011-06-22 16:14:36 -07:00
|
|
|
const Vector<SkiaColorFilter*> &filterResources = recorder.getFilterResources();
|
|
|
|
for (size_t i = 0; i < filterResources.size(); i++) {
|
|
|
|
SkiaColorFilter* resource = filterResources.itemAt(i);
|
|
|
|
mFilterResources.add(resource);
|
|
|
|
caches.resourceCache.incrementRefcount(resource);
|
|
|
|
}
|
|
|
|
|
2011-01-14 15:31:00 -08:00
|
|
|
const Vector<SkiaShader*> &shaders = recorder.getShaders();
|
|
|
|
for (size_t i = 0; i < shaders.size(); i++) {
|
2011-06-22 16:14:36 -07:00
|
|
|
SkiaShader* resource = shaders.itemAt(i);
|
|
|
|
mShaders.add(resource);
|
|
|
|
caches.resourceCache.incrementRefcount(resource);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
|
2010-10-25 15:47:32 -07:00
|
|
|
const Vector<SkPaint*> &paints = recorder.getPaints();
|
|
|
|
for (size_t i = 0; i < paints.size(); i++) {
|
|
|
|
mPaints.add(paints.itemAt(i));
|
|
|
|
}
|
|
|
|
|
2011-02-03 15:06:05 -08:00
|
|
|
const Vector<SkPath*> &paths = recorder.getPaths();
|
|
|
|
for (size_t i = 0; i < paths.size(); i++) {
|
|
|
|
mPaths.add(paths.itemAt(i));
|
|
|
|
}
|
|
|
|
|
2010-10-25 15:47:32 -07:00
|
|
|
const Vector<SkMatrix*> &matrices = recorder.getMatrices();
|
|
|
|
for (size_t i = 0; i < matrices.size(); i++) {
|
|
|
|
mMatrices.add(matrices.itemAt(i));
|
|
|
|
}
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayList::init() {
|
2011-07-27 18:51:50 -07:00
|
|
|
mSize = 0;
|
2011-08-25 14:01:48 -07:00
|
|
|
mIsRenderable = true;
|
2011-07-27 18:51:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t DisplayList::getSize() {
|
|
|
|
return mSize;
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
|
2011-04-22 16:18:45 -07:00
|
|
|
/**
|
|
|
|
* This function is a simplified version of replay(), where we simply retrieve and log the
|
|
|
|
* display list. This function should remain in sync with the replay() function.
|
|
|
|
*/
|
|
|
|
void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
|
|
|
|
TextContainer text;
|
|
|
|
|
|
|
|
uint32_t count = (level + 1) * 2;
|
|
|
|
char indent[count + 1];
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
|
|
|
indent[i] = ' ';
|
|
|
|
}
|
|
|
|
indent[count] = '\0';
|
2012-01-30 17:41:55 -08:00
|
|
|
ALOGD("%sStart display list (%p, %s)", (char*) indent + 2, this, mName.string());
|
2011-04-22 16:18:45 -07:00
|
|
|
|
|
|
|
int saveCount = renderer.getSaveCount() - 1;
|
|
|
|
|
2012-02-21 13:43:44 -08:00
|
|
|
outputViewProperties(renderer, (char*) indent);
|
2011-04-22 16:18:45 -07:00
|
|
|
mReader.rewind();
|
|
|
|
|
|
|
|
while (!mReader.eof()) {
|
|
|
|
int op = mReader.readInt();
|
2012-02-16 19:24:51 -08:00
|
|
|
if (op & OP_MAY_BE_SKIPPED_MASK) {
|
|
|
|
int skip = mReader.readInt();
|
|
|
|
ALOGD("%sSkip %d", (char*) indent, skip);
|
|
|
|
op &= ~OP_MAY_BE_SKIPPED_MASK;
|
2012-02-21 13:43:44 -08:00
|
|
|
}
|
2011-04-22 16:18:45 -07:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case DrawGLFunction: {
|
|
|
|
Functor *functor = (Functor *) getInt();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Save: {
|
|
|
|
int rendererNum = getInt();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Restore: {
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RestoreToCount: {
|
|
|
|
int restoreCount = saveCount + getInt();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SaveLayer: {
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-04-22 16:18:45 -07:00
|
|
|
int flags = getInt();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
|
2012-02-21 13:43:44 -08:00
|
|
|
OP_NAMES[op], f1, f2, f3, f4, paint, flags);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SaveLayerAlpha: {
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
|
|
|
int alpha = getInt();
|
|
|
|
int flags = getInt();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
|
2012-02-21 13:43:44 -08:00
|
|
|
OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Translate: {
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Rotate: {
|
|
|
|
float rotation = getFloat();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Scale: {
|
|
|
|
float sx = getFloat();
|
|
|
|
float sy = getFloat();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Skew: {
|
|
|
|
float sx = getFloat();
|
|
|
|
float sy = getFloat();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SetMatrix: {
|
|
|
|
SkMatrix* matrix = getMatrix();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ConcatMatrix: {
|
|
|
|
SkMatrix* matrix = getMatrix();
|
2012-02-21 13:43:44 -08:00
|
|
|
ALOGD("%s%s new concat %p: [%f, %f, %f] [%f, %f, %f] [%f, %f, %f]",
|
|
|
|
(char*) indent, OP_NAMES[op], matrix, matrix->get(0), matrix->get(1),
|
|
|
|
matrix->get(2), matrix->get(3), matrix->get(4), matrix->get(5),
|
|
|
|
matrix->get(6), matrix->get(7), matrix->get(8));
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ClipRect: {
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
|
|
|
int regionOp = getInt();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
f1, f2, f3, f4, regionOp);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawDisplayList: {
|
|
|
|
DisplayList* displayList = getDisplayList();
|
|
|
|
uint32_t width = getUInt();
|
|
|
|
uint32_t height = getUInt();
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t flags = getInt();
|
|
|
|
ALOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
displayList, width, height, flags, level + 1);
|
2011-04-22 16:18:45 -07:00
|
|
|
renderer.outputDisplayList(displayList, level + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawLayer: {
|
|
|
|
Layer* layer = (Layer*) getInt();
|
|
|
|
float x = getFloat();
|
|
|
|
float y = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
layer, x, y, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawBitmap: {
|
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
float x = getFloat();
|
|
|
|
float y = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
bitmap, x, y, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawBitmapMatrix: {
|
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
SkMatrix* matrix = getMatrix();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
bitmap, matrix, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawBitmapRect: {
|
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
|
|
|
float f5 = getFloat();
|
|
|
|
float f6 = getFloat();
|
|
|
|
float f7 = getFloat();
|
|
|
|
float f8 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawBitmapMesh: {
|
|
|
|
int verticesCount = 0;
|
|
|
|
uint32_t colorsCount = 0;
|
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
uint32_t meshWidth = getInt();
|
|
|
|
uint32_t meshHeight = getInt();
|
|
|
|
float* vertices = getFloats(verticesCount);
|
|
|
|
bool hasColors = getInt();
|
|
|
|
int* colors = hasColors ? getInts(colorsCount) : NULL;
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawPatch: {
|
|
|
|
int32_t* xDivs = NULL;
|
|
|
|
int32_t* yDivs = NULL;
|
|
|
|
uint32_t* colors = NULL;
|
|
|
|
uint32_t xDivsCount = 0;
|
|
|
|
uint32_t yDivsCount = 0;
|
|
|
|
int8_t numColors = 0;
|
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
xDivs = getInts(xDivsCount);
|
|
|
|
yDivs = getInts(yDivsCount);
|
|
|
|
colors = getUInts(numColors);
|
2011-10-19 17:06:19 -07:00
|
|
|
float left = getFloat();
|
|
|
|
float top = getFloat();
|
|
|
|
float right = getFloat();
|
|
|
|
float bottom = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", (char*) indent, OP_NAMES[op],
|
2011-10-19 17:06:19 -07:00
|
|
|
left, top, right, bottom);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawColor: {
|
|
|
|
int color = getInt();
|
|
|
|
int xferMode = getInt();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawRect: {
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
f1, f2, f3, f4, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawRoundRect: {
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
|
|
|
float f5 = getFloat();
|
|
|
|
float f6 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawCircle: {
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], f1, f2, f3, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawOval: {
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawArc: {
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
|
|
|
float f5 = getFloat();
|
|
|
|
float f6 = getFloat();
|
|
|
|
int i1 = getInt();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawPath: {
|
|
|
|
SkPath* path = getPath();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawLines: {
|
|
|
|
int count = 0;
|
|
|
|
float* points = getFloats(count);
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawPoints: {
|
|
|
|
int count = 0;
|
|
|
|
float* points = getFloats(count);
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawText: {
|
|
|
|
getText(&text);
|
2012-02-24 16:48:34 -08:00
|
|
|
int32_t count = getInt();
|
2011-04-22 16:18:45 -07:00
|
|
|
float x = getFloat();
|
|
|
|
float y = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-01 20:08:50 -08:00
|
|
|
float length = getFloat();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %s, %d, %d, %.2f, %.2f, %p, %.2f", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
text.text(), text.length(), count, x, y, paint, length);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
2012-02-24 16:48:34 -08:00
|
|
|
case DrawTextOnPath: {
|
|
|
|
getText(&text);
|
|
|
|
int32_t count = getInt();
|
|
|
|
SkPath* path = getPath();
|
|
|
|
float hOffset = getFloat();
|
|
|
|
float vOffset = getFloat();
|
|
|
|
SkPaint* paint = getPaint(renderer);
|
|
|
|
ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
|
|
|
|
text.text(), text.length(), count, paint);
|
|
|
|
}
|
|
|
|
break;
|
2012-01-17 17:39:26 -08:00
|
|
|
case DrawPosText: {
|
|
|
|
getText(&text);
|
|
|
|
int count = getInt();
|
|
|
|
int positionsCount = 0;
|
|
|
|
float* positions = getFloats(positionsCount);
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2012-01-17 17:39:26 -08:00
|
|
|
ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
text.text(), text.length(), count, paint);
|
2012-01-17 17:39:26 -08:00
|
|
|
}
|
2011-04-22 16:18:45 -07:00
|
|
|
case ResetShader: {
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SetupShader: {
|
|
|
|
SkiaShader* shader = getShader();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ResetColorFilter: {
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SetupColorFilter: {
|
|
|
|
SkiaColorFilter *colorFilter = getColorFilter();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ResetShadow: {
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SetupShadow: {
|
|
|
|
float radius = getFloat();
|
|
|
|
float dx = getFloat();
|
|
|
|
float dy = getFloat();
|
|
|
|
int color = getInt();
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
radius, dx, dy, color);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
|
|
|
break;
|
2012-01-23 17:09:05 -08:00
|
|
|
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;
|
2011-04-22 16:18:45 -07:00
|
|
|
default:
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("Display List error: op not handled: %s%s",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op]);
|
2011-04-22 16:18:45 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-02-21 13:43:44 -08:00
|
|
|
ALOGD("%sDone (%p, %s)", (char*) indent + 2, this, mName.string());
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayList::updateMatrix() {
|
|
|
|
if (mMatrixDirty) {
|
|
|
|
if (!mTransformMatrix) {
|
|
|
|
mTransformMatrix = new SkMatrix();
|
|
|
|
}
|
|
|
|
if (mMatrixFlags == 0 || mMatrixFlags == TRANSLATION) {
|
|
|
|
mTransformMatrix->reset();
|
|
|
|
} else {
|
|
|
|
if (!mPivotExplicitlySet) {
|
|
|
|
if (mWidth != mPrevWidth || mHeight != mPrevHeight) {
|
|
|
|
mPrevWidth = mWidth;
|
|
|
|
mPrevHeight = mHeight;
|
|
|
|
mPivotX = mPrevWidth / 2;
|
|
|
|
mPivotY = mPrevHeight / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((mMatrixFlags & ROTATION_3D) == 0) {
|
|
|
|
mTransformMatrix->setTranslate(mTranslationX, mTranslationY);
|
|
|
|
mTransformMatrix->preRotate(mRotation, mPivotX, mPivotY);
|
|
|
|
mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
|
|
|
|
} else {
|
|
|
|
if (!mTransformCamera) {
|
|
|
|
mTransformCamera = new Sk3DView();
|
|
|
|
mTransformMatrix3D = new SkMatrix();
|
|
|
|
}
|
|
|
|
mTransformMatrix->reset();
|
|
|
|
mTransformCamera->save();
|
|
|
|
mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
|
|
|
|
mTransformCamera->rotateX(mRotationX);
|
|
|
|
mTransformCamera->rotateY(mRotationY);
|
|
|
|
mTransformCamera->rotateZ(-mRotation);
|
|
|
|
mTransformCamera->getMatrix(mTransformMatrix3D);
|
|
|
|
mTransformMatrix3D->preTranslate(-mPivotX, -mPivotY);
|
|
|
|
mTransformMatrix3D->postTranslate(mPivotX + mTranslationX,
|
|
|
|
mPivotY + mTranslationY);
|
|
|
|
mTransformMatrix->postConcat(*mTransformMatrix3D);
|
|
|
|
mTransformCamera->restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mMatrixDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
|
|
|
|
if (USE_DISPLAY_LIST_PROPERTIES) {
|
|
|
|
updateMatrix();
|
|
|
|
if (mLeft != 0 || mTop != 0) {
|
2012-03-29 16:28:32 -07:00
|
|
|
ALOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
|
|
|
|
}
|
|
|
|
if (mStaticMatrix) {
|
|
|
|
ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
|
|
|
|
indent, "ConcatMatrix (static)", mStaticMatrix,
|
|
|
|
mStaticMatrix->get(0), mStaticMatrix->get(1),
|
|
|
|
mStaticMatrix->get(2), mStaticMatrix->get(3),
|
|
|
|
mStaticMatrix->get(4), mStaticMatrix->get(5),
|
|
|
|
mStaticMatrix->get(6), mStaticMatrix->get(7),
|
|
|
|
mStaticMatrix->get(8));
|
|
|
|
}
|
|
|
|
if (mAnimationMatrix) {
|
|
|
|
ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
|
|
|
|
indent, "ConcatMatrix (animation)", mAnimationMatrix,
|
|
|
|
mAnimationMatrix->get(0), mAnimationMatrix->get(1),
|
|
|
|
mAnimationMatrix->get(2), mAnimationMatrix->get(3),
|
|
|
|
mAnimationMatrix->get(4), mAnimationMatrix->get(5),
|
|
|
|
mAnimationMatrix->get(6), mAnimationMatrix->get(7),
|
|
|
|
mAnimationMatrix->get(8));
|
2012-02-21 13:43:44 -08:00
|
|
|
}
|
|
|
|
if (mMatrixFlags != 0) {
|
|
|
|
if (mMatrixFlags == TRANSLATION) {
|
|
|
|
ALOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
|
|
|
|
} else {
|
|
|
|
ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
|
|
|
|
indent, "ConcatMatrix", mTransformMatrix,
|
|
|
|
mTransformMatrix->get(0), mTransformMatrix->get(1),
|
|
|
|
mTransformMatrix->get(2), mTransformMatrix->get(3),
|
|
|
|
mTransformMatrix->get(4), mTransformMatrix->get(5),
|
|
|
|
mTransformMatrix->get(6), mTransformMatrix->get(7),
|
|
|
|
mTransformMatrix->get(8));
|
|
|
|
}
|
|
|
|
}
|
2012-03-26 14:37:51 -07:00
|
|
|
if (mAlpha < 1 && !mCaching) {
|
2012-03-13 11:03:25 -07:00
|
|
|
// TODO: should be able to store the size of a DL at record time and not
|
|
|
|
// have to pass it into this call. In fact, this information might be in the
|
|
|
|
// location/size info that we store with the new native transform data.
|
|
|
|
int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
|
|
|
|
if (mClipChildren) {
|
|
|
|
flags |= SkCanvas::kClipToLayer_SaveFlag;
|
|
|
|
}
|
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
|
|
|
|
(float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
|
|
|
|
mMultipliedAlpha, flags);
|
|
|
|
}
|
2012-02-21 13:43:44 -08:00
|
|
|
if (mClipChildren) {
|
|
|
|
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
|
|
|
|
(float) mRight - mLeft, (float) mBottom - mTop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-22 16:18:45 -07:00
|
|
|
|
2012-02-21 13:43:44 -08:00
|
|
|
void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t width, uint32_t height,
|
|
|
|
uint32_t level) {
|
|
|
|
if (USE_DISPLAY_LIST_PROPERTIES) {
|
|
|
|
#if DEBUG_DISPLAY_LIST
|
|
|
|
uint32_t count = (level + 1) * 2;
|
|
|
|
char indent[count + 1];
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
|
|
|
indent[i] = ' ';
|
|
|
|
}
|
|
|
|
indent[count] = '\0';
|
|
|
|
#endif
|
|
|
|
updateMatrix();
|
|
|
|
if (mLeft != 0 || mTop != 0) {
|
2012-03-29 16:28:32 -07:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
|
2012-02-21 13:43:44 -08:00
|
|
|
renderer.translate(mLeft, mTop);
|
|
|
|
}
|
2012-03-29 16:28:32 -07:00
|
|
|
if (mStaticMatrix) {
|
|
|
|
DISPLAY_LIST_LOGD(
|
|
|
|
"%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
|
|
|
|
indent, "ConcatMatrix (static)", mStaticMatrix,
|
|
|
|
mStaticMatrix->get(0), mStaticMatrix->get(1),
|
|
|
|
mStaticMatrix->get(2), mStaticMatrix->get(3),
|
|
|
|
mStaticMatrix->get(4), mStaticMatrix->get(5),
|
|
|
|
mStaticMatrix->get(6), mStaticMatrix->get(7),
|
|
|
|
mStaticMatrix->get(8));
|
|
|
|
renderer.concatMatrix(mStaticMatrix);
|
|
|
|
} else if (mAnimationMatrix) {
|
|
|
|
DISPLAY_LIST_LOGD(
|
|
|
|
"%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
|
|
|
|
indent, "ConcatMatrix (animation)", mAnimationMatrix,
|
|
|
|
mAnimationMatrix->get(0), mAnimationMatrix->get(1),
|
|
|
|
mAnimationMatrix->get(2), mAnimationMatrix->get(3),
|
|
|
|
mAnimationMatrix->get(4), mAnimationMatrix->get(5),
|
|
|
|
mAnimationMatrix->get(6), mAnimationMatrix->get(7),
|
|
|
|
mAnimationMatrix->get(8));
|
|
|
|
renderer.concatMatrix(mAnimationMatrix);
|
2012-02-21 13:43:44 -08:00
|
|
|
}
|
|
|
|
if (mMatrixFlags != 0) {
|
|
|
|
if (mMatrixFlags == TRANSLATION) {
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
|
|
|
|
renderer.translate(mTranslationX, mTranslationY);
|
|
|
|
} else {
|
|
|
|
DISPLAY_LIST_LOGD(
|
|
|
|
"%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
|
|
|
|
indent, "ConcatMatrix", mTransformMatrix,
|
|
|
|
mTransformMatrix->get(0), mTransformMatrix->get(1),
|
|
|
|
mTransformMatrix->get(2), mTransformMatrix->get(3),
|
|
|
|
mTransformMatrix->get(4), mTransformMatrix->get(5),
|
|
|
|
mTransformMatrix->get(6), mTransformMatrix->get(7),
|
|
|
|
mTransformMatrix->get(8));
|
|
|
|
renderer.concatMatrix(mTransformMatrix);
|
|
|
|
}
|
|
|
|
}
|
2012-03-13 11:03:25 -07:00
|
|
|
if (mAlpha < 1 && !mCaching) {
|
2012-03-21 18:54:18 -07:00
|
|
|
if (!mHasOverlappingRendering) {
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
|
|
|
|
renderer.setAlpha(mAlpha);
|
|
|
|
} else {
|
|
|
|
// TODO: should be able to store the size of a DL at record time and not
|
|
|
|
// have to pass it into this call. In fact, this information might be in the
|
|
|
|
// location/size info that we store with the new native transform data.
|
|
|
|
int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
|
|
|
|
if (mClipChildren) {
|
|
|
|
flags |= SkCanvas::kClipToLayer_SaveFlag;
|
|
|
|
}
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
|
|
|
|
(float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
|
|
|
|
mMultipliedAlpha, flags);
|
|
|
|
renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
|
|
|
|
mMultipliedAlpha, flags);
|
2012-03-13 11:03:25 -07:00
|
|
|
}
|
|
|
|
}
|
2012-02-21 13:43:44 -08:00
|
|
|
if (mClipChildren) {
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
|
|
|
|
(float) mRight - mLeft, (float) mBottom - mTop);
|
|
|
|
renderer.clipRect(0, 0, mRight - mLeft, mBottom - mTop,
|
|
|
|
SkRegion::kIntersect_Op);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-22 16:18:45 -07:00
|
|
|
/**
|
|
|
|
* Changes to replay(), specifically those involving opcode or parameter changes, should be mimicked
|
|
|
|
* in the output() function, since that function processes the same list of opcodes for the
|
|
|
|
* purposes of logging display list info for a given view.
|
|
|
|
*/
|
2012-03-26 16:45:05 -07:00
|
|
|
status_t DisplayList::replay(OpenGLRenderer& renderer, uint32_t width,
|
2012-02-21 13:43:44 -08:00
|
|
|
uint32_t height, Rect& dirty, int32_t flags, uint32_t level) {
|
2012-03-26 16:45:05 -07:00
|
|
|
status_t drawGlStatus = 0;
|
2010-09-28 19:09:36 -07:00
|
|
|
TextContainer text;
|
|
|
|
mReader.rewind();
|
|
|
|
|
2011-01-13 17:21:49 -08:00
|
|
|
#if DEBUG_DISPLAY_LIST
|
|
|
|
uint32_t count = (level + 1) * 2;
|
|
|
|
char indent[count + 1];
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
|
|
|
indent[i] = ' ';
|
|
|
|
}
|
|
|
|
indent[count] = '\0';
|
2012-04-12 15:19:04 -07:00
|
|
|
Rect* clipRect = renderer.getClipRect();
|
|
|
|
DISPLAY_LIST_LOGD("%sStart display list (%p, %s), clipRect: %.0f, %.f, %.0f, %.0f",
|
|
|
|
(char*) indent + 2, this, mName.string(), clipRect->left, clipRect->top,
|
|
|
|
clipRect->right, clipRect->bottom);
|
2011-01-13 17:21:49 -08:00
|
|
|
#endif
|
2010-09-28 19:09:36 -07:00
|
|
|
|
2012-01-30 17:41:55 -08:00
|
|
|
renderer.startMark(mName.string());
|
2012-02-21 13:43:44 -08:00
|
|
|
int restoreTo = 0;
|
|
|
|
if (USE_DISPLAY_LIST_PROPERTIES) {
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %d", indent, "Save",
|
|
|
|
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
|
|
|
|
restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
|
|
|
|
}
|
|
|
|
setViewProperties(renderer, width, height, level);
|
2012-03-26 14:37:51 -07:00
|
|
|
if (USE_DISPLAY_LIST_PROPERTIES && renderer.quickReject(0, 0, width, height)) {
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
|
|
|
|
renderer.restoreToCount(restoreTo);
|
|
|
|
renderer.endMark();
|
|
|
|
return false;
|
|
|
|
}
|
2012-01-30 17:41:55 -08:00
|
|
|
|
2011-03-24 10:51:31 -07:00
|
|
|
DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
|
2011-01-13 17:21:49 -08:00
|
|
|
int saveCount = renderer.getSaveCount() - 1;
|
2010-09-28 19:09:36 -07:00
|
|
|
while (!mReader.eof()) {
|
2010-10-27 18:57:51 -07:00
|
|
|
int op = mReader.readInt();
|
2012-02-16 19:24:51 -08:00
|
|
|
if (op & OP_MAY_BE_SKIPPED_MASK) {
|
2012-03-13 18:00:10 -07:00
|
|
|
int32_t skip = mReader.readInt();
|
2012-02-16 19:24:51 -08:00
|
|
|
if (CC_LIKELY(flags & kReplayFlag_ClipChildren)) {
|
|
|
|
mReader.skip(skip);
|
|
|
|
DISPLAY_LIST_LOGD("%s%s skipping %d bytes", (char*) indent,
|
|
|
|
OP_NAMES[op & ~OP_MAY_BE_SKIPPED_MASK], skip);
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
op &= ~OP_MAY_BE_SKIPPED_MASK;
|
|
|
|
}
|
|
|
|
}
|
2011-03-24 10:51:31 -07:00
|
|
|
logBuffer.writeCommand(level, op);
|
2011-01-13 17:21:49 -08:00
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
switch (op) {
|
2011-01-10 14:10:36 -08:00
|
|
|
case DrawGLFunction: {
|
|
|
|
Functor *functor = (Functor *) getInt();
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
|
2012-01-30 17:41:55 -08:00
|
|
|
renderer.startMark("GL functor");
|
2012-03-26 16:45:05 -07:00
|
|
|
drawGlStatus |= renderer.callDrawGLFunction(functor, dirty);
|
2012-01-30 17:41:55 -08:00
|
|
|
renderer.endMark();
|
2011-01-10 14:10:36 -08:00
|
|
|
}
|
|
|
|
break;
|
2010-09-28 19:09:36 -07:00
|
|
|
case Save: {
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t rendererNum = getInt();
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
|
|
|
|
renderer.save(rendererNum);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Restore: {
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2010-09-28 19:09:36 -07:00
|
|
|
renderer.restore();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RestoreToCount: {
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t restoreCount = saveCount + getInt();
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
|
|
|
|
renderer.restoreToCount(restoreCount);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SaveLayer: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t flags = getInt();
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
|
2012-02-21 13:43:44 -08:00
|
|
|
OP_NAMES[op], f1, f2, f3, f4, paint, flags);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.saveLayer(f1, f2, f3, f4, paint, flags);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
2010-10-27 18:57:51 -07:00
|
|
|
case SaveLayerAlpha: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t alpha = getInt();
|
|
|
|
int32_t flags = getInt();
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
|
2012-02-21 13:43:44 -08:00
|
|
|
OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.saveLayerAlpha(f1, f2, f3, f4, alpha, flags);
|
2010-10-27 18:57:51 -07:00
|
|
|
}
|
|
|
|
break;
|
2010-09-28 19:09:36 -07:00
|
|
|
case Translate: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
|
|
|
|
renderer.translate(f1, f2);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Rotate: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float rotation = getFloat();
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
|
|
|
|
renderer.rotate(rotation);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Scale: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float sx = getFloat();
|
|
|
|
float sy = getFloat();
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
|
|
|
|
renderer.scale(sx, sy);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
2011-01-18 11:19:19 -08:00
|
|
|
case Skew: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float sx = getFloat();
|
|
|
|
float sy = getFloat();
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
|
|
|
|
renderer.skew(sx, sy);
|
2011-01-18 11:19:19 -08:00
|
|
|
}
|
|
|
|
break;
|
2010-09-28 19:09:36 -07:00
|
|
|
case SetMatrix: {
|
2011-01-10 14:10:36 -08:00
|
|
|
SkMatrix* matrix = getMatrix();
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
|
|
|
|
renderer.setMatrix(matrix);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ConcatMatrix: {
|
2011-01-10 14:10:36 -08:00
|
|
|
SkMatrix* matrix = getMatrix();
|
2012-02-21 13:43:44 -08:00
|
|
|
DISPLAY_LIST_LOGD(
|
|
|
|
"%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
|
|
|
|
(char*) indent, OP_NAMES[op], matrix,
|
|
|
|
matrix->get(0), matrix->get(1), matrix->get(2),
|
|
|
|
matrix->get(3), matrix->get(4), matrix->get(5),
|
|
|
|
matrix->get(6), matrix->get(7), matrix->get(8));
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.concatMatrix(matrix);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ClipRect: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t regionOp = getInt();
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
f1, f2, f3, f4, regionOp);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.clipRect(f1, f2, f3, f4, (SkRegion::Op) regionOp);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
2010-11-08 12:08:41 -08:00
|
|
|
case DrawDisplayList: {
|
2011-01-10 14:10:36 -08:00
|
|
|
DisplayList* displayList = getDisplayList();
|
2011-03-14 18:05:08 -07:00
|
|
|
uint32_t width = getUInt();
|
|
|
|
uint32_t height = getUInt();
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t flags = getInt();
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
displayList, width, height, flags, level + 1);
|
2012-03-26 16:45:05 -07:00
|
|
|
drawGlStatus |= renderer.drawDisplayList(displayList, width,
|
2012-02-21 13:43:44 -08:00
|
|
|
height, dirty, flags, level + 1);
|
2010-11-08 12:08:41 -08:00
|
|
|
}
|
|
|
|
break;
|
2011-01-11 14:29:25 -08:00
|
|
|
case DrawLayer: {
|
2011-01-10 14:10:36 -08:00
|
|
|
Layer* layer = (Layer*) getInt();
|
|
|
|
float x = getFloat();
|
|
|
|
float y = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2012-02-21 13:43:44 -08:00
|
|
|
if (mCaching && mMultipliedAlpha < 255) {
|
|
|
|
paint->setAlpha(mMultipliedAlpha);
|
|
|
|
}
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
layer, x, y, paint);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.drawLayer(layer, x, y, paint);
|
2011-01-11 14:29:25 -08:00
|
|
|
}
|
|
|
|
break;
|
2010-09-28 19:09:36 -07:00
|
|
|
case DrawBitmap: {
|
2011-01-10 14:10:36 -08:00
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
float x = getFloat();
|
|
|
|
float y = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2012-03-26 14:37:51 -07:00
|
|
|
if (mCaching && mMultipliedAlpha < 255) {
|
|
|
|
paint->setAlpha(mMultipliedAlpha);
|
|
|
|
}
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
bitmap, x, y, paint);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.drawBitmap(bitmap, x, y, paint);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawBitmapMatrix: {
|
2011-01-10 14:10:36 -08:00
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
SkMatrix* matrix = getMatrix();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
bitmap, matrix, paint);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.drawBitmap(bitmap, matrix, paint);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawBitmapRect: {
|
2011-01-10 14:10:36 -08:00
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
|
|
|
float f5 = getFloat();
|
|
|
|
float f6 = getFloat();
|
|
|
|
float f7 = getFloat();
|
|
|
|
float f8 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], bitmap,
|
|
|
|
f1, f2, f3, f4, f5, f6, f7, f8,paint);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.drawBitmap(bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
2011-01-20 19:09:30 -08:00
|
|
|
case DrawBitmapMesh: {
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t verticesCount = 0;
|
2011-01-20 19:09:30 -08:00
|
|
|
uint32_t colorsCount = 0;
|
|
|
|
|
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
uint32_t meshWidth = getInt();
|
|
|
|
uint32_t meshHeight = getInt();
|
|
|
|
float* vertices = getFloats(verticesCount);
|
|
|
|
bool hasColors = getInt();
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t* colors = hasColors ? getInts(colorsCount) : NULL;
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-20 19:09:30 -08:00
|
|
|
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-06-28 14:02:11 -07:00
|
|
|
renderer.drawBitmapMesh(bitmap, meshWidth, meshHeight, vertices, colors, paint);
|
2011-01-20 19:09:30 -08:00
|
|
|
}
|
2011-01-23 16:36:11 -08:00
|
|
|
break;
|
2010-09-28 19:09:36 -07:00
|
|
|
case DrawPatch: {
|
|
|
|
int32_t* xDivs = NULL;
|
|
|
|
int32_t* yDivs = NULL;
|
2010-10-12 15:59:26 -07:00
|
|
|
uint32_t* colors = NULL;
|
2010-09-28 19:09:36 -07:00
|
|
|
uint32_t xDivsCount = 0;
|
|
|
|
uint32_t yDivsCount = 0;
|
2010-10-12 15:59:26 -07:00
|
|
|
int8_t numColors = 0;
|
2010-09-28 19:09:36 -07:00
|
|
|
|
|
|
|
SkBitmap* bitmap = getBitmap();
|
|
|
|
|
|
|
|
xDivs = getInts(xDivsCount);
|
|
|
|
yDivs = getInts(yDivsCount);
|
2010-10-12 15:59:26 -07:00
|
|
|
colors = getUInts(numColors);
|
2010-09-28 19:09:36 -07:00
|
|
|
|
2011-06-28 14:02:11 -07:00
|
|
|
float left = getFloat();
|
|
|
|
float top = getFloat();
|
|
|
|
float right = getFloat();
|
|
|
|
float bottom = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-06-28 14:02:11 -07:00
|
|
|
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2010-10-12 15:59:26 -07:00
|
|
|
renderer.drawPatch(bitmap, xDivs, yDivs, colors, xDivsCount, yDivsCount,
|
2011-06-28 14:02:11 -07:00
|
|
|
numColors, left, top, right, bottom, paint);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawColor: {
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t color = getInt();
|
|
|
|
int32_t xferMode = getInt();
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
|
|
|
|
renderer.drawColor(color, (SkXfermode::Mode) xferMode);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawRect: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
f1, f2, f3, f4, paint);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.drawRect(f1, f2, f3, f4, paint);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
2011-01-19 21:54:02 -08:00
|
|
|
case DrawRoundRect: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
|
|
|
float f5 = getFloat();
|
|
|
|
float f6 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.drawRoundRect(f1, f2, f3, f4, f5, f6, paint);
|
2011-01-19 21:54:02 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawCircle: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], f1, f2, f3, paint);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.drawCircle(f1, f2, f3, paint);
|
2011-01-19 21:54:02 -08:00
|
|
|
}
|
|
|
|
break;
|
2011-01-23 14:18:41 -08:00
|
|
|
case DrawOval: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.drawOval(f1, f2, f3, f4, paint);
|
2011-01-23 14:18:41 -08:00
|
|
|
}
|
|
|
|
break;
|
2011-01-23 16:15:02 -08:00
|
|
|
case DrawArc: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float f1 = getFloat();
|
|
|
|
float f2 = getFloat();
|
|
|
|
float f3 = getFloat();
|
|
|
|
float f4 = getFloat();
|
|
|
|
float f5 = getFloat();
|
|
|
|
float f6 = getFloat();
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t i1 = getInt();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.drawArc(f1, f2, f3, f4, f5, f6, i1 == 1, paint);
|
2011-01-23 16:15:02 -08:00
|
|
|
}
|
|
|
|
break;
|
2010-09-28 19:09:36 -07:00
|
|
|
case DrawPath: {
|
2011-01-10 14:10:36 -08:00
|
|
|
SkPath* path = getPath();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
|
|
|
|
renderer.drawPath(path, paint);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DrawLines: {
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t count = 0;
|
2010-09-28 19:09:36 -07:00
|
|
|
float* points = getFloats(count);
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-06-28 14:02:11 -07:00
|
|
|
renderer.drawLines(points, count, paint);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
2011-03-21 13:11:28 -07:00
|
|
|
case DrawPoints: {
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t count = 0;
|
2011-03-21 13:11:28 -07:00
|
|
|
float* points = getFloats(count);
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-03-21 13:11:28 -07:00
|
|
|
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2011-06-28 14:02:11 -07:00
|
|
|
renderer.drawPoints(points, count, paint);
|
2011-03-21 13:11:28 -07:00
|
|
|
}
|
|
|
|
break;
|
2010-09-28 19:09:36 -07:00
|
|
|
case DrawText: {
|
|
|
|
getText(&text);
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t count = getInt();
|
2011-01-10 14:10:36 -08:00
|
|
|
float x = getFloat();
|
|
|
|
float y = getFloat();
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2011-12-01 20:08:50 -08:00
|
|
|
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);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
2012-02-24 16:48:34 -08:00
|
|
|
case DrawTextOnPath: {
|
|
|
|
getText(&text);
|
|
|
|
int32_t count = getInt();
|
|
|
|
SkPath* path = getPath();
|
|
|
|
float hOffset = getFloat();
|
|
|
|
float vOffset = getFloat();
|
|
|
|
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.drawTextOnPath(text.text(), text.length(), count, path,
|
|
|
|
hOffset, vOffset, paint);
|
|
|
|
}
|
|
|
|
break;
|
2012-01-17 17:39:26 -08:00
|
|
|
case DrawPosText: {
|
|
|
|
getText(&text);
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t count = getInt();
|
|
|
|
int32_t positionsCount = 0;
|
2012-01-17 17:39:26 -08:00
|
|
|
float* positions = getFloats(positionsCount);
|
2012-01-23 17:09:05 -08:00
|
|
|
SkPaint* paint = getPaint(renderer);
|
2012-01-17 17:39:26 -08:00
|
|
|
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;
|
2010-09-28 19:09:36 -07:00
|
|
|
case ResetShader: {
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2010-09-28 19:09:36 -07:00
|
|
|
renderer.resetShader();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SetupShader: {
|
2011-01-10 14:10:36 -08:00
|
|
|
SkiaShader* shader = getShader();
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
|
|
|
|
renderer.setupShader(shader);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ResetColorFilter: {
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2010-09-28 19:09:36 -07:00
|
|
|
renderer.resetColorFilter();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SetupColorFilter: {
|
2011-01-10 14:10:36 -08:00
|
|
|
SkiaColorFilter *colorFilter = getColorFilter();
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
|
|
|
|
renderer.setupColorFilter(colorFilter);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ResetShadow: {
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
2010-09-28 19:09:36 -07:00
|
|
|
renderer.resetShadow();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SetupShadow: {
|
2011-01-10 14:10:36 -08:00
|
|
|
float radius = getFloat();
|
|
|
|
float dx = getFloat();
|
|
|
|
float dy = getFloat();
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t color = getInt();
|
2011-01-10 14:10:36 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
|
2012-02-21 13:43:44 -08:00
|
|
|
radius, dx, dy, color);
|
2011-01-10 14:10:36 -08:00
|
|
|
renderer.setupShadow(radius, dx, dy, color);
|
|
|
|
}
|
|
|
|
break;
|
2012-01-23 17:09:05 -08:00
|
|
|
case ResetPaintFilter: {
|
|
|
|
DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
|
|
|
|
renderer.resetPaintFilter();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SetupPaintFilter: {
|
2012-02-16 19:24:51 -08:00
|
|
|
int32_t clearBits = getInt();
|
|
|
|
int32_t setBits = getInt();
|
2012-01-23 17:09:05 -08:00
|
|
|
DISPLAY_LIST_LOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op],
|
|
|
|
clearBits, setBits);
|
|
|
|
renderer.setupPaintFilter(clearBits, setBits);
|
|
|
|
}
|
|
|
|
break;
|
2011-01-10 14:10:36 -08:00
|
|
|
default:
|
|
|
|
DISPLAY_LIST_LOGD("Display List error: op not handled: %s%s",
|
2012-02-21 13:43:44 -08:00
|
|
|
(char*) indent, OP_NAMES[op]);
|
2011-01-10 14:10:36 -08:00
|
|
|
break;
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
}
|
2011-01-13 17:21:49 -08:00
|
|
|
|
2012-02-21 13:43:44 -08:00
|
|
|
if (USE_DISPLAY_LIST_PROPERTIES) {
|
|
|
|
DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
|
|
|
|
renderer.restoreToCount(restoreTo);
|
|
|
|
}
|
2012-01-30 17:41:55 -08:00
|
|
|
renderer.endMark();
|
|
|
|
|
2012-02-21 13:43:44 -08:00
|
|
|
DISPLAY_LIST_LOGD("%sDone (%p, %s), returning %d", (char*) indent + 2, this, mName.string(),
|
2012-03-26 16:45:05 -07:00
|
|
|
drawGlStatus);
|
|
|
|
return drawGlStatus;
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Base structure
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-02-21 13:43:44 -08:00
|
|
|
DisplayListRenderer::DisplayListRenderer() : mWriter(MIN_WRITER_SIZE),
|
2012-02-16 19:24:51 -08:00
|
|
|
mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false), mHasDrawOps(false) {
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayListRenderer::~DisplayListRenderer() {
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::reset() {
|
|
|
|
mWriter.reset();
|
2010-10-08 08:37:55 -07:00
|
|
|
|
|
|
|
Caches& caches = Caches::getInstance();
|
|
|
|
for (size_t i = 0; i < mBitmapResources.size(); i++) {
|
2011-06-22 16:14:36 -07:00
|
|
|
caches.resourceCache.decrementRefcount(mBitmapResources.itemAt(i));
|
2010-10-08 08:37:55 -07:00
|
|
|
}
|
|
|
|
mBitmapResources.clear();
|
2010-10-25 15:47:32 -07:00
|
|
|
|
2011-06-22 16:14:36 -07:00
|
|
|
for (size_t i = 0; i < mFilterResources.size(); i++) {
|
|
|
|
caches.resourceCache.decrementRefcount(mFilterResources.itemAt(i));
|
|
|
|
}
|
|
|
|
mFilterResources.clear();
|
|
|
|
|
2011-01-14 18:51:01 -08:00
|
|
|
for (size_t i = 0; i < mShaders.size(); i++) {
|
2011-06-22 16:14:36 -07:00
|
|
|
caches.resourceCache.decrementRefcount(mShaders.itemAt(i));
|
2011-01-14 18:51:01 -08:00
|
|
|
}
|
2011-01-14 15:31:00 -08:00
|
|
|
mShaders.clear();
|
|
|
|
mShaderMap.clear();
|
2011-01-14 18:51:01 -08:00
|
|
|
|
|
|
|
mPaints.clear();
|
|
|
|
mPaintMap.clear();
|
2011-06-22 16:14:36 -07:00
|
|
|
|
2011-02-03 15:06:05 -08:00
|
|
|
mPaths.clear();
|
|
|
|
mPathMap.clear();
|
2011-06-22 16:14:36 -07:00
|
|
|
|
2010-10-25 15:47:32 -07:00
|
|
|
mMatrices.clear();
|
2011-08-25 14:01:48 -07:00
|
|
|
|
|
|
|
mHasDrawOps = false;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Operations
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-07-21 17:02:54 -07:00
|
|
|
DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) {
|
|
|
|
if (!displayList) {
|
|
|
|
displayList = new DisplayList(*this);
|
2011-01-05 18:01:22 -08:00
|
|
|
} else {
|
2011-07-21 17:02:54 -07:00
|
|
|
displayList->initFromDisplayListRenderer(*this, true);
|
2011-01-05 18:01:22 -08:00
|
|
|
}
|
2011-08-25 14:01:48 -07:00
|
|
|
displayList->setRenderable(mHasDrawOps);
|
2011-07-21 17:02:54 -07:00
|
|
|
return displayList;
|
2011-01-05 18:01:22 -08:00
|
|
|
}
|
|
|
|
|
2010-09-28 19:09:36 -07:00
|
|
|
void DisplayListRenderer::setViewport(int width, int height) {
|
|
|
|
mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
|
|
|
|
|
|
|
|
mWidth = width;
|
|
|
|
mHeight = height;
|
|
|
|
}
|
|
|
|
|
2011-01-24 16:33:45 -08:00
|
|
|
void DisplayListRenderer::prepareDirty(float left, float top,
|
|
|
|
float right, float bottom, bool opaque) {
|
2010-09-28 19:09:36 -07:00
|
|
|
mSnapshot = new Snapshot(mFirstSnapshot,
|
|
|
|
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
|
|
|
|
mSaveCount = 1;
|
|
|
|
mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
|
2011-01-23 12:01:41 -08:00
|
|
|
mRestoreSaveCount = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::finish() {
|
|
|
|
insertRestoreToCount();
|
2012-02-16 19:24:51 -08:00
|
|
|
insertTranlate();
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
|
2011-01-10 14:10:36 -08:00
|
|
|
void DisplayListRenderer::interrupt() {
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:43:01 -08:00
|
|
|
void DisplayListRenderer::resume() {
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-03-26 16:45:05 -07:00
|
|
|
status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
|
2011-03-07 18:06:46 -08:00
|
|
|
// Ignore dirty during recording, it matters only when we replay
|
2011-01-10 14:10:36 -08:00
|
|
|
addOp(DisplayList::DrawGLFunction);
|
|
|
|
addInt((int) functor);
|
2012-03-26 16:45:05 -07:00
|
|
|
return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
|
2011-01-10 14:10:36 -08:00
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
int DisplayListRenderer::save(int flags) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::Save);
|
2010-09-26 18:40:37 -07:00
|
|
|
addInt(flags);
|
|
|
|
return OpenGLRenderer::save(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::restore() {
|
2011-08-25 14:01:48 -07:00
|
|
|
if (mRestoreSaveCount < 0) {
|
2012-02-16 19:24:51 -08:00
|
|
|
restoreToCount(getSaveCount() - 1);
|
|
|
|
return;
|
2011-08-25 14:01:48 -07:00
|
|
|
}
|
2012-02-16 19:24:51 -08:00
|
|
|
|
|
|
|
mRestoreSaveCount--;
|
|
|
|
insertTranlate();
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::restoreToCount(int saveCount) {
|
2011-01-23 12:01:41 -08:00
|
|
|
mRestoreSaveCount = saveCount;
|
2012-02-16 19:24:51 -08:00
|
|
|
insertTranlate();
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::restoreToCount(saveCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DisplayListRenderer::saveLayer(float left, float top, float right, float bottom,
|
2010-10-08 08:37:55 -07:00
|
|
|
SkPaint* p, int flags) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::SaveLayer);
|
2010-09-26 18:40:37 -07:00
|
|
|
addBounds(left, top, right, bottom);
|
|
|
|
addPaint(p);
|
|
|
|
addInt(flags);
|
2010-09-28 19:09:36 -07:00
|
|
|
return OpenGLRenderer::save(flags);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
int DisplayListRenderer::saveLayerAlpha(float left, float top, float right, float bottom,
|
|
|
|
int alpha, int flags) {
|
|
|
|
addOp(DisplayList::SaveLayerAlpha);
|
|
|
|
addBounds(left, top, right, bottom);
|
|
|
|
addInt(alpha);
|
|
|
|
addInt(flags);
|
|
|
|
return OpenGLRenderer::save(flags);
|
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::translate(float dx, float dy) {
|
2012-02-16 19:24:51 -08:00
|
|
|
mHasTranslate = true;
|
|
|
|
mTranslateX += dx;
|
|
|
|
mTranslateY += dy;
|
|
|
|
insertRestoreToCount();
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::translate(dx, dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::rotate(float degrees) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::Rotate);
|
2010-09-26 18:40:37 -07:00
|
|
|
addFloat(degrees);
|
|
|
|
OpenGLRenderer::rotate(degrees);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::scale(float sx, float sy) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::Scale);
|
2010-09-26 18:40:37 -07:00
|
|
|
addPoint(sx, sy);
|
|
|
|
OpenGLRenderer::scale(sx, sy);
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:19:19 -08:00
|
|
|
void DisplayListRenderer::skew(float sx, float sy) {
|
|
|
|
addOp(DisplayList::Skew);
|
|
|
|
addPoint(sx, sy);
|
|
|
|
OpenGLRenderer::skew(sx, sy);
|
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::setMatrix(SkMatrix* matrix) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::SetMatrix);
|
2010-09-26 18:40:37 -07:00
|
|
|
addMatrix(matrix);
|
|
|
|
OpenGLRenderer::setMatrix(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::concatMatrix(SkMatrix* matrix) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::ConcatMatrix);
|
2010-09-26 18:40:37 -07:00
|
|
|
addMatrix(matrix);
|
|
|
|
OpenGLRenderer::concatMatrix(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayListRenderer::clipRect(float left, float top, float right, float bottom,
|
|
|
|
SkRegion::Op op) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::ClipRect);
|
2010-09-26 18:40:37 -07:00
|
|
|
addBounds(left, top, right, bottom);
|
|
|
|
addInt(op);
|
|
|
|
return OpenGLRenderer::clipRect(left, top, right, bottom, op);
|
|
|
|
}
|
|
|
|
|
2012-03-26 16:45:05 -07:00
|
|
|
status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList,
|
2012-02-16 19:24:51 -08:00
|
|
|
uint32_t width, uint32_t height, Rect& dirty, int32_t flags, uint32_t level) {
|
2011-03-07 18:06:46 -08:00
|
|
|
// dirty is an out parameter and should not be recorded,
|
|
|
|
// it matters only when replaying the display list
|
2012-03-26 14:37:51 -07:00
|
|
|
|
|
|
|
addOp(DisplayList::DrawDisplayList);
|
2010-11-08 12:08:41 -08:00
|
|
|
addDisplayList(displayList);
|
2011-03-14 18:05:08 -07:00
|
|
|
addSize(width, height);
|
2012-02-16 19:24:51 -08:00
|
|
|
addInt(flags);
|
2012-03-26 16:45:05 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-11-08 12:08:41 -08:00
|
|
|
}
|
|
|
|
|
2011-01-13 12:13:20 -08:00
|
|
|
void DisplayListRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
|
2011-01-11 14:29:25 -08:00
|
|
|
addOp(DisplayList::DrawLayer);
|
2011-01-13 12:13:20 -08:00
|
|
|
addInt((int) layer);
|
|
|
|
addPoint(x, y);
|
2011-01-11 14:29:25 -08:00
|
|
|
addPaint(paint);
|
|
|
|
}
|
|
|
|
|
2012-02-16 19:24:51 -08:00
|
|
|
void DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
|
|
|
|
const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height());
|
|
|
|
uint32_t* location = addOp(DisplayList::DrawBitmap, reject);
|
2010-09-26 18:40:37 -07:00
|
|
|
addBitmap(bitmap);
|
|
|
|
addPoint(left, top);
|
|
|
|
addPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
addSkip(location);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-02-16 19:24:51 -08:00
|
|
|
void DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) {
|
|
|
|
Rect r(0.0f, 0.0f, bitmap->width(), bitmap->height());
|
|
|
|
const mat4 transform(*matrix);
|
|
|
|
transform.mapRect(r);
|
|
|
|
|
|
|
|
const bool reject = quickReject(r.left, r.top, r.right, r.bottom);
|
|
|
|
uint32_t* location = addOp(DisplayList::DrawBitmapMatrix, reject);
|
2010-09-26 18:40:37 -07:00
|
|
|
addBitmap(bitmap);
|
|
|
|
addMatrix(matrix);
|
|
|
|
addPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
addSkip(location);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
|
|
|
|
float srcRight, float srcBottom, float dstLeft, float dstTop,
|
2010-10-08 08:37:55 -07:00
|
|
|
float dstRight, float dstBottom, SkPaint* paint) {
|
2012-02-16 19:24:51 -08:00
|
|
|
const bool reject = quickReject(dstLeft, dstTop, dstRight, dstBottom);
|
|
|
|
uint32_t* location = addOp(DisplayList::DrawBitmapRect, reject);
|
2010-09-26 18:40:37 -07:00
|
|
|
addBitmap(bitmap);
|
|
|
|
addBounds(srcLeft, srcTop, srcRight, srcBottom);
|
|
|
|
addBounds(dstLeft, dstTop, dstRight, dstBottom);
|
|
|
|
addPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
addSkip(location);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2011-01-20 19:09:30 -08:00
|
|
|
void DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
|
|
|
|
float* vertices, int* colors, SkPaint* paint) {
|
|
|
|
addOp(DisplayList::DrawBitmapMesh);
|
|
|
|
addBitmap(bitmap);
|
|
|
|
addInt(meshWidth);
|
|
|
|
addInt(meshHeight);
|
|
|
|
addFloats(vertices, (meshWidth + 1) * (meshHeight + 1) * 2);
|
|
|
|
if (colors) {
|
|
|
|
addInt(1);
|
|
|
|
addInts(colors, (meshWidth + 1) * (meshHeight + 1));
|
|
|
|
} else {
|
|
|
|
addInt(0);
|
|
|
|
}
|
|
|
|
addPaint(paint);
|
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
|
2010-10-12 15:59:26 -07:00
|
|
|
const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
|
2010-10-08 08:37:55 -07:00
|
|
|
float left, float top, float right, float bottom, SkPaint* paint) {
|
2012-02-16 19:24:51 -08:00
|
|
|
const bool reject = quickReject(left, top, right, bottom);
|
|
|
|
uint32_t* location = addOp(DisplayList::DrawPatch, reject);
|
2010-09-26 18:40:37 -07:00
|
|
|
addBitmap(bitmap);
|
|
|
|
addInts(xDivs, width);
|
|
|
|
addInts(yDivs, height);
|
2010-10-12 15:59:26 -07:00
|
|
|
addUInts(colors, numColors);
|
2010-09-26 18:40:37 -07:00
|
|
|
addBounds(left, top, right, bottom);
|
|
|
|
addPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
addSkip(location);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::DrawColor);
|
2010-09-26 18:40:37 -07:00
|
|
|
addInt(color);
|
|
|
|
addInt(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
|
2010-10-08 08:37:55 -07:00
|
|
|
SkPaint* paint) {
|
2012-02-16 19:24:51 -08:00
|
|
|
const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
|
|
|
|
quickReject(left, top, right, bottom);
|
|
|
|
uint32_t* location = addOp(DisplayList::DrawRect, reject);
|
2010-09-26 18:40:37 -07:00
|
|
|
addBounds(left, top, right, bottom);
|
|
|
|
addPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
addSkip(location);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2011-01-19 21:54:02 -08:00
|
|
|
void DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
|
2012-02-21 13:43:44 -08:00
|
|
|
float rx, float ry, SkPaint* paint) {
|
2012-02-16 19:24:51 -08:00
|
|
|
const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
|
|
|
|
quickReject(left, top, right, bottom);
|
|
|
|
uint32_t* location = addOp(DisplayList::DrawRoundRect, reject);
|
2011-01-19 21:54:02 -08:00
|
|
|
addBounds(left, top, right, bottom);
|
|
|
|
addPoint(rx, ry);
|
|
|
|
addPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
addSkip(location);
|
2011-01-19 21:54:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
|
|
|
|
addOp(DisplayList::DrawCircle);
|
|
|
|
addPoint(x, y);
|
|
|
|
addFloat(radius);
|
|
|
|
addPaint(paint);
|
|
|
|
}
|
|
|
|
|
2011-01-23 14:18:41 -08:00
|
|
|
void DisplayListRenderer::drawOval(float left, float top, float right, float bottom,
|
|
|
|
SkPaint* paint) {
|
|
|
|
addOp(DisplayList::DrawOval);
|
|
|
|
addBounds(left, top, right, bottom);
|
|
|
|
addPaint(paint);
|
|
|
|
}
|
|
|
|
|
2011-01-23 16:15:02 -08:00
|
|
|
void DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
|
|
|
|
float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
|
2011-01-24 21:53:42 -08:00
|
|
|
addOp(DisplayList::DrawArc);
|
2011-01-23 16:15:02 -08:00
|
|
|
addBounds(left, top, right, bottom);
|
|
|
|
addPoint(startAngle, sweepAngle);
|
|
|
|
addInt(useCenter ? 1 : 0);
|
|
|
|
addPaint(paint);
|
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
|
2012-02-16 19:24:51 -08:00
|
|
|
float left, top, offset;
|
|
|
|
uint32_t width, height;
|
|
|
|
computePathBounds(path, paint, left, top, offset, width, height);
|
|
|
|
|
|
|
|
const bool reject = quickReject(left - offset, top - offset, width, height);
|
|
|
|
uint32_t* location = addOp(DisplayList::DrawPath, reject);
|
2010-09-26 18:40:37 -07:00
|
|
|
addPath(path);
|
|
|
|
addPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
addSkip(location);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2010-10-08 08:37:55 -07:00
|
|
|
void DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::DrawLines);
|
2010-09-26 18:40:37 -07:00
|
|
|
addFloats(points, count);
|
|
|
|
addPaint(paint);
|
2011-03-21 13:11:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
|
|
|
|
addOp(DisplayList::DrawPoints);
|
|
|
|
addFloats(points, count);
|
|
|
|
addPaint(paint);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
|
2011-12-01 20:08:50 -08:00
|
|
|
float x, float y, SkPaint* paint, float length) {
|
2012-02-16 19:24:51 -08:00
|
|
|
if (!text || count <= 0) return;
|
|
|
|
|
2011-12-05 11:53:26 -08:00
|
|
|
// 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.
|
2012-01-05 13:30:54 -08:00
|
|
|
// Beware: this needs Glyph encoding (already done on the Paint constructor)
|
2011-12-05 11:53:26 -08:00
|
|
|
paint->setAntiAlias(true);
|
2012-02-16 19:24:51 -08:00
|
|
|
if (length < 0.0f) length = paint->measureText(text, bytesCount);
|
|
|
|
|
|
|
|
bool reject = false;
|
|
|
|
if (CC_LIKELY(paint->getTextAlign() == SkPaint::kLeft_Align)) {
|
|
|
|
SkPaint::FontMetrics metrics;
|
|
|
|
paint->getFontMetrics(&metrics, 0.0f);
|
|
|
|
reject = quickReject(x, y + metrics.fTop, x + length, y + metrics.fBottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t* location = addOp(DisplayList::DrawText, reject);
|
|
|
|
addText(text, bytesCount);
|
|
|
|
addInt(count);
|
|
|
|
addPoint(x, y);
|
2010-09-26 18:40:37 -07:00
|
|
|
addPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
addFloat(length);
|
|
|
|
addSkip(location);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-02-24 16:48:34 -08:00
|
|
|
void DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
|
|
|
|
SkPath* path, float hOffset, float vOffset, SkPaint* paint) {
|
|
|
|
if (!text || count <= 0) return;
|
|
|
|
addOp(DisplayList::DrawTextOnPath);
|
|
|
|
addText(text, bytesCount);
|
|
|
|
addInt(count);
|
|
|
|
addPath(path);
|
|
|
|
addFloat(hOffset);
|
|
|
|
addFloat(vOffset);
|
|
|
|
paint->setAntiAlias(true);
|
|
|
|
addPaint(paint);
|
|
|
|
}
|
|
|
|
|
2012-01-17 17:39:26 -08:00
|
|
|
void DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
|
|
|
|
const float* positions, SkPaint* paint) {
|
2012-02-16 19:24:51 -08:00
|
|
|
if (!text || count <= 0) return;
|
2012-01-17 17:39:26 -08:00
|
|
|
addOp(DisplayList::DrawPosText);
|
|
|
|
addText(text, bytesCount);
|
|
|
|
addInt(count);
|
|
|
|
addFloats(positions, count * 2);
|
|
|
|
paint->setAntiAlias(true);
|
|
|
|
addPaint(paint);
|
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::resetShader() {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::ResetShader);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupShader(SkiaShader* shader) {
|
2010-10-08 08:37:55 -07:00
|
|
|
addOp(DisplayList::SetupShader);
|
|
|
|
addShader(shader);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::resetColorFilter() {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::ResetColorFilter);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) {
|
2010-10-22 16:17:12 -07:00
|
|
|
addOp(DisplayList::SetupColorFilter);
|
|
|
|
addColorFilter(filter);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::resetShadow() {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::ResetShadow);
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) {
|
2010-09-28 19:09:36 -07:00
|
|
|
addOp(DisplayList::SetupShadow);
|
2010-09-26 18:40:37 -07:00
|
|
|
addFloat(radius);
|
|
|
|
addPoint(dx, dy);
|
|
|
|
addInt(color);
|
|
|
|
}
|
|
|
|
|
2012-01-23 17:09:05 -08:00
|
|
|
void DisplayListRenderer::resetPaintFilter() {
|
|
|
|
addOp(DisplayList::ResetPaintFilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupPaintFilter(int clearBits, int setBits) {
|
|
|
|
addOp(DisplayList::SetupPaintFilter);
|
|
|
|
addInt(clearBits);
|
|
|
|
addInt(setBits);
|
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|