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"
|
2012-11-26 18:30:17 -08:00
|
|
|
#include "DisplayListOp.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-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");
|
2012-11-26 18:30:17 -08:00
|
|
|
logBuffer.outputCommands(file);
|
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-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() {
|
2012-11-26 18:30:17 -08:00
|
|
|
mDisplayListData = NULL;
|
2012-04-20 09:54:27 -07:00
|
|
|
delete mTransformMatrix;
|
|
|
|
delete mTransformCamera;
|
|
|
|
delete mTransformMatrix3D;
|
|
|
|
delete mStaticMatrix;
|
|
|
|
delete mAnimationMatrix;
|
2012-09-07 11:58:36 -07:00
|
|
|
|
2012-04-20 09:54:27 -07:00
|
|
|
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();
|
2012-09-27 17:55:46 -07:00
|
|
|
caches.unregisterFunctors(mFunctorCount);
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.lock();
|
2011-01-05 18:01:22 -08:00
|
|
|
|
|
|
|
for (size_t i = 0; i < mBitmapResources.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
|
2011-01-05 18:01:22 -08:00
|
|
|
}
|
|
|
|
|
2012-05-15 11:10:01 -07:00
|
|
|
for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
|
|
|
|
SkBitmap* bitmap = mOwnedBitmapResources.itemAt(i);
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.decrementRefcountLocked(bitmap);
|
|
|
|
caches.resourceCache.destructorLocked(bitmap);
|
2012-05-15 11:10:01 -07:00
|
|
|
}
|
|
|
|
|
2011-06-22 16:14:36 -07:00
|
|
|
for (size_t i = 0; i < mFilterResources.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
|
2011-06-22 16:14:36 -07:00
|
|
|
}
|
|
|
|
|
2011-01-14 15:31:00 -08:00
|
|
|
for (size_t i = 0; i < mShaders.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
|
|
|
|
caches.resourceCache.destructorLocked(mShaders.itemAt(i));
|
2011-01-05 18:01:22 -08:00
|
|
|
}
|
2012-09-07 11:58:36 -07:00
|
|
|
|
|
|
|
for (size_t i = 0; i < mSourcePaths.size(); i++) {
|
|
|
|
caches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
|
|
|
|
}
|
|
|
|
|
Fix occasional crash bug with layers
Launcher occasionally crashes with a stack trace indicating that the memory
of a Layer object is corrupt. It is possible for us to delete a Layer
structure and then, briefly, use it to draw a DisplayList again before
that DisplayList gets recreated (without the layer that got deleted).
When this happens, if the memory got corrupted, it's possible to crash.
The fix is to add Layer to the other objects which we currently refcount
(bitmaps, shaders, etc.). Then instead of deleting a Layer, we decrement the
refcount. We increment when creating it, then increment it again when it's
referenced from a DisplayList. Then we decrement the refcount instead of
deleting it, and decrement when we clear a DisplayList that refers to it.
Then when the refcount reaches 0, we delete it.
Issue #6994632 Native crash in launcher when trying to launch all apps screen
Change-Id: I0627be8d49bb2f9ba8d158a84b764bb4e7df934c
2012-09-14 15:31:25 -07:00
|
|
|
for (size_t i = 0; i < mLayers.size(); i++) {
|
|
|
|
caches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
|
|
|
|
}
|
|
|
|
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.unlock();
|
2011-01-05 18:01:22 -08:00
|
|
|
|
|
|
|
for (size_t i = 0; i < mPaints.size(); i++) {
|
|
|
|
delete mPaints.itemAt(i);
|
|
|
|
}
|
|
|
|
|
2012-12-03 12:34:51 -08:00
|
|
|
for (size_t i = 0; i < mRegions.size(); i++) {
|
|
|
|
delete mRegions.itemAt(i);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2012-05-02 18:50:34 -07:00
|
|
|
|
2011-01-05 18:01:22 -08:00
|
|
|
for (size_t i = 0; i < mMatrices.size(); i++) {
|
|
|
|
delete mMatrices.itemAt(i);
|
|
|
|
}
|
2012-09-07 11:58:36 -07:00
|
|
|
|
|
|
|
mBitmapResources.clear();
|
|
|
|
mOwnedBitmapResources.clear();
|
|
|
|
mFilterResources.clear();
|
|
|
|
mShaders.clear();
|
|
|
|
mSourcePaths.clear();
|
|
|
|
mPaints.clear();
|
2012-12-03 12:34:51 -08:00
|
|
|
mRegions.clear();
|
2012-09-07 11:58:36 -07:00
|
|
|
mPaths.clear();
|
2011-01-05 18:01:22 -08:00
|
|
|
mMatrices.clear();
|
Fix occasional crash bug with layers
Launcher occasionally crashes with a stack trace indicating that the memory
of a Layer object is corrupt. It is possible for us to delete a Layer
structure and then, briefly, use it to draw a DisplayList again before
that DisplayList gets recreated (without the layer that got deleted).
When this happens, if the memory got corrupted, it's possible to crash.
The fix is to add Layer to the other objects which we currently refcount
(bitmaps, shaders, etc.). Then instead of deleting a Layer, we decrement the
refcount. We increment when creating it, then increment it again when it's
referenced from a DisplayList. Then we decrement the refcount instead of
deleting it, and decrement when we clear a DisplayList that refers to it.
Then when the refcount reaches 0, we delete it.
Issue #6994632 Native crash in launcher when trying to launch all apps screen
Change-Id: I0627be8d49bb2f9ba8d158a84b764bb4e7df934c
2012-09-14 15:31:25 -07:00
|
|
|
mLayers.clear();
|
2011-01-05 18:01:22 -08:00
|
|
|
}
|
|
|
|
|
Fix texture corruption
When memory gets low on a device, activities flush everything they can.
Hardware-accelerated activites, such as Launcher, flush GL resources and destroy
the GL context. However, some resources were still hanging around, due to deferred
destruction policies (we don't delete layers until the DisplayLists they are in
are finalized, to ensure we don't deref deleted objects). This meant that we were
referring to obsolete GL data in these objects. in particular, it meant that we might
come around later, after a new GL context was created, and delete a texture object
that was incorrect. We use the layer's "texture id" to refer to the texture underlying the
layer. But if there's a new GL context, then this texture ID is no longer valid, and
we may be deleting the texture that a different object (layer, icon, whatever) is referring
to, because the driver may return that same ID under the new GL context.
The fix is to more aggressively delete things that we know will not be used again
when the GL context is destroyed. In particular, we delete all resources being used
by all DisplayLists at GL context destruction time.
Issue #7195815 Textures corruption on all devices, in many apps
Change-Id: I52d2d208173690dbb794a83402d38f14ea4c6c22
2012-09-30 12:14:13 -07:00
|
|
|
void DisplayList::reset() {
|
|
|
|
clearResources();
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
2011-02-03 16:32:46 -08:00
|
|
|
void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
|
|
|
|
if (reusing) {
|
|
|
|
// re-using display list - clear out previous allocations
|
|
|
|
clearResources();
|
|
|
|
}
|
2012-09-27 19:01:55 -07:00
|
|
|
|
|
|
|
init();
|
2011-02-03 16:32:46 -08:00
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
mDisplayListData = recorder.getDisplayListData();
|
|
|
|
mSize = mDisplayListData->allocator.usedSize();
|
|
|
|
|
|
|
|
if (mSize == 0) {
|
2012-09-27 19:01:55 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-27 17:55:46 -07:00
|
|
|
mFunctorCount = recorder.getFunctorCount();
|
|
|
|
|
2010-10-08 08:37:55 -07:00
|
|
|
Caches& caches = Caches::getInstance();
|
2012-09-27 17:55:46 -07:00
|
|
|
caches.registerFunctors(mFunctorCount);
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.lock();
|
2010-09-28 19:09:36 -07:00
|
|
|
|
2012-05-15 11:10:01 -07:00
|
|
|
const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources();
|
2010-10-08 08:37:55 -07:00
|
|
|
for (size_t i = 0; i < bitmapResources.size(); i++) {
|
|
|
|
SkBitmap* resource = bitmapResources.itemAt(i);
|
|
|
|
mBitmapResources.add(resource);
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.incrementRefcountLocked(resource);
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
2010-10-25 15:47:32 -07:00
|
|
|
|
2012-05-15 11:10:01 -07:00
|
|
|
const Vector<SkBitmap*> &ownedBitmapResources = recorder.getOwnedBitmapResources();
|
|
|
|
for (size_t i = 0; i < ownedBitmapResources.size(); i++) {
|
|
|
|
SkBitmap* resource = ownedBitmapResources.itemAt(i);
|
|
|
|
mOwnedBitmapResources.add(resource);
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.incrementRefcountLocked(resource);
|
2012-05-15 11:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const Vector<SkiaColorFilter*>& filterResources = recorder.getFilterResources();
|
2011-06-22 16:14:36 -07:00
|
|
|
for (size_t i = 0; i < filterResources.size(); i++) {
|
|
|
|
SkiaColorFilter* resource = filterResources.itemAt(i);
|
|
|
|
mFilterResources.add(resource);
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.incrementRefcountLocked(resource);
|
2011-06-22 16:14:36 -07:00
|
|
|
}
|
|
|
|
|
2012-05-15 11:10:01 -07:00
|
|
|
const Vector<SkiaShader*>& shaders = recorder.getShaders();
|
2011-01-14 15:31:00 -08:00
|
|
|
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);
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.incrementRefcountLocked(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SortedVector<SkPath*>& sourcePaths = recorder.getSourcePaths();
|
|
|
|
for (size_t i = 0; i < sourcePaths.size(); i++) {
|
|
|
|
mSourcePaths.add(sourcePaths.itemAt(i));
|
|
|
|
caches.resourceCache.incrementRefcountLocked(sourcePaths.itemAt(i));
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
|
Fix occasional crash bug with layers
Launcher occasionally crashes with a stack trace indicating that the memory
of a Layer object is corrupt. It is possible for us to delete a Layer
structure and then, briefly, use it to draw a DisplayList again before
that DisplayList gets recreated (without the layer that got deleted).
When this happens, if the memory got corrupted, it's possible to crash.
The fix is to add Layer to the other objects which we currently refcount
(bitmaps, shaders, etc.). Then instead of deleting a Layer, we decrement the
refcount. We increment when creating it, then increment it again when it's
referenced from a DisplayList. Then we decrement the refcount instead of
deleting it, and decrement when we clear a DisplayList that refers to it.
Then when the refcount reaches 0, we delete it.
Issue #6994632 Native crash in launcher when trying to launch all apps screen
Change-Id: I0627be8d49bb2f9ba8d158a84b764bb4e7df934c
2012-09-14 15:31:25 -07:00
|
|
|
const Vector<Layer*>& layers = recorder.getLayers();
|
|
|
|
for (size_t i = 0; i < layers.size(); i++) {
|
|
|
|
mLayers.add(layers.itemAt(i));
|
|
|
|
caches.resourceCache.incrementRefcountLocked(layers.itemAt(i));
|
|
|
|
}
|
|
|
|
|
2012-09-07 11:58:36 -07:00
|
|
|
caches.resourceCache.unlock();
|
|
|
|
|
2012-12-03 12:34:51 -08:00
|
|
|
mPaints.appendVector(recorder.getPaints());
|
|
|
|
mRegions.appendVector(recorder.getRegions());
|
|
|
|
mPaths.appendVector(recorder.getPaths());
|
|
|
|
mMatrices.appendVector(recorder.getMatrices());
|
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;
|
2012-09-27 19:01:55 -07:00
|
|
|
mFunctorCount = 0;
|
Fix texture corruption
When memory gets low on a device, activities flush everything they can.
Hardware-accelerated activites, such as Launcher, flush GL resources and destroy
the GL context. However, some resources were still hanging around, due to deferred
destruction policies (we don't delete layers until the DisplayLists they are in
are finalized, to ensure we don't deref deleted objects). This meant that we were
referring to obsolete GL data in these objects. in particular, it meant that we might
come around later, after a new GL context was created, and delete a texture object
that was incorrect. We use the layer's "texture id" to refer to the texture underlying the
layer. But if there's a new GL context, then this texture ID is no longer valid, and
we may be deleting the texture that a different object (layer, icon, whatever) is referring
to, because the driver may return that same ID under the new GL context.
The fix is to more aggressively delete things that we know will not be used again
when the GL context is destroyed. In particular, we delete all resources being used
by all DisplayLists at GL context destruction time.
Issue #7195815 Textures corruption on all devices, in many apps
Change-Id: I52d2d208173690dbb794a83402d38f14ea4c6c22
2012-09-30 12:14:13 -07:00
|
|
|
mLeft = 0;
|
|
|
|
mTop = 0;
|
|
|
|
mRight = 0;
|
|
|
|
mBottom = 0;
|
|
|
|
mClipChildren = true;
|
|
|
|
mAlpha = 1;
|
|
|
|
mMultipliedAlpha = 255;
|
|
|
|
mHasOverlappingRendering = true;
|
|
|
|
mTranslationX = 0;
|
|
|
|
mTranslationY = 0;
|
|
|
|
mRotation = 0;
|
|
|
|
mRotationX = 0;
|
|
|
|
mRotationY= 0;
|
|
|
|
mScaleX = 1;
|
|
|
|
mScaleY = 1;
|
|
|
|
mPivotX = 0;
|
|
|
|
mPivotY = 0;
|
|
|
|
mCameraDistance = 0;
|
|
|
|
mMatrixDirty = false;
|
|
|
|
mMatrixFlags = 0;
|
|
|
|
mPrevWidth = -1;
|
|
|
|
mPrevHeight = -1;
|
|
|
|
mWidth = 0;
|
|
|
|
mHeight = 0;
|
|
|
|
mPivotExplicitlySet = false;
|
|
|
|
mCaching = false;
|
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.
|
|
|
|
*/
|
2012-11-26 18:30:17 -08:00
|
|
|
void DisplayList::output(uint32_t level) {
|
|
|
|
ALOGD("%*sStart display list (%p, %s, render=%d)", level * 2, "", this,
|
2012-05-22 14:07:07 -07:00
|
|
|
mName.string(), isRenderable());
|
2011-04-22 16:18:45 -07:00
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*s%s %d", level * 4, "", "Save", SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
|
|
|
|
outputViewProperties(level);
|
|
|
|
int flags = DisplayListOp::kOpLogFlag_Recurse;
|
|
|
|
for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) {
|
|
|
|
mDisplayListData->displayListOps[i]->output(level, flags);
|
2011-04-22 16:18:45 -07:00
|
|
|
}
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*sDone (%p, %s)", level * 2, "", this, mName.string());
|
2012-02-21 13:43:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
void DisplayList::outputViewProperties(uint32_t level) {
|
2012-04-20 09:54:27 -07:00
|
|
|
updateMatrix();
|
|
|
|
if (mLeft != 0 || mTop != 0) {
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*sTranslate (left, top) %d, %d", level * 2, "", mLeft, mTop);
|
2012-04-20 09:54:27 -07:00
|
|
|
}
|
|
|
|
if (mStaticMatrix) {
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*sConcatMatrix (static) %p: " MATRIX_STRING,
|
|
|
|
level * 2, "", mStaticMatrix, MATRIX_ARGS(mStaticMatrix));
|
2012-04-20 09:54:27 -07:00
|
|
|
}
|
|
|
|
if (mAnimationMatrix) {
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*sConcatMatrix (animation) %p: " MATRIX_STRING,
|
|
|
|
level * 2, "", mAnimationMatrix, MATRIX_ARGS(mStaticMatrix));
|
2012-04-20 09:54:27 -07:00
|
|
|
}
|
|
|
|
if (mMatrixFlags != 0) {
|
|
|
|
if (mMatrixFlags == TRANSLATION) {
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*sTranslate %f, %f", level * 2, "", mTranslationX, mTranslationY);
|
2012-04-20 09:54:27 -07:00
|
|
|
} else {
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*sConcatMatrix %p: " MATRIX_STRING,
|
|
|
|
level * 2, "", mTransformMatrix, MATRIX_ARGS(mTransformMatrix));
|
2012-03-13 11:03:25 -07:00
|
|
|
}
|
2012-04-20 09:54:27 -07:00
|
|
|
}
|
|
|
|
if (mAlpha < 1 && !mCaching) {
|
2012-10-23 12:54:51 -07:00
|
|
|
if (!mHasOverlappingRendering) {
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*sSetAlpha %.2f", level * 2, "", mAlpha);
|
2012-10-23 12:54:51 -07:00
|
|
|
} else {
|
|
|
|
int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
|
|
|
|
if (mClipChildren) {
|
|
|
|
flags |= SkCanvas::kClipToLayer_SaveFlag;
|
|
|
|
}
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*sSaveLayerAlpha %.2f, %.2f, %.2f, %.2f, %d, 0x%x", level * 2, "",
|
2012-10-23 12:54:51 -07:00
|
|
|
(float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
|
|
|
|
mMultipliedAlpha, flags);
|
2012-02-21 13:43:44 -08:00
|
|
|
}
|
2012-04-20 09:54:27 -07:00
|
|
|
}
|
|
|
|
if (mClipChildren) {
|
2012-11-26 18:30:17 -08:00
|
|
|
ALOGD("%*sClipRect %.2f, %.2f, %.2f, %.2f", level * 2, "", 0.0f, 0.0f,
|
2012-04-20 09:54:27 -07:00
|
|
|
(float) mRight - mLeft, (float) mBottom - mTop);
|
2012-02-21 13:43:44 -08:00
|
|
|
}
|
|
|
|
}
|
2011-04-22 16:18:45 -07:00
|
|
|
|
2012-04-20 09:54:27 -07:00
|
|
|
void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t level) {
|
2012-11-26 18:30:17 -08:00
|
|
|
#if DEBUG_DISPLAYLIST
|
|
|
|
outputViewProperties(level);
|
2012-02-21 13:43:44 -08:00
|
|
|
#endif
|
2012-04-20 09:54:27 -07:00
|
|
|
updateMatrix();
|
|
|
|
if (mLeft != 0 || mTop != 0) {
|
|
|
|
renderer.translate(mLeft, mTop);
|
|
|
|
}
|
|
|
|
if (mStaticMatrix) {
|
|
|
|
renderer.concatMatrix(mStaticMatrix);
|
|
|
|
} else if (mAnimationMatrix) {
|
|
|
|
renderer.concatMatrix(mAnimationMatrix);
|
|
|
|
}
|
|
|
|
if (mMatrixFlags != 0) {
|
|
|
|
if (mMatrixFlags == TRANSLATION) {
|
|
|
|
renderer.translate(mTranslationX, mTranslationY);
|
|
|
|
} else {
|
|
|
|
renderer.concatMatrix(mTransformMatrix);
|
2012-02-21 13:43:44 -08:00
|
|
|
}
|
2012-04-20 09:54:27 -07:00
|
|
|
}
|
|
|
|
if (mAlpha < 1 && !mCaching) {
|
|
|
|
if (!mHasOverlappingRendering) {
|
|
|
|
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;
|
2012-03-13 11:03:25 -07:00
|
|
|
}
|
2012-04-20 09:54:27 -07:00
|
|
|
renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
|
|
|
|
mMultipliedAlpha, flags);
|
2012-03-13 11:03:25 -07:00
|
|
|
}
|
2012-04-20 09:54:27 -07:00
|
|
|
}
|
|
|
|
if (mClipChildren) {
|
|
|
|
renderer.clipRect(0, 0, mRight - mLeft, mBottom - mTop,
|
|
|
|
SkRegion::kIntersect_Op);
|
2012-02-21 13:43:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-20 09:54:27 -07:00
|
|
|
status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level) {
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t drawGlStatus = DrawGlInfo::kStatusDone;
|
2010-09-28 19:09:36 -07:00
|
|
|
|
2011-01-13 17:21:49 -08:00
|
|
|
#if DEBUG_DISPLAY_LIST
|
2012-04-12 15:19:04 -07:00
|
|
|
Rect* clipRect = renderer.getClipRect();
|
2012-11-26 18:30:17 -08:00
|
|
|
DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), clipRect: %.0f, %.f, %.0f, %.0f",
|
|
|
|
(level+1)*2, "", this, mName.string(), clipRect->left, clipRect->top,
|
2012-04-12 15:19:04 -07:00
|
|
|
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-07-17 17:32:48 -07:00
|
|
|
|
2012-04-20 09:54:27 -07:00
|
|
|
int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
|
2012-11-26 18:30:17 -08:00
|
|
|
DISPLAY_LIST_LOGD("%*sSave %d %d", level * 2, "",
|
2012-04-20 09:54:27 -07:00
|
|
|
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
|
|
|
|
setViewProperties(renderer, level);
|
2012-07-17 17:32:48 -07:00
|
|
|
|
|
|
|
if (renderer.quickRejectNoScissor(0, 0, mWidth, mHeight)) {
|
2012-11-26 18:30:17 -08:00
|
|
|
DISPLAY_LIST_LOGD("%*sRestoreToCount %d", level * 2, "", restoreTo);
|
2012-03-26 14:37:51 -07:00
|
|
|
renderer.restoreToCount(restoreTo);
|
|
|
|
renderer.endMark();
|
2012-05-31 15:21:51 -07:00
|
|
|
return drawGlStatus;
|
2012-03-26 14:37:51 -07:00
|
|
|
}
|
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;
|
2012-11-26 18:30:17 -08:00
|
|
|
for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) {
|
|
|
|
DisplayListOp *op = mDisplayListData->displayListOps[i];
|
2012-07-17 17:32:48 -07:00
|
|
|
#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
|
2012-11-26 18:30:17 -08:00
|
|
|
Caches::getInstance().eventMark(strlen(op->name()), op->name());
|
2012-07-17 17:32:48 -07:00
|
|
|
#endif
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
drawGlStatus |= op->replay(renderer, dirty, flags,
|
|
|
|
saveCount, level, mCaching, mMultipliedAlpha);
|
|
|
|
logBuffer.writeCommand(level, op->name());
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
2011-01-13 17:21:49 -08:00
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
DISPLAY_LIST_LOGD("%*sRestoreToCount %d", level * 2, "", restoreTo);
|
2012-04-20 09:54:27 -07:00
|
|
|
renderer.restoreToCount(restoreTo);
|
2012-01-30 17:41:55 -08:00
|
|
|
renderer.endMark();
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
DISPLAY_LIST_LOGD("%*sDone (%p, %s), returning %d", (level + 1) * 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-09-07 11:58:36 -07:00
|
|
|
DisplayListRenderer::DisplayListRenderer():
|
2012-11-26 18:30:17 -08:00
|
|
|
mCaches(Caches::getInstance()), mDisplayListData(new DisplayListData),
|
2012-09-27 17:55:46 -07:00
|
|
|
mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false),
|
|
|
|
mHasDrawOps(false), mFunctorCount(0) {
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayListRenderer::~DisplayListRenderer() {
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::reset() {
|
2012-11-26 18:30:17 -08:00
|
|
|
mDisplayListData = new DisplayListData();
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.lock();
|
|
|
|
|
2010-10-08 08:37:55 -07:00
|
|
|
for (size_t i = 0; i < mBitmapResources.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
|
2010-10-08 08:37:55 -07:00
|
|
|
}
|
2010-10-25 15:47:32 -07:00
|
|
|
|
2012-05-15 11:10:01 -07:00
|
|
|
for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mOwnedBitmapResources.itemAt(i));
|
2012-05-15 11:10:01 -07:00
|
|
|
}
|
|
|
|
|
2011-06-22 16:14:36 -07:00
|
|
|
for (size_t i = 0; i < mFilterResources.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
|
2011-06-22 16:14:36 -07:00
|
|
|
}
|
|
|
|
|
2011-01-14 18:51:01 -08:00
|
|
|
for (size_t i = 0; i < mShaders.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
|
2011-01-14 18:51:01 -08:00
|
|
|
}
|
|
|
|
|
2012-05-02 18:50:34 -07:00
|
|
|
for (size_t i = 0; i < mSourcePaths.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
|
2012-05-02 18:50:34 -07:00
|
|
|
}
|
2012-09-07 11:58:36 -07:00
|
|
|
|
Fix occasional crash bug with layers
Launcher occasionally crashes with a stack trace indicating that the memory
of a Layer object is corrupt. It is possible for us to delete a Layer
structure and then, briefly, use it to draw a DisplayList again before
that DisplayList gets recreated (without the layer that got deleted).
When this happens, if the memory got corrupted, it's possible to crash.
The fix is to add Layer to the other objects which we currently refcount
(bitmaps, shaders, etc.). Then instead of deleting a Layer, we decrement the
refcount. We increment when creating it, then increment it again when it's
referenced from a DisplayList. Then we decrement the refcount instead of
deleting it, and decrement when we clear a DisplayList that refers to it.
Then when the refcount reaches 0, we delete it.
Issue #6994632 Native crash in launcher when trying to launch all apps screen
Change-Id: I0627be8d49bb2f9ba8d158a84b764bb4e7df934c
2012-09-14 15:31:25 -07:00
|
|
|
for (size_t i = 0; i < mLayers.size(); i++) {
|
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
|
|
|
|
}
|
|
|
|
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.unlock();
|
|
|
|
|
|
|
|
mBitmapResources.clear();
|
|
|
|
mOwnedBitmapResources.clear();
|
|
|
|
mFilterResources.clear();
|
2012-05-02 18:50:34 -07:00
|
|
|
mSourcePaths.clear();
|
|
|
|
|
2012-09-07 11:58:36 -07: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
|
|
|
|
2012-12-03 12:34:51 -08:00
|
|
|
mRegions.clear();
|
|
|
|
mRegionMap.clear();
|
|
|
|
|
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
|
|
|
|
Fix occasional crash bug with layers
Launcher occasionally crashes with a stack trace indicating that the memory
of a Layer object is corrupt. It is possible for us to delete a Layer
structure and then, briefly, use it to draw a DisplayList again before
that DisplayList gets recreated (without the layer that got deleted).
When this happens, if the memory got corrupted, it's possible to crash.
The fix is to add Layer to the other objects which we currently refcount
(bitmaps, shaders, etc.). Then instead of deleting a Layer, we decrement the
refcount. We increment when creating it, then increment it again when it's
referenced from a DisplayList. Then we decrement the refcount instead of
deleting it, and decrement when we clear a DisplayList that refers to it.
Then when the refcount reaches 0, we delete it.
Issue #6994632 Native crash in launcher when trying to launch all apps screen
Change-Id: I0627be8d49bb2f9ba8d158a84b764bb4e7df934c
2012-09-14 15:31:25 -07:00
|
|
|
mLayers.clear();
|
|
|
|
|
2011-08-25 14:01:48 -07:00
|
|
|
mHasDrawOps = false;
|
2012-09-27 17:55:46 -07:00
|
|
|
mFunctorCount = 0;
|
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
|
|
|
}
|
|
|
|
|
2012-05-15 11:10:01 -07:00
|
|
|
bool DisplayListRenderer::isDeferred() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-10-18 15:05:02 -07:00
|
|
|
status_t DisplayListRenderer::prepareDirty(float left, float top,
|
2011-01-24 16:33:45 -08:00
|
|
|
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;
|
2012-09-11 17:17:07 -07:00
|
|
|
|
2010-09-28 19:09:36 -07:00
|
|
|
mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
|
2012-09-11 17:17:07 -07:00
|
|
|
mDirtyClip = opaque;
|
|
|
|
|
2011-01-23 12:01:41 -08:00
|
|
|
mRestoreSaveCount = -1;
|
2012-09-11 17:17:07 -07:00
|
|
|
|
2012-06-06 19:03:58 -07:00
|
|
|
return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
|
2011-01-23 12:01:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::finish() {
|
|
|
|
insertRestoreToCount();
|
2012-11-26 18:30:17 -08:00
|
|
|
insertTranslate();
|
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
|
2012-11-26 18:30:17 -08:00
|
|
|
addDrawOp(new (alloc()) DrawFunctorOp(functor));
|
2012-09-27 17:55:46 -07:00
|
|
|
mFunctorCount++;
|
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) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SaveOp(flags));
|
2010-09-26 18:40:37 -07:00
|
|
|
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--;
|
2012-11-26 18:30:17 -08:00
|
|
|
insertTranslate();
|
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-11-26 18:30:17 -08:00
|
|
|
insertTranslate();
|
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) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SaveLayerOp(left, top, right, bottom, p, 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) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SaveLayerAlphaOp(left, top, right, bottom, alpha, flags));
|
2010-10-27 18:57:51 -07:00
|
|
|
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) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) RotateOp(degrees));
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::rotate(degrees);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::scale(float sx, float sy) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ScaleOp(sx, sy));
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::scale(sx, sy);
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:19:19 -08:00
|
|
|
void DisplayListRenderer::skew(float sx, float sy) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SkewOp(sx, sy));
|
2011-01-18 11:19:19 -08:00
|
|
|
OpenGLRenderer::skew(sx, sy);
|
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::setMatrix(SkMatrix* matrix) {
|
2012-11-26 18:30:17 -08:00
|
|
|
matrix = refMatrix(matrix);
|
|
|
|
addStateOp(new (alloc()) SetMatrixOp(matrix));
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::setMatrix(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::concatMatrix(SkMatrix* matrix) {
|
2012-11-26 18:30:17 -08:00
|
|
|
matrix = refMatrix(matrix);
|
|
|
|
addStateOp(new (alloc()) ConcatMatrixOp(matrix));
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::concatMatrix(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayListRenderer::clipRect(float left, float top, float right, float bottom,
|
|
|
|
SkRegion::Op op) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ClipRectOp(left, top, right, bottom, op));
|
2010-09-26 18:40:37 -07:00
|
|
|
return OpenGLRenderer::clipRect(left, top, right, bottom, op);
|
|
|
|
}
|
|
|
|
|
2012-12-03 12:34:51 -08:00
|
|
|
bool DisplayListRenderer::clipPath(SkPath* path, SkRegion::Op op) {
|
2012-11-26 18:30:17 -08:00
|
|
|
path = refPath(path);
|
|
|
|
addStateOp(new (alloc()) ClipPathOp(path, op));
|
2012-12-03 12:34:51 -08:00
|
|
|
return OpenGLRenderer::clipPath(path, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayListRenderer::clipRegion(SkRegion* region, SkRegion::Op op) {
|
2012-11-26 18:30:17 -08:00
|
|
|
region = refRegion(region);
|
|
|
|
addStateOp(new (alloc()) ClipRegionOp(region, op));
|
2012-12-03 12:34:51 -08:00
|
|
|
return OpenGLRenderer::clipRegion(region, op);
|
|
|
|
}
|
|
|
|
|
2012-03-26 16:45:05 -07:00
|
|
|
status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList,
|
2012-04-20 09:54:27 -07:00
|
|
|
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
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
// TODO: To be safe, the display list should be ref-counted in the
|
|
|
|
// resources cache, but we rely on the caller (UI toolkit) to
|
|
|
|
// do the right thing for now
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawDisplayListOp(displayList, flags));
|
2012-03-26 16:45:05 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-11-08 12:08:41 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
mLayers.add(layer);
|
|
|
|
mCaches.resourceCache.incrementRefcount(layer);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawLayerOp(layer, x, y, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-11 14:29:25 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapOp(bitmap, left, top, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
matrix = refMatrix(matrix);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapMatrixOp(bitmap, matrix, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
|
2010-09-26 18:40:37 -07:00
|
|
|
float srcRight, float srcBottom, float dstLeft, float dstTop,
|
2010-10-08 08:37:55 -07:00
|
|
|
float dstRight, float dstBottom, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapRectOp(bitmap,
|
|
|
|
srcLeft, srcTop, srcRight, srcBottom,
|
|
|
|
dstLeft, dstTop, dstRight, dstBottom, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
|
|
|
|
SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmapData(bitmap);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapDataOp(bitmap, left, top, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2012-05-14 19:44:40 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
|
2011-01-20 19:09:30 -08:00
|
|
|
float* vertices, int* colors, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
int count = (meshWidth + 1) * (meshHeight + 1) * 2;
|
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
vertices = refBuffer<float>(vertices, count);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
colors = refBuffer<int>(colors, count);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapMeshOp(bitmap, meshWidth, meshHeight,
|
|
|
|
vertices, colors, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-20 19:09:30 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs,
|
|
|
|
const int32_t* yDivs, const uint32_t* colors, uint32_t width, uint32_t height,
|
|
|
|
int8_t numColors, float left, float top, float right, float bottom, SkPaint* paint) {
|
2012-07-16 12:41:17 -07:00
|
|
|
int alpha;
|
|
|
|
SkXfermode::Mode mode;
|
|
|
|
OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
xDivs = refBuffer<int>(xDivs, width);
|
|
|
|
yDivs = refBuffer<int>(yDivs, height);
|
|
|
|
colors = refBuffer<uint32_t>(colors, numColors);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawPatchOp(bitmap, xDivs, yDivs, colors, width, height, numColors,
|
|
|
|
left, top, right, bottom, alpha, mode));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addDrawOp(new (alloc()) DrawColorOp(color, mode));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
|
2010-10-08 08:37:55 -07:00
|
|
|
SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawRectOp(left, top, right, bottom, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t 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-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawRoundRectOp(left, top, right, bottom, rx, ry, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-19 21:54:02 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawCircleOp(x, y, radius, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-19 21:54:02 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawOval(float left, float top, float right, float bottom,
|
2011-01-23 14:18:41 -08:00
|
|
|
SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawOvalOp(left, top, right, bottom, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-23 14:18:41 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
|
2011-01-23 16:15:02 -08:00
|
|
|
float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawArcOp(left, top, right, bottom,
|
|
|
|
startAngle, sweepAngle, useCenter, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-23 16:15:02 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
path = refPath(path);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawPathOp(path, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
points = refBuffer<float>(points, count);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawLinesOp(points, count, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-03-21 13:11:28 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
points = refBuffer<float>(points, count);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawPointsOp(points, count, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-07-23 15:22:52 -07:00
|
|
|
status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
|
|
|
|
SkPath* path, float hOffset, float vOffset, SkPaint* paint) {
|
|
|
|
if (!text || count <= 0) return DrawGlInfo::kStatusDone;
|
2012-11-26 18:30:17 -08:00
|
|
|
|
2012-07-23 15:22:52 -07:00
|
|
|
paint->setAntiAlias(true);
|
2012-11-26 18:30:17 -08:00
|
|
|
text = refText(text, bytesCount);
|
|
|
|
path = refPath(path);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
DrawOp* op = new (alloc()) DrawTextOnPathOp(text, bytesCount, count, path,
|
|
|
|
hOffset, vOffset, paint);
|
|
|
|
if (addDrawOp(op)) {
|
|
|
|
// precache if draw operation is visible
|
|
|
|
FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint);
|
|
|
|
fontRenderer.precache(paint, text, count, *mSnapshot->transform);
|
|
|
|
}
|
2012-07-23 15:22:52 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
|
|
|
|
const float* positions, SkPaint* paint) {
|
|
|
|
if (!text || count <= 0) return DrawGlInfo::kStatusDone;
|
2012-11-26 18:30:17 -08:00
|
|
|
|
2012-07-23 15:22:52 -07:00
|
|
|
paint->setAntiAlias(true);
|
2012-11-26 18:30:17 -08:00
|
|
|
text = refText(text, bytesCount);
|
|
|
|
positions = refBuffer<float>(positions, count * 2);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
DrawOp* op = new (alloc()) DrawPosTextOp(text, bytesCount, count, positions, paint);
|
|
|
|
if (addDrawOp(op)) {
|
|
|
|
// precache if draw operation is visible
|
|
|
|
FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint);
|
|
|
|
fontRenderer.precache(paint, text, count, *mSnapshot->transform);
|
|
|
|
}
|
2012-07-23 15:22:52 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
|
|
|
}
|
|
|
|
|
2012-07-27 16:41:22 -07:00
|
|
|
status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
|
2012-07-23 15:22:52 -07:00
|
|
|
float x, float y, const float* positions, SkPaint* paint, float length) {
|
2012-05-31 15:21:51 -07:00
|
|
|
if (!text || count <= 0) return DrawGlInfo::kStatusDone;
|
2012-02-16 19:24:51 -08:00
|
|
|
|
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);
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
text = refText(text, bytesCount);
|
|
|
|
positions = refBuffer<float>(positions, count * 2);
|
|
|
|
paint = refPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
DrawOp* op = new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, paint, length);
|
|
|
|
if (addDrawOp(op)) {
|
|
|
|
// precache if draw operation is visible
|
|
|
|
FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint);
|
|
|
|
fontRenderer.precache(paint, text, count, *mSnapshot->transform);
|
Optimize interactions with glyph cache
There are two fixes here:
- precaching: instead of caching-then-drawing whenever there is a new
glyph, we cache at DisplayList record time. Then when we finally draw that
DisplayList, we just upload the affected texture(s) once, instead of once
per change. This is a huge savings in upload time, especially when there are
larger glyphs being used by the app.
- packing: Previously, glyphs would line up horizontally on each cache line, leaving
potentially tons of space vertically, especially when smaller glyphs got put into cache
lines intended for large glyphs (which can happen when an app uses lots of unique
glyphs, a common case with, for example, chinese/japanese/korean languages). The new
approach packs glyphs vertically as well as horizontally to use the space more efficiently
and provide space for more glyphs in these situations.
Change-Id: I84338aa25db208c7bf13f3f92b4d05ed40c33527
2012-08-09 13:39:02 -07:00
|
|
|
}
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2013-01-04 19:05:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
status_t DisplayListRenderer::drawRects(const float* rects, int count, SkPaint* paint) {
|
|
|
|
if (count <= 0) return DrawGlInfo::kStatusDone;
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
rects = refBuffer<float>(rects, count);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawRectsOp(rects, count, paint));
|
2013-01-04 19:05:13 -08:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2012-01-17 17:39:26 -08:00
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::resetShader() {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ResetShaderOp());
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupShader(SkiaShader* shader) {
|
2012-11-26 18:30:17 -08:00
|
|
|
shader = refShader(shader);
|
|
|
|
addStateOp(new (alloc()) SetupShaderOp(shader));
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::resetColorFilter() {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ResetColorFilterOp());
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) {
|
2012-11-26 18:30:17 -08:00
|
|
|
filter = refColorFilter(filter);
|
|
|
|
addStateOp(new (alloc()) SetupColorFilterOp(filter));
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::resetShadow() {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ResetShadowOp());
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SetupShadowOp(radius, dx, dy, color));
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-01-23 17:09:05 -08:00
|
|
|
void DisplayListRenderer::resetPaintFilter() {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ResetPaintFilterOp());
|
2012-01-23 17:09:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupPaintFilter(int clearBits, int setBits) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SetupPaintFilterOp(clearBits, setBits));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::insertRestoreToCount() {
|
|
|
|
if (mRestoreSaveCount >= 0) {
|
|
|
|
DisplayListOp* op = new (alloc()) RestoreToCountOp(mRestoreSaveCount);
|
|
|
|
mDisplayListData->displayListOps.add(op);
|
|
|
|
mRestoreSaveCount = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::insertTranslate() {
|
|
|
|
if (mHasTranslate) {
|
|
|
|
if (mTranslateX != 0.0f || mTranslateY != 0.0f) {
|
|
|
|
DisplayListOp* op = new (alloc()) TranslateOp(mTranslateX, mTranslateY);
|
|
|
|
mDisplayListData->displayListOps.add(op);
|
|
|
|
mTranslateX = mTranslateY = 0.0f;
|
|
|
|
}
|
|
|
|
mHasTranslate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::addStateOp(StateOp* op) {
|
|
|
|
addOpInternal(op);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayListRenderer::addDrawOp(DrawOp* op) {
|
|
|
|
bool rejected = false;
|
|
|
|
Rect localBounds;
|
|
|
|
if (op->getLocalBounds(localBounds)) {
|
|
|
|
rejected = quickRejectNoScissor(localBounds.left, localBounds.top,
|
|
|
|
localBounds.right, localBounds.bottom);
|
|
|
|
op->setQuickRejected(rejected);
|
|
|
|
}
|
|
|
|
mHasDrawOps = true;
|
|
|
|
addOpInternal(op);
|
|
|
|
return !rejected;
|
2012-01-23 17:09:05 -08:00
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|