Skip to content

Commit 8c43650

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Fix a couple of rendering issues Bug #7253839" into jb-mr1-dev
2 parents 07ddb46 + a3dc55f commit 8c43650

File tree

7 files changed

+33
-13
lines changed

7 files changed

+33
-13
lines changed

libs/hwui/DisplayListRenderer.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,8 @@ status_t DisplayListRenderer::drawLayer(Layer* layer, float x, float y, SkPaint*
15731573
}
15741574

15751575
status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
1576-
const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height());
1576+
const bool reject = quickRejectNoScissor(left, top,
1577+
left + bitmap->width(), top + bitmap->height());
15771578
uint32_t* location = addOp(DisplayList::DrawBitmap, reject);
15781579
addBitmap(bitmap);
15791580
addPoint(left, top);
@@ -1587,7 +1588,7 @@ status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkP
15871588
const mat4 transform(*matrix);
15881589
transform.mapRect(r);
15891590

1590-
const bool reject = quickReject(r.left, r.top, r.right, r.bottom);
1591+
const bool reject = quickRejectNoScissor(r.left, r.top, r.right, r.bottom);
15911592
uint32_t* location = addOp(DisplayList::DrawBitmapMatrix, reject);
15921593
addBitmap(bitmap);
15931594
addMatrix(matrix);
@@ -1599,7 +1600,7 @@ status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkP
15991600
status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
16001601
float srcRight, float srcBottom, float dstLeft, float dstTop,
16011602
float dstRight, float dstBottom, SkPaint* paint) {
1602-
const bool reject = quickReject(dstLeft, dstTop, dstRight, dstBottom);
1603+
const bool reject = quickRejectNoScissor(dstLeft, dstTop, dstRight, dstBottom);
16031604
uint32_t* location = addOp(DisplayList::DrawBitmapRect, reject);
16041605
addBitmap(bitmap);
16051606
addBounds(srcLeft, srcTop, srcRight, srcBottom);
@@ -1611,7 +1612,8 @@ status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float
16111612

16121613
status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
16131614
SkPaint* paint) {
1614-
const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height());
1615+
const bool reject = quickRejectNoScissor(left, top,
1616+
left + bitmap->width(), top + bitmap->height());
16151617
uint32_t* location = addOp(DisplayList::DrawBitmapData, reject);
16161618
addBitmapData(bitmap);
16171619
addPoint(left, top);
@@ -1644,7 +1646,7 @@ status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs,
16441646
SkXfermode::Mode mode;
16451647
OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
16461648

1647-
const bool reject = quickReject(left, top, right, bottom);
1649+
const bool reject = quickRejectNoScissor(left, top, right, bottom);
16481650
uint32_t* location = addOp(DisplayList::DrawPatch, reject);
16491651
addBitmap(bitmap);
16501652
addInts(xDivs, width);
@@ -1667,7 +1669,7 @@ status_t DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
16671669
status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
16681670
SkPaint* paint) {
16691671
const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
1670-
quickReject(left, top, right, bottom);
1672+
quickRejectNoScissor(left, top, right, bottom);
16711673
uint32_t* location = addOp(DisplayList::DrawRect, reject);
16721674
addBounds(left, top, right, bottom);
16731675
addPaint(paint);
@@ -1678,7 +1680,7 @@ status_t DisplayListRenderer::drawRect(float left, float top, float right, float
16781680
status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
16791681
float rx, float ry, SkPaint* paint) {
16801682
const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
1681-
quickReject(left, top, right, bottom);
1683+
quickRejectNoScissor(left, top, right, bottom);
16821684
uint32_t* location = addOp(DisplayList::DrawRoundRect, reject);
16831685
addBounds(left, top, right, bottom);
16841686
addPoint(rx, ry);
@@ -1721,7 +1723,7 @@ status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
17211723
left -= offset;
17221724
top -= offset;
17231725

1724-
const bool reject = quickReject(left, top, left + width, top + height);
1726+
const bool reject = quickRejectNoScissor(left, top, left + width, top + height);
17251727
uint32_t* location = addOp(DisplayList::DrawPath, reject);
17261728
addPath(path);
17271729
addPaint(paint);
@@ -1791,7 +1793,7 @@ status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int cou
17911793
if (CC_LIKELY(paint->getTextAlign() == SkPaint::kLeft_Align)) {
17921794
SkPaint::FontMetrics metrics;
17931795
paint->getFontMetrics(&metrics, 0.0f);
1794-
reject = quickReject(x, y + metrics.fTop, x + length, y + metrics.fBottom);
1796+
reject = quickRejectNoScissor(x, y + metrics.fTop, x + length, y + metrics.fBottom);
17951797
}
17961798

17971799
uint32_t* location = addOp(DisplayList::DrawText, reject);

libs/hwui/Matrix.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ bool Matrix4::isIdentity() const {
7373
return mIsIdentity;
7474
}
7575

76+
bool Matrix4::isPerspective() const {
77+
return data[kPerspective0] != 0.0f || data[kPerspective1] != 0.0f ||
78+
data[kPerspective2] != 1.0f;
79+
}
80+
7681
void Matrix4::load(const float* v) {
7782
memcpy(data, v, sizeof(data));
7883
// TODO: Do something smarter here

libs/hwui/Matrix.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class ANDROID_API Matrix4 {
115115
bool isPureTranslate() const;
116116
bool isSimple() const;
117117
bool isIdentity() const;
118+
bool isPerspective() const;
118119

119120
bool changesBounds() const;
120121

libs/hwui/OpenGLRenderer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,20 +2647,21 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
26472647
setupDrawShaderUniforms(pureTranslate);
26482648
setupDrawTextGammaUniforms();
26492649

2650-
const Rect* clip = pureTranslate ? mSnapshot->clipRect : &mSnapshot->getLocalClip();
2650+
const Rect* clip = pureTranslate ? mSnapshot->clipRect :
2651+
(mSnapshot->hasPerspectiveTransform() ? NULL : &mSnapshot->getLocalClip());
26512652
Rect bounds(FLT_MAX / 2.0f, FLT_MAX / 2.0f, FLT_MIN / 2.0f, FLT_MIN / 2.0f);
26522653

26532654
const bool hasActiveLayer = hasLayer();
26542655

26552656
bool status;
2656-
if (paint->getTextAlign() != SkPaint::kLeft_Align) {
2657+
if (CC_UNLIKELY(paint->getTextAlign() != SkPaint::kLeft_Align)) {
26572658
SkPaint paintCopy(*paint);
26582659
paintCopy.setTextAlign(SkPaint::kLeft_Align);
26592660
status = fontRenderer.renderPosText(&paintCopy, clip, text, 0, bytesCount, count, x, y,
2660-
positions, hasActiveLayer ? &bounds : NULL);
2661+
positions, hasActiveLayer ? &bounds : NULL);
26612662
} else {
26622663
status = fontRenderer.renderPosText(paint, clip, text, 0, bytesCount, count, x, y,
2663-
positions, hasActiveLayer ? &bounds : NULL);
2664+
positions, hasActiveLayer ? &bounds : NULL);
26642665
}
26652666

26662667
if (status && hasActiveLayer) {

libs/hwui/Snapshot.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ void Snapshot::setClip(float left, float top, float right, float bottom) {
178178
flags |= Snapshot::kFlagClipSet;
179179
}
180180

181+
bool Snapshot::hasPerspectiveTransform() const {
182+
return transform->isPerspective();
183+
}
184+
181185
const Rect& Snapshot::getLocalClip() {
182186
mat4 inverse;
183187
inverse.loadInverse(*transform);

libs/hwui/Snapshot.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ class Snapshot: public LightRefBase<Snapshot> {
120120
*/
121121
bool isIgnored() const;
122122

123+
/**
124+
* Indicates whether the current transform has perspective components.
125+
*/
126+
bool hasPerspectiveTransform() const;
127+
123128
/**
124129
* Dirty flags.
125130
*/

libs/hwui/font/Font.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
#define LOG_TAG "OpenGLRenderer"
18+
1719
#include <cutils/compiler.h>
1820

1921
#include <SkUtils.h>

0 commit comments

Comments
 (0)