Skip to content

Commit a852ff3

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge changes I9873540e,I4f6c38e3 into jb-mr1-dev
* changes: Skia's ColorMatrix vector is in the 0..255 range not 0..1 Bug #7248980 Don't use the QCOM_tiled_rendering extension with functors Bug #7247880
2 parents 93aa70c + 6ed9e43 commit a852ff3

File tree

7 files changed

+63
-8
lines changed

7 files changed

+63
-8
lines changed

libs/hwui/Caches.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ void Caches::init() {
8787
lastDstMode = GL_ZERO;
8888
currentProgram = NULL;
8989

90+
mFunctorsCount = 0;
91+
9092
mInitialized = true;
9193
}
9294

@@ -458,6 +460,22 @@ void Caches::endTiling() {
458460
}
459461
}
460462

463+
bool Caches::hasRegisteredFunctors() {
464+
return mFunctorsCount > 0;
465+
}
466+
467+
void Caches::registerFunctors(uint32_t functorCount) {
468+
mFunctorsCount += functorCount;
469+
}
470+
471+
void Caches::unregisterFunctors(uint32_t functorCount) {
472+
if (functorCount > mFunctorsCount) {
473+
mFunctorsCount = 0;
474+
} else {
475+
mFunctorsCount -= functorCount;
476+
}
477+
}
478+
461479
///////////////////////////////////////////////////////////////////////////////
462480
// Regions
463481
///////////////////////////////////////////////////////////////////////////////

libs/hwui/Caches.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ class ANDROID_API Caches: public Singleton<Caches> {
226226
void dumpMemoryUsage();
227227
void dumpMemoryUsage(String8& log);
228228

229+
bool hasRegisteredFunctors();
230+
void registerFunctors(uint32_t functorCount);
231+
void unregisterFunctors(uint32_t functorCount);
232+
229233
bool blend;
230234
GLenum lastSrcMode;
231235
GLenum lastDstMode;
@@ -316,6 +320,8 @@ class ANDROID_API Caches: public Singleton<Caches> {
316320

317321
DebugLevel mDebugLevel;
318322
bool mInitialized;
323+
324+
uint32_t mFunctorsCount;
319325
}; // class Caches
320326

321327
}; // namespace uirenderer

libs/hwui/DisplayListRenderer.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ void DisplayList::clearResources() {
157157
mAnimationMatrix = NULL;
158158

159159
Caches& caches = Caches::getInstance();
160+
caches.unregisterFunctors(mFunctorCount);
160161
caches.resourceCache.lock();
161162

162163
for (size_t i = 0; i < mBitmapResources.size(); i++) {
@@ -218,6 +219,7 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde
218219
init();
219220

220221
if (writer.size() == 0) {
222+
mFunctorCount = 0;
221223
return;
222224
}
223225

@@ -232,7 +234,10 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde
232234
writer.flatten(buffer);
233235
mReader.setMemory(buffer, mSize);
234236

237+
mFunctorCount = recorder.getFunctorCount();
238+
235239
Caches& caches = Caches::getInstance();
240+
caches.registerFunctors(mFunctorCount);
236241
caches.resourceCache.lock();
237242

238243
const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources();
@@ -1340,7 +1345,8 @@ status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flag
13401345

13411346
DisplayListRenderer::DisplayListRenderer():
13421347
mCaches(Caches::getInstance()), mWriter(MIN_WRITER_SIZE),
1343-
mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false), mHasDrawOps(false) {
1348+
mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false),
1349+
mHasDrawOps(false), mFunctorCount(0) {
13441350
}
13451351

13461352
DisplayListRenderer::~DisplayListRenderer() {
@@ -1397,6 +1403,7 @@ void DisplayListRenderer::reset() {
13971403
mLayers.clear();
13981404

13991405
mHasDrawOps = false;
1406+
mFunctorCount = 0;
14001407
}
14011408

14021409
///////////////////////////////////////////////////////////////////////////////
@@ -1453,6 +1460,7 @@ status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty)
14531460
// Ignore dirty during recording, it matters only when we replay
14541461
addOp(DisplayList::DrawGLFunction);
14551462
addInt((int) functor);
1463+
mFunctorCount++;
14561464
return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
14571465
}
14581466

libs/hwui/DisplayListRenderer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ class DisplayList {
503503
size_t mSize;
504504

505505
bool mIsRenderable;
506+
uint32_t mFunctorCount;
506507

507508
String8 mName;
508509

@@ -661,6 +662,10 @@ class DisplayListRenderer: public OpenGLRenderer {
661662
return mMatrices;
662663
}
663664

665+
uint32_t getFunctorCount() const {
666+
return mFunctorCount;
667+
}
668+
664669
private:
665670
void insertRestoreToCount() {
666671
if (mRestoreSaveCount >= 0) {
@@ -887,6 +892,8 @@ class DisplayListRenderer: public OpenGLRenderer {
887892
bool mHasTranslate;
888893
bool mHasDrawOps;
889894

895+
uint32_t mFunctorCount;
896+
890897
friend class DisplayList;
891898

892899
}; // class DisplayListRenderer

libs/hwui/OpenGLRenderer.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ int OpenGLRenderer::prepareDirty(float left, float top, float right, float botto
193193

194194
syncState();
195195

196+
// Functors break the tiling extension in pretty spectacular ways
197+
// This ensures we don't use tiling when a functor is going to be
198+
// invoked during the frame
199+
mSuppressTiling = mCaches.hasRegisteredFunctors();
200+
196201
mTilingSnapshot = mSnapshot;
197202
startTiling(mTilingSnapshot, true);
198203

@@ -221,17 +226,19 @@ void OpenGLRenderer::syncState() {
221226
}
222227

223228
void OpenGLRenderer::startTiling(const sp<Snapshot>& s, bool opaque) {
224-
Rect* clip = mTilingSnapshot->clipRect;
225-
if (s->flags & Snapshot::kFlagIsFboLayer) {
226-
clip = s->clipRect;
227-
}
229+
if (!mSuppressTiling) {
230+
Rect* clip = mTilingSnapshot->clipRect;
231+
if (s->flags & Snapshot::kFlagIsFboLayer) {
232+
clip = s->clipRect;
233+
}
228234

229-
mCaches.startTiling(clip->left, s->height - clip->bottom,
230-
clip->right - clip->left, clip->bottom - clip->top, opaque);
235+
mCaches.startTiling(clip->left, s->height - clip->bottom,
236+
clip->right - clip->left, clip->bottom - clip->top, opaque);
237+
}
231238
}
232239

233240
void OpenGLRenderer::endTiling() {
234-
mCaches.endTiling();
241+
if (!mSuppressTiling) mCaches.endTiling();
235242
}
236243

237244
void OpenGLRenderer::finish() {

libs/hwui/OpenGLRenderer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,9 @@ class OpenGLRenderer {
817817
// Properties.h
818818
bool mScissorOptimizationDisabled;
819819

820+
// No-ops start/endTiling when set
821+
bool mSuppressTiling;
822+
820823
friend class DisplayListRenderer;
821824

822825
}; // class OpenGLRenderer

libs/hwui/SkiaColorFilter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ SkiaColorFilter::~SkiaColorFilter() {
3636

3737
SkiaColorMatrixFilter::SkiaColorMatrixFilter(SkColorFilter* skFilter, float* matrix, float* vector):
3838
SkiaColorFilter(skFilter, kColorMatrix, true), mMatrix(matrix), mVector(vector) {
39+
// Skia uses the range [0..255] for the addition vector, but we need
40+
// the [0..1] range to apply the vector in GLSL
41+
for (int i = 0; i < 4; i++) {
42+
mVector[i] /= 255.0f;
43+
}
44+
3945
// TODO: We should be smarter about this
4046
mBlend = true;
4147
}

0 commit comments

Comments
 (0)