diff options
author | Derek Sollenberger <djsollen@google.com> | 2014-02-19 16:47:32 +0000 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2014-02-20 16:20:33 -0500 |
commit | 674554fc36932ca50b15bba41ac6f650254d4e72 (patch) | |
tree | ec0fc936ce4fdbd15d8bf6e15348676194855b8a | |
parent | 96f0369b25811319398a268071eb147fe14a09e3 (diff) | |
download | frameworks_base-674554fc36932ca50b15bba41ac6f650254d4e72.zip frameworks_base-674554fc36932ca50b15bba41ac6f650254d4e72.tar.gz frameworks_base-674554fc36932ca50b15bba41ac6f650254d4e72.tar.bz2 |
Reapply "Refactor setting an SkPaint onto a hwui Layer."
This reverts commit 90d0c75e94a32fb7d993fae69762820aabc2fcbb.
Change-Id: Ie807761231edf7c848b019931dccbf466208c0be
-rw-r--r-- | core/java/android/view/HardwareLayer.java | 5 | ||||
-rw-r--r-- | core/jni/android_view_HardwareLayer.cpp | 6 | ||||
-rw-r--r-- | libs/hwui/DeferredLayerUpdater.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/DeferredLayerUpdater.h | 6 | ||||
-rw-r--r-- | libs/hwui/Layer.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/Layer.h | 2 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 9 |
7 files changed, 15 insertions, 24 deletions
diff --git a/core/java/android/view/HardwareLayer.java b/core/java/android/view/HardwareLayer.java index 958c071..8900d23 100644 --- a/core/java/android/view/HardwareLayer.java +++ b/core/java/android/view/HardwareLayer.java @@ -66,8 +66,7 @@ final class HardwareLayer { * @see View#setLayerPaint(android.graphics.Paint) */ public void setLayerPaint(Paint paint) { - nSetLayerPaint(mFinalizer.mDeferredUpdater, paint.mNativePaint, - paint.getColorFilter() != null ? paint.getColorFilter().native_instance : 0); + nSetLayerPaint(mFinalizer.mDeferredUpdater, paint.mNativePaint); } /** @@ -270,7 +269,7 @@ final class HardwareLayer { private static native void nDestroyLayerUpdater(long layerUpdater); private static native boolean nPrepare(long layerUpdater, int width, int height, boolean isOpaque); - private static native void nSetLayerPaint(long layerUpdater, long paint, long colorFilter); + private static native void nSetLayerPaint(long layerUpdater, long paint); private static native void nSetTransform(long layerUpdater, long matrix); private static native void nSetSurfaceTexture(long layerUpdater, SurfaceTexture surface, boolean isAlreadyAttached); diff --git a/core/jni/android_view_HardwareLayer.cpp b/core/jni/android_view_HardwareLayer.cpp index 8a0a011..5b21e94 100644 --- a/core/jni/android_view_HardwareLayer.cpp +++ b/core/jni/android_view_HardwareLayer.cpp @@ -88,13 +88,11 @@ static jboolean android_view_HardwareLayer_prepare(JNIEnv* env, jobject clazz, } static void android_view_HardwareLayer_setLayerPaint(JNIEnv* env, jobject clazz, - jlong layerUpdaterPtr, jlong paintPtr, jlong colorFilterPtr) { + jlong layerUpdaterPtr, jlong paintPtr) { DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(layerUpdaterPtr); if (layer) { SkPaint* paint = reinterpret_cast<SkPaint*>(paintPtr); - SkColorFilter* colorFilter = reinterpret_cast<SkColorFilter*>(colorFilterPtr); layer->setPaint(paint); - layer->setColorFilter(colorFilter); } } @@ -162,7 +160,7 @@ static JNINativeMethod gMethods[] = { { "nDestroyLayerUpdater", "(J)V", (void*) android_view_HardwareLayer_destroyLayerUpdater }, { "nPrepare", "(JIIZ)Z", (void*) android_view_HardwareLayer_prepare }, - { "nSetLayerPaint", "(JJJ)V", (void*) android_view_HardwareLayer_setLayerPaint }, + { "nSetLayerPaint", "(JJ)V", (void*) android_view_HardwareLayer_setLayerPaint }, { "nSetTransform", "(JJ)V", (void*) android_view_HardwareLayer_setTransform }, { "nSetSurfaceTexture", "(JLandroid/graphics/SurfaceTexture;Z)V", (void*) android_view_HardwareLayer_setSurfaceTexture }, diff --git a/libs/hwui/DeferredLayerUpdater.cpp b/libs/hwui/DeferredLayerUpdater.cpp index efb1298..62f6c76 100644 --- a/libs/hwui/DeferredLayerUpdater.cpp +++ b/libs/hwui/DeferredLayerUpdater.cpp @@ -34,21 +34,23 @@ DeferredLayerUpdater::DeferredLayerUpdater(Layer* layer, OpenGLRenderer* rendere mWidth = mLayer->layer.getWidth(); mHeight = mLayer->layer.getHeight(); mBlend = mLayer->isBlend(); - mColorFilter = mLayer->getColorFilter(); + mColorFilter = SkSafeRef(mLayer->getColorFilter()); mAlpha = mLayer->getAlpha(); mMode = mLayer->getMode(); mDirtyRect.setEmpty(); } DeferredLayerUpdater::~DeferredLayerUpdater() { - setColorFilter(NULL); + SkSafeUnref(mColorFilter); if (mLayer) { mCaches.resourceCache.decrementRefcount(mLayer); } delete mRenderer; } -void DeferredLayerUpdater::setColorFilter(SkColorFilter* colorFilter) { +void DeferredLayerUpdater::setPaint(const SkPaint* paint) { + OpenGLRenderer::getAlphaAndModeDirect(paint, &mAlpha, &mMode); + SkColorFilter* colorFilter = (paint) ? paint->getColorFilter() : NULL; SkRefCnt_SafeAssign(mColorFilter, colorFilter); } diff --git a/libs/hwui/DeferredLayerUpdater.h b/libs/hwui/DeferredLayerUpdater.h index 624db2c..65f225c 100644 --- a/libs/hwui/DeferredLayerUpdater.h +++ b/libs/hwui/DeferredLayerUpdater.h @@ -75,11 +75,7 @@ public: ANDROID_API void setDisplayList(DisplayList* displayList, int left, int top, int right, int bottom); - ANDROID_API void setPaint(const SkPaint* paint) { - OpenGLRenderer::getAlphaAndModeDirect(paint, &mAlpha, &mMode); - } - - ANDROID_API void setColorFilter(SkColorFilter* colorFilter); + ANDROID_API void setPaint(const SkPaint* paint); ANDROID_API bool apply(); diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index 70eeb39..54ce64f 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -131,8 +131,9 @@ void Layer::removeFbo(bool flush) { } } -void Layer::setPaint(SkPaint* paint) { +void Layer::setPaint(const SkPaint* paint) { OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode); + setColorFilter((paint) ? paint->getColorFilter() : NULL); } void Layer::setColorFilter(SkColorFilter* filter) { diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index ec80e9c..8cc027a 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -117,7 +117,7 @@ public: texture.height = height; } - ANDROID_API void setPaint(SkPaint* paint); + ANDROID_API void setPaint(const SkPaint* paint); inline void setBlend(bool blend) { texture.blend = blend; diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 9b253a6..2da0fd3 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -868,14 +868,11 @@ bool OpenGLRenderer::createLayer(float left, float top, float right, float botto const bool fboLayer = flags & SkCanvas::kClipToLayer_SaveFlag; - SkXfermode::Mode mode = getXfermodeDirect(paint); - int alpha = getAlphaDirect(paint); - // Window coordinates of the layer Rect clip; Rect bounds(left, top, right, bottom); calculateLayerBoundsAndClip(bounds, clip, fboLayer); - updateSnapshotIgnoreForLayer(bounds, clip, fboLayer, alpha); + updateSnapshotIgnoreForLayer(bounds, clip, fboLayer, getAlphaDirect(paint)); // Bail out if we won't draw in this snapshot if (currentSnapshot()->isIgnored()) { @@ -888,12 +885,11 @@ bool OpenGLRenderer::createLayer(float left, float top, float right, float botto return false; } - layer->setAlpha(alpha, mode); + layer->setPaint(paint); layer->layer.set(bounds); layer->texCoords.set(0.0f, bounds.getHeight() / float(layer->getHeight()), bounds.getWidth() / float(layer->getWidth()), 0.0f); - layer->setColorFilter(getColorFilter(paint)); layer->setBlend(true); layer->setDirty(false); @@ -1011,7 +1007,6 @@ void OpenGLRenderer::composeLayer(const Snapshot& removed, const Snapshot& resto } if (!fboLayer && layer->getAlpha() < 255) { - // TODO: this seems to point to the fact that the layer should store the paint SkPaint layerPaint; layerPaint.setAlpha(layer->getAlpha()); layerPaint.setXfermodeMode(SkXfermode::kDstIn_Mode); |