Skip to content

Commit 710f46d

Browse files
committed
Polygonal rendering of simple fill shapes
bug:4419017 Change-Id: If0428e1732139786cba15f54b285d880e4a56b89
1 parent 5ca88a1 commit 710f46d

File tree

10 files changed

+581
-207
lines changed

10 files changed

+581
-207
lines changed

libs/hwui/Android.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ifeq ($(USE_OPENGL_RENDERER),true)
2121
LayerRenderer.cpp \
2222
Matrix.cpp \
2323
OpenGLRenderer.cpp \
24+
PathRenderer.cpp \
2425
Patch.cpp \
2526
PatchCache.cpp \
2627
PathCache.cpp \
@@ -34,7 +35,7 @@ ifeq ($(USE_OPENGL_RENDERER),true)
3435
Stencil.cpp \
3536
TextureCache.cpp \
3637
TextDropShadowCache.cpp
37-
38+
3839
LOCAL_C_INCLUDES += \
3940
$(JNI_H_INCLUDE) \
4041
$(LOCAL_PATH)/../../include/utils \

libs/hwui/LayerRenderer.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ void LayerRenderer::flushLayer(Layer* layer) {
345345

346346
bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
347347
Caches& caches = Caches::getInstance();
348-
if (layer && layer->isTextureLayer() && bitmap->width() <= caches.maxTextureSize &&
348+
if (layer && bitmap->width() <= caches.maxTextureSize &&
349349
bitmap->height() <= caches.maxTextureSize) {
350350

351351
GLuint fbo = caches.fboCache.get();
@@ -358,6 +358,7 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
358358

359359
GLuint texture;
360360
GLuint previousFbo;
361+
GLuint previousViewport[4];
361362

362363
GLenum format;
363364
GLenum type;
@@ -387,11 +388,13 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
387388

388389
float alpha = layer->getAlpha();
389390
SkXfermode::Mode mode = layer->getMode();
391+
GLuint previousLayerFbo = layer->getFbo();
390392

391393
layer->setAlpha(255, SkXfermode::kSrc_Mode);
392394
layer->setFbo(fbo);
393395

394396
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &previousFbo);
397+
glGetIntegerv(GL_VIEWPORT, (GLint*) &previousViewport);
395398
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
396399

397400
glGenTextures(1, &texture);
@@ -459,9 +462,11 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
459462

460463
glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
461464
layer->setAlpha(alpha, mode);
462-
layer->setFbo(0);
465+
layer->setFbo(previousLayerFbo);
463466
glDeleteTextures(1, &texture);
464467
caches.fboCache.put(fbo);
468+
glViewport(previousViewport[0], previousViewport[1],
469+
previousViewport[2], previousViewport[3]);
465470

466471
return status;
467472
}

libs/hwui/Matrix.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ void Matrix4::loadIdentity() {
5555
mSimpleMatrix = true;
5656
}
5757

58-
bool Matrix4::changesBounds() {
58+
bool Matrix4::changesBounds() const {
5959
return !(data[0] == 1.0f && data[1] == 0.0f && data[2] == 0.0f && data[4] == 0.0f &&
6060
data[5] == 1.0f && data[6] == 0.0f && data[8] == 0.0f && data[9] == 0.0f &&
6161
data[10] == 1.0f);
6262
}
6363

64-
bool Matrix4::isPureTranslate() {
64+
bool Matrix4::isPureTranslate() const {
6565
return mSimpleMatrix && data[kScaleX] == 1.0f && data[kScaleY] == 1.0f;
6666
}
6767

68-
bool Matrix4::isSimple() {
68+
bool Matrix4::isSimple() const {
6969
return mSimpleMatrix;
7070
}
7171

72-
bool Matrix4::isIdentity() {
72+
bool Matrix4::isIdentity() const {
7373
return mIsIdentity;
7474
}
7575

libs/hwui/Matrix.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ class ANDROID_API Matrix4 {
112112
multiply(u);
113113
}
114114

115-
bool isPureTranslate();
116-
bool isSimple();
117-
bool isIdentity();
115+
bool isPureTranslate() const;
116+
bool isSimple() const;
117+
bool isIdentity() const;
118118

119-
bool changesBounds();
119+
bool changesBounds() const;
120120

121121
void copyTo(float* v) const;
122122
void copyTo(SkMatrix& v) const;

0 commit comments

Comments
 (0)