Skip to content

Commit a8557d2

Browse files
committed
Revert "Add more support for transformed clip rects and paths"
this introduced a dead lock in GradientCache's ctor. This reverts commit dfe082f. Bug: 7096001 Change-Id: I57b8bbab11fb7cb502fa58e3bbf5d19864db874f
1 parent 703bd32 commit a8557d2

File tree

10 files changed

+78
-190
lines changed

10 files changed

+78
-190
lines changed

core/jni/android_view_GLES20Canvas.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#include <OpenGLRenderer.h>
4747
#include <SkiaShader.h>
4848
#include <SkiaColorFilter.h>
49-
#include <Stencil.h>
5049
#include <Rect.h>
5150

5251
#include <TextLayout.h>
@@ -151,7 +150,7 @@ static void android_view_GLES20Canvas_finish(JNIEnv* env, jobject clazz,
151150
}
152151

153152
static jint android_view_GLES20Canvas_getStencilSize(JNIEnv* env, jobject clazz) {
154-
return Stencil::getStencilSize();
153+
return OpenGLRenderer::getStencilSize();
155154
}
156155

157156
// ----------------------------------------------------------------------------

libs/hwui/Android.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ ifeq ($(USE_OPENGL_RENDERER),true)
2828
SkiaColorFilter.cpp \
2929
SkiaShader.cpp \
3030
Snapshot.cpp \
31-
Stencil.cpp \
3231
TextureCache.cpp \
3332
TextDropShadowCache.cpp
3433

libs/hwui/Caches.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "TextDropShadowCache.h"
3939
#include "FboCache.h"
4040
#include "ResourceCache.h"
41-
#include "Stencil.h"
4241
#include "Dither.h"
4342

4443
namespace android {
@@ -253,14 +252,10 @@ class ANDROID_API Caches: public Singleton<Caches> {
253252
TextDropShadowCache dropShadowCache;
254253
FboCache fboCache;
255254
ResourceCache resourceCache;
255+
Dither dither;
256256

257257
GammaFontRenderer* fontRenderer;
258258

259-
Dither dither;
260-
#if STENCIL_BUFFER_SIZE
261-
Stencil stencil;
262-
#endif
263-
264259
// Debug methods
265260
PFNGLINSERTEVENTMARKEREXTPROC eventMark;
266261
PFNGLPUSHGROUPMARKEREXTPROC startMark;

libs/hwui/GradientCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ GradientCache::GradientCache():
5757
INIT_LOGD(" Using default gradient cache size of %.2fMB", DEFAULT_GRADIENT_CACHE_SIZE);
5858
}
5959

60-
mMaxTextureSize = Caches::getInstance().maxTextureSize;
60+
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
6161

6262
mCache.setOnEntryRemovedListener(this);
6363
}

libs/hwui/OpenGLRenderer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ void OpenGLRenderer::endMark() const {
139139
// Setup
140140
///////////////////////////////////////////////////////////////////////////////
141141

142+
uint32_t OpenGLRenderer::getStencilSize() {
143+
return STENCIL_BUFFER_SIZE;
144+
}
145+
142146
bool OpenGLRenderer::isDeferred() {
143147
return false;
144148
}

libs/hwui/OpenGLRenderer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ class OpenGLRenderer {
207207

208208
SkPaint* filterPaint(SkPaint* paint);
209209

210+
/**
211+
* Returns the desired size for the stencil buffer. If the returned value
212+
* is 0, then no stencil buffer is required.
213+
*/
214+
ANDROID_API static uint32_t getStencilSize();
215+
210216
/**
211217
* Sets the alpha on the current snapshot. This alpha value will be modulated
212218
* with other alpha values when drawing primitives.

libs/hwui/Snapshot.cpp

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags):
5757
clipRect = &mClipRectRoot;
5858
#if STENCIL_BUFFER_SIZE
5959
if (s->clipRegion) {
60-
mClipRegionRoot.op(*s->clipRegion, SkRegion::kUnion_Op);
60+
mClipRegionRoot.merge(*s->clipRegion);
6161
clipRegion = &mClipRegionRoot;
6262
}
6363
#endif
@@ -84,19 +84,20 @@ void Snapshot::ensureClipRegion() {
8484
#if STENCIL_BUFFER_SIZE
8585
if (!clipRegion) {
8686
clipRegion = &mClipRegionRoot;
87-
clipRegion->setRect(clipRect->left, clipRect->top, clipRect->right, clipRect->bottom);
87+
android::Rect tmp(clipRect->left, clipRect->top, clipRect->right, clipRect->bottom);
88+
clipRegion->set(tmp);
8889
}
8990
#endif
9091
}
9192

9293
void Snapshot::copyClipRectFromRegion() {
9394
#if STENCIL_BUFFER_SIZE
9495
if (!clipRegion->isEmpty()) {
95-
const SkIRect& bounds = clipRegion->getBounds();
96-
clipRect->set(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
96+
android::Rect bounds(clipRegion->bounds());
97+
clipRect->set(bounds.left, bounds.top, bounds.right, bounds.bottom);
9798

9899
if (clipRegion->isRect()) {
99-
clipRegion->setEmpty();
100+
clipRegion->clear();
100101
clipRegion = NULL;
101102
}
102103
} else {
@@ -106,11 +107,43 @@ void Snapshot::copyClipRectFromRegion() {
106107
#endif
107108
}
108109

109-
bool Snapshot::clipRegionOp(float left, float top, float right, float bottom, SkRegion::Op op) {
110+
bool Snapshot::clipRegionOr(float left, float top, float right, float bottom) {
110111
#if STENCIL_BUFFER_SIZE
111-
SkIRect tmp;
112-
tmp.set(left, top, right, bottom);
113-
clipRegion->op(tmp, op);
112+
android::Rect tmp(left, top, right, bottom);
113+
clipRegion->orSelf(tmp);
114+
copyClipRectFromRegion();
115+
return true;
116+
#else
117+
return false;
118+
#endif
119+
}
120+
121+
bool Snapshot::clipRegionXor(float left, float top, float right, float bottom) {
122+
#if STENCIL_BUFFER_SIZE
123+
android::Rect tmp(left, top, right, bottom);
124+
clipRegion->xorSelf(tmp);
125+
copyClipRectFromRegion();
126+
return true;
127+
#else
128+
return false;
129+
#endif
130+
}
131+
132+
bool Snapshot::clipRegionAnd(float left, float top, float right, float bottom) {
133+
#if STENCIL_BUFFER_SIZE
134+
android::Rect tmp(left, top, right, bottom);
135+
clipRegion->andSelf(tmp);
136+
copyClipRectFromRegion();
137+
return true;
138+
#else
139+
return false;
140+
#endif
141+
}
142+
143+
bool Snapshot::clipRegionNand(float left, float top, float right, float bottom) {
144+
#if STENCIL_BUFFER_SIZE
145+
android::Rect tmp(left, top, right, bottom);
146+
clipRegion->subtractSelf(tmp);
114147
copyClipRectFromRegion();
115148
return true;
116149
#else
@@ -128,9 +161,14 @@ bool Snapshot::clipTransformed(const Rect& r, SkRegion::Op op) {
128161
bool clipped = false;
129162

130163
switch (op) {
164+
case SkRegion::kDifference_Op: {
165+
ensureClipRegion();
166+
clipped = clipRegionNand(r.left, r.top, r.right, r.bottom);
167+
break;
168+
}
131169
case SkRegion::kIntersect_Op: {
132170
if (CC_UNLIKELY(clipRegion)) {
133-
clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, SkRegion::kIntersect_Op);
171+
clipped = clipRegionOr(r.left, r.top, r.right, r.bottom);
134172
} else {
135173
clipped = clipRect->intersect(r);
136174
if (!clipped) {
@@ -142,22 +180,26 @@ bool Snapshot::clipTransformed(const Rect& r, SkRegion::Op op) {
142180
}
143181
case SkRegion::kUnion_Op: {
144182
if (CC_UNLIKELY(clipRegion)) {
145-
clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, SkRegion::kUnion_Op);
183+
clipped = clipRegionAnd(r.left, r.top, r.right, r.bottom);
146184
} else {
147185
clipped = clipRect->unionWith(r);
148186
}
149187
break;
150188
}
189+
case SkRegion::kXOR_Op: {
190+
ensureClipRegion();
191+
clipped = clipRegionXor(r.left, r.top, r.right, r.bottom);
192+
break;
193+
}
194+
case SkRegion::kReverseDifference_Op: {
195+
// TODO!!!!!!!
196+
break;
197+
}
151198
case SkRegion::kReplace_Op: {
152199
setClip(r.left, r.top, r.right, r.bottom);
153200
clipped = true;
154201
break;
155202
}
156-
default: {
157-
ensureClipRegion();
158-
clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, op);
159-
break;
160-
}
161203
}
162204

163205
if (clipped) {
@@ -171,7 +213,7 @@ void Snapshot::setClip(float left, float top, float right, float bottom) {
171213
clipRect->set(left, top, right, bottom);
172214
#if STENCIL_BUFFER_SIZE
173215
if (clipRegion) {
174-
clipRegion->setEmpty();
216+
clipRegion->clear();
175217
clipRegion = NULL;
176218
}
177219
#endif

libs/hwui/Snapshot.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Snapshot: public LightRefBase<Snapshot> {
198198
*
199199
* This field is used only if STENCIL_BUFFER_SIZE is > 0.
200200
*/
201-
SkRegion* clipRegion;
201+
Region* clipRegion;
202202

203203
/**
204204
* The ancestor layer's dirty region.
@@ -223,14 +223,17 @@ class Snapshot: public LightRefBase<Snapshot> {
223223
void ensureClipRegion();
224224
void copyClipRectFromRegion();
225225

226-
bool clipRegionOp(float left, float top, float right, float bottom, SkRegion::Op op);
226+
bool clipRegionOr(float left, float top, float right, float bottom);
227+
bool clipRegionXor(float left, float top, float right, float bottom);
228+
bool clipRegionAnd(float left, float top, float right, float bottom);
229+
bool clipRegionNand(float left, float top, float right, float bottom);
227230

228231
mat4 mTransformRoot;
229232
Rect mClipRectRoot;
230233
Rect mLocalClip;
231234

232235
#if STENCIL_BUFFER_SIZE
233-
SkRegion mClipRegionRoot;
236+
Region mClipRegionRoot;
234237
#endif
235238

236239
}; // class Snapshot

libs/hwui/Stencil.cpp

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)