Merge "Fix texture corruption" into jb-mr1-dev
This commit is contained in:
@@ -332,4 +332,11 @@ public abstract class DisplayList {
|
||||
* @see View#offsetTopAndBottom(int)
|
||||
*/
|
||||
public abstract void offsetTopBottom(int offset);
|
||||
|
||||
/**
|
||||
* Reset native resources. This is called when cleaning up the state of DisplayLists
|
||||
* during destruction of hardware resources, to ensure that we do not hold onto
|
||||
* obsolete resources after related resources are gone.
|
||||
*/
|
||||
public abstract void reset();
|
||||
}
|
||||
|
||||
@@ -86,6 +86,13 @@ class GLES20DisplayList extends DisplayList {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
if (hasNativeDisplayList()) {
|
||||
nReset(mFinalizer.mNativeDisplayList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return mValid;
|
||||
@@ -294,6 +301,7 @@ class GLES20DisplayList extends DisplayList {
|
||||
}
|
||||
}
|
||||
|
||||
private static native void nReset(int displayList);
|
||||
private static native void nOffsetTopBottom(int displayList, int offset);
|
||||
private static native void nOffsetLeftRight(int displayList, int offset);
|
||||
private static native void nSetLeftTopRightBottom(int displayList, int left, int top,
|
||||
|
||||
@@ -1508,6 +1508,9 @@ public abstract class HardwareRenderer {
|
||||
@Override
|
||||
void destroyLayers(View view) {
|
||||
if (view != null && isEnabled() && checkCurrent() != SURFACE_STATE_ERROR) {
|
||||
if (mCanvas != null) {
|
||||
mCanvas.clearLayerUpdates();
|
||||
}
|
||||
destroyHardwareLayer(view);
|
||||
GLES20Canvas.flushCaches(GLES20Canvas.FLUSH_CACHES_LAYERS);
|
||||
}
|
||||
@@ -1556,6 +1559,9 @@ public abstract class HardwareRenderer {
|
||||
safelyRun(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mCanvas != null) {
|
||||
mCanvas.clearLayerUpdates();
|
||||
}
|
||||
destroyResources(view);
|
||||
GLES20Canvas.flushCaches(GLES20Canvas.FLUSH_CACHES_LAYERS);
|
||||
}
|
||||
|
||||
@@ -12394,6 +12394,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
mHardwareLayer.destroy();
|
||||
mHardwareLayer = null;
|
||||
|
||||
if (mDisplayList != null) {
|
||||
mDisplayList.reset();
|
||||
}
|
||||
invalidate(true);
|
||||
invalidateParentCaches();
|
||||
}
|
||||
|
||||
@@ -931,6 +931,9 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l
|
||||
SkIRect ir;
|
||||
bool result = canvas->getClipBounds(&r, SkCanvas::kBW_EdgeType);
|
||||
|
||||
if (!result) {
|
||||
r.setEmpty();
|
||||
}
|
||||
r.round(&ir);
|
||||
(void)GraphicsJNI::irect_to_jrect(ir, env, bounds);
|
||||
return result;
|
||||
|
||||
@@ -36,6 +36,11 @@ using namespace uirenderer;
|
||||
*/
|
||||
#ifdef USE_OPENGL_RENDERER
|
||||
|
||||
static void android_view_GLES20DisplayList_reset(JNIEnv* env,
|
||||
jobject clazz, DisplayList* displayList) {
|
||||
displayList->reset();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DisplayList view properties
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -185,6 +190,7 @@ const char* const kClassPathName = "android/view/GLES20DisplayList";
|
||||
|
||||
static JNINativeMethod gMethods[] = {
|
||||
#ifdef USE_OPENGL_RENDERER
|
||||
{ "nReset", "(I)V", (void*) android_view_GLES20DisplayList_reset },
|
||||
{ "nSetCaching", "(IZ)V", (void*) android_view_GLES20DisplayList_setCaching },
|
||||
{ "nSetStaticMatrix", "(II)V", (void*) android_view_GLES20DisplayList_setStaticMatrix },
|
||||
{ "nSetAnimationMatrix", "(II)V", (void*) android_view_GLES20DisplayList_setAnimationMatrix },
|
||||
|
||||
@@ -268,8 +268,6 @@ void Caches::deleteDisplayListDeferred(DisplayList* displayList) {
|
||||
void Caches::flush(FlushMode mode) {
|
||||
FLUSH_LOGD("Flushing caches (mode %d)", mode);
|
||||
|
||||
clearGarbage();
|
||||
|
||||
switch (mode) {
|
||||
case kFlushMode_Full:
|
||||
textureCache.clear();
|
||||
@@ -293,6 +291,8 @@ void Caches::flush(FlushMode mode) {
|
||||
layerCache.clear();
|
||||
break;
|
||||
}
|
||||
|
||||
clearGarbage();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -105,35 +105,6 @@ DisplayList::~DisplayList() {
|
||||
clearResources();
|
||||
}
|
||||
|
||||
void DisplayList::initProperties() {
|
||||
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;
|
||||
}
|
||||
|
||||
void DisplayList::destroyDisplayListDeferred(DisplayList* displayList) {
|
||||
if (displayList) {
|
||||
DISPLAY_LIST_LOGD("Deferring display list destruction");
|
||||
@@ -215,8 +186,12 @@ void DisplayList::clearResources() {
|
||||
mLayers.clear();
|
||||
}
|
||||
|
||||
void DisplayList::reset() {
|
||||
clearResources();
|
||||
init();
|
||||
}
|
||||
|
||||
void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
|
||||
const SkWriter32& writer = recorder.writeStream();
|
||||
|
||||
if (reusing) {
|
||||
// re-using display list - clear out previous allocations
|
||||
@@ -224,8 +199,8 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde
|
||||
}
|
||||
|
||||
init();
|
||||
initProperties();
|
||||
|
||||
const SkWriter32& writer = recorder.writeStream();
|
||||
if (writer.size() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -303,6 +278,32 @@ void DisplayList::init() {
|
||||
mSize = 0;
|
||||
mIsRenderable = true;
|
||||
mFunctorCount = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
size_t DisplayList::getSize() {
|
||||
|
||||
@@ -137,6 +137,8 @@ public:
|
||||
|
||||
void output(OpenGLRenderer& renderer, uint32_t level = 0);
|
||||
|
||||
ANDROID_API void reset();
|
||||
|
||||
void setRenderable(bool renderable) {
|
||||
mIsRenderable = renderable;
|
||||
}
|
||||
@@ -399,7 +401,6 @@ public:
|
||||
|
||||
private:
|
||||
void init();
|
||||
void initProperties();
|
||||
|
||||
void clearResources();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user