diff options
author | Mathias Agopian <mathias@google.com> | 2012-08-31 19:52:30 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2012-08-31 20:04:18 -0700 |
commit | a8557d2169e14997637f57bc897640c8882d4a46 (patch) | |
tree | 7b2266c166f65ef186e913f18110dab6bbd7d9e8 | |
parent | 703bd32647556524fa8cadbe869c8a8d734640ef (diff) | |
download | frameworks_base-a8557d2169e14997637f57bc897640c8882d4a46.zip frameworks_base-a8557d2169e14997637f57bc897640c8882d4a46.tar.gz frameworks_base-a8557d2169e14997637f57bc897640c8882d4a46.tar.bz2 |
Revert "Add more support for transformed clip rects and paths"
this introduced a dead lock in GradientCache's ctor.
This reverts commit dfe082f63e94cde9aee271c94d13de5e7217e036.
Bug: 7096001
Change-Id: I57b8bbab11fb7cb502fa58e3bbf5d19864db874f
-rw-r--r-- | core/jni/android_view_GLES20Canvas.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/Android.mk | 1 | ||||
-rw-r--r-- | libs/hwui/Caches.h | 7 | ||||
-rw-r--r-- | libs/hwui/GradientCache.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 6 | ||||
-rw-r--r-- | libs/hwui/Snapshot.cpp | 76 | ||||
-rw-r--r-- | libs/hwui/Snapshot.h | 9 | ||||
-rw-r--r-- | libs/hwui/Stencil.cpp | 71 | ||||
-rw-r--r-- | libs/hwui/Stencil.h | 89 |
10 files changed, 78 insertions, 190 deletions
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp index 3538fef..9fc73a4 100644 --- a/core/jni/android_view_GLES20Canvas.cpp +++ b/core/jni/android_view_GLES20Canvas.cpp @@ -46,7 +46,6 @@ #include <OpenGLRenderer.h> #include <SkiaShader.h> #include <SkiaColorFilter.h> -#include <Stencil.h> #include <Rect.h> #include <TextLayout.h> @@ -151,7 +150,7 @@ static void android_view_GLES20Canvas_finish(JNIEnv* env, jobject clazz, } static jint android_view_GLES20Canvas_getStencilSize(JNIEnv* env, jobject clazz) { - return Stencil::getStencilSize(); + return OpenGLRenderer::getStencilSize(); } // ---------------------------------------------------------------------------- diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk index c3a07a1..1947c32 100644 --- a/libs/hwui/Android.mk +++ b/libs/hwui/Android.mk @@ -28,7 +28,6 @@ ifeq ($(USE_OPENGL_RENDERER),true) SkiaColorFilter.cpp \ SkiaShader.cpp \ Snapshot.cpp \ - Stencil.cpp \ TextureCache.cpp \ TextDropShadowCache.cpp diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index b9a6336..f4f56d6 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -38,7 +38,6 @@ #include "TextDropShadowCache.h" #include "FboCache.h" #include "ResourceCache.h" -#include "Stencil.h" #include "Dither.h" namespace android { @@ -253,14 +252,10 @@ public: TextDropShadowCache dropShadowCache; FboCache fboCache; ResourceCache resourceCache; + Dither dither; GammaFontRenderer* fontRenderer; - Dither dither; -#if STENCIL_BUFFER_SIZE - Stencil stencil; -#endif - // Debug methods PFNGLINSERTEVENTMARKEREXTPROC eventMark; PFNGLPUSHGROUPMARKEREXTPROC startMark; diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp index b50ed10..2e4e349 100644 --- a/libs/hwui/GradientCache.cpp +++ b/libs/hwui/GradientCache.cpp @@ -57,7 +57,7 @@ GradientCache::GradientCache(): INIT_LOGD(" Using default gradient cache size of %.2fMB", DEFAULT_GRADIENT_CACHE_SIZE); } - mMaxTextureSize = Caches::getInstance().maxTextureSize; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); mCache.setOnEntryRemovedListener(this); } diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 2f43be8..8da9f66 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -139,6 +139,10 @@ void OpenGLRenderer::endMark() const { // Setup /////////////////////////////////////////////////////////////////////////////// +uint32_t OpenGLRenderer::getStencilSize() { + return STENCIL_BUFFER_SIZE; +} + bool OpenGLRenderer::isDeferred() { return false; } diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 4c7cf0a..2369f47 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -208,6 +208,12 @@ public: SkPaint* filterPaint(SkPaint* paint); /** + * Returns the desired size for the stencil buffer. If the returned value + * is 0, then no stencil buffer is required. + */ + ANDROID_API static uint32_t getStencilSize(); + + /** * Sets the alpha on the current snapshot. This alpha value will be modulated * with other alpha values when drawing primitives. */ diff --git a/libs/hwui/Snapshot.cpp b/libs/hwui/Snapshot.cpp index 4484676..5d5961a 100644 --- a/libs/hwui/Snapshot.cpp +++ b/libs/hwui/Snapshot.cpp @@ -57,7 +57,7 @@ Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags): clipRect = &mClipRectRoot; #if STENCIL_BUFFER_SIZE if (s->clipRegion) { - mClipRegionRoot.op(*s->clipRegion, SkRegion::kUnion_Op); + mClipRegionRoot.merge(*s->clipRegion); clipRegion = &mClipRegionRoot; } #endif @@ -84,7 +84,8 @@ void Snapshot::ensureClipRegion() { #if STENCIL_BUFFER_SIZE if (!clipRegion) { clipRegion = &mClipRegionRoot; - clipRegion->setRect(clipRect->left, clipRect->top, clipRect->right, clipRect->bottom); + android::Rect tmp(clipRect->left, clipRect->top, clipRect->right, clipRect->bottom); + clipRegion->set(tmp); } #endif } @@ -92,11 +93,11 @@ void Snapshot::ensureClipRegion() { void Snapshot::copyClipRectFromRegion() { #if STENCIL_BUFFER_SIZE if (!clipRegion->isEmpty()) { - const SkIRect& bounds = clipRegion->getBounds(); - clipRect->set(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); + android::Rect bounds(clipRegion->bounds()); + clipRect->set(bounds.left, bounds.top, bounds.right, bounds.bottom); if (clipRegion->isRect()) { - clipRegion->setEmpty(); + clipRegion->clear(); clipRegion = NULL; } } else { @@ -106,11 +107,43 @@ void Snapshot::copyClipRectFromRegion() { #endif } -bool Snapshot::clipRegionOp(float left, float top, float right, float bottom, SkRegion::Op op) { +bool Snapshot::clipRegionOr(float left, float top, float right, float bottom) { #if STENCIL_BUFFER_SIZE - SkIRect tmp; - tmp.set(left, top, right, bottom); - clipRegion->op(tmp, op); + android::Rect tmp(left, top, right, bottom); + clipRegion->orSelf(tmp); + copyClipRectFromRegion(); + return true; +#else + return false; +#endif +} + +bool Snapshot::clipRegionXor(float left, float top, float right, float bottom) { +#if STENCIL_BUFFER_SIZE + android::Rect tmp(left, top, right, bottom); + clipRegion->xorSelf(tmp); + copyClipRectFromRegion(); + return true; +#else + return false; +#endif +} + +bool Snapshot::clipRegionAnd(float left, float top, float right, float bottom) { +#if STENCIL_BUFFER_SIZE + android::Rect tmp(left, top, right, bottom); + clipRegion->andSelf(tmp); + copyClipRectFromRegion(); + return true; +#else + return false; +#endif +} + +bool Snapshot::clipRegionNand(float left, float top, float right, float bottom) { +#if STENCIL_BUFFER_SIZE + android::Rect tmp(left, top, right, bottom); + clipRegion->subtractSelf(tmp); copyClipRectFromRegion(); return true; #else @@ -128,9 +161,14 @@ bool Snapshot::clipTransformed(const Rect& r, SkRegion::Op op) { bool clipped = false; switch (op) { + case SkRegion::kDifference_Op: { + ensureClipRegion(); + clipped = clipRegionNand(r.left, r.top, r.right, r.bottom); + break; + } case SkRegion::kIntersect_Op: { if (CC_UNLIKELY(clipRegion)) { - clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, SkRegion::kIntersect_Op); + clipped = clipRegionOr(r.left, r.top, r.right, r.bottom); } else { clipped = clipRect->intersect(r); if (!clipped) { @@ -142,22 +180,26 @@ bool Snapshot::clipTransformed(const Rect& r, SkRegion::Op op) { } case SkRegion::kUnion_Op: { if (CC_UNLIKELY(clipRegion)) { - clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, SkRegion::kUnion_Op); + clipped = clipRegionAnd(r.left, r.top, r.right, r.bottom); } else { clipped = clipRect->unionWith(r); } break; } + case SkRegion::kXOR_Op: { + ensureClipRegion(); + clipped = clipRegionXor(r.left, r.top, r.right, r.bottom); + break; + } + case SkRegion::kReverseDifference_Op: { + // TODO!!!!!!! + break; + } case SkRegion::kReplace_Op: { setClip(r.left, r.top, r.right, r.bottom); clipped = true; break; } - default: { - ensureClipRegion(); - clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, op); - break; - } } if (clipped) { @@ -171,7 +213,7 @@ void Snapshot::setClip(float left, float top, float right, float bottom) { clipRect->set(left, top, right, bottom); #if STENCIL_BUFFER_SIZE if (clipRegion) { - clipRegion->setEmpty(); + clipRegion->clear(); clipRegion = NULL; } #endif diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h index a89b740..30b03fc 100644 --- a/libs/hwui/Snapshot.h +++ b/libs/hwui/Snapshot.h @@ -198,7 +198,7 @@ public: * * This field is used only if STENCIL_BUFFER_SIZE is > 0. */ - SkRegion* clipRegion; + Region* clipRegion; /** * The ancestor layer's dirty region. @@ -223,14 +223,17 @@ private: void ensureClipRegion(); void copyClipRectFromRegion(); - bool clipRegionOp(float left, float top, float right, float bottom, SkRegion::Op op); + bool clipRegionOr(float left, float top, float right, float bottom); + bool clipRegionXor(float left, float top, float right, float bottom); + bool clipRegionAnd(float left, float top, float right, float bottom); + bool clipRegionNand(float left, float top, float right, float bottom); mat4 mTransformRoot; Rect mClipRectRoot; Rect mLocalClip; #if STENCIL_BUFFER_SIZE - SkRegion mClipRegionRoot; + Region mClipRegionRoot; #endif }; // class Snapshot diff --git a/libs/hwui/Stencil.cpp b/libs/hwui/Stencil.cpp deleted file mode 100644 index 9d2c86f..0000000 --- a/libs/hwui/Stencil.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#include <GLES2/gl2.h> - -#include "Properties.h" -#include "Stencil.h" - -namespace android { -namespace uirenderer { - -Stencil::Stencil(): mState(kDisabled) { -} - -uint32_t Stencil::getStencilSize() { - return STENCIL_BUFFER_SIZE; -} - -void Stencil::clear() { - glClearStencil(0); - glClear(GL_STENCIL_BUFFER_BIT); -} - -void Stencil::enableTest() { - if (mState != kTest) { - enable(); - glStencilFunc(GL_LESS, 0x0, 0x1); - // We only want to test, let's keep everything - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - mState = kTest; - } -} - -void Stencil::enableWrite() { - if (mState != kWrite) { - enable(); - glStencilFunc(GL_ALWAYS, 0x1, 0x1); - // The test always passes so the first two values are meaningless - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - mState = kWrite; - } -} - -void Stencil::enable() { - if (!mState == kDisabled) { - glEnable(GL_STENCIL_TEST); - } -} - -void Stencil::disable() { - if (mState != kDisabled) { - glDisable(GL_STENCIL_TEST); - mState = kDisabled; - } -} - -}; // namespace uirenderer -}; // namespace android diff --git a/libs/hwui/Stencil.h b/libs/hwui/Stencil.h deleted file mode 100644 index 67ccc78..0000000 --- a/libs/hwui/Stencil.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_HWUI_STENCIL_H -#define ANDROID_HWUI_STENCIL_H - -#ifndef LOG_TAG - #define LOG_TAG "OpenGLRenderer" -#endif - -#include <cutils/compiler.h> - -namespace android { -namespace uirenderer { - -/////////////////////////////////////////////////////////////////////////////// -// Stencil buffer management -/////////////////////////////////////////////////////////////////////////////// - -class ANDROID_API Stencil { -public: - Stencil(); - - /** - * Returns the desired size for the stencil buffer. If the returned value - * is 0, then no stencil buffer is required. - */ - ANDROID_API static uint32_t getStencilSize(); - - /** - * Clears the stencil buffer. - */ - void clear(); - - /** - * Enables stencil test. When the stencil test is enabled the stencil - * buffer is not written into. - */ - void enableTest(); - - /** - * Enables stencil write. When stencil write is enabled, the stencil - * test always succeeds and the value 0x1 is written in the stencil - * buffer for each fragment. - */ - void enableWrite(); - - /** - * Disables stencil test and write. - */ - void disable(); - - /** - * Indicates whether either test or write is enabled. - */ - bool isEnabled() { - return mState != kDisabled; - } - -private: - void enable(); - - enum StencilState { - kDisabled, - kTest, - kWrite - }; - - StencilState mState; - -}; // class Stencil - -}; // namespace uirenderer -}; // namespace android - -#endif // ANDROID_HWUI_STENCIL_H |