Skip to content

Commit 61d3704

Browse files
ChrisCraikAndroid (Google) Code Review
authored andcommitted
Merge "Polygonal rendering of simple fill shapes" into jb-mr1-dev
2 parents 739bc9e + 710f46d commit 61d3704

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
@@ -349,7 +349,7 @@ void LayerRenderer::flushLayer(Layer* layer) {
349349

350350
bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
351351
Caches& caches = Caches::getInstance();
352-
if (layer && layer->isTextureLayer() && bitmap->width() <= caches.maxTextureSize &&
352+
if (layer && bitmap->width() <= caches.maxTextureSize &&
353353
bitmap->height() <= caches.maxTextureSize) {
354354

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

363363
GLuint texture;
364364
GLuint previousFbo;
365+
GLuint previousViewport[4];
365366

366367
GLenum format;
367368
GLenum type;
@@ -391,11 +392,13 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
391392

392393
float alpha = layer->getAlpha();
393394
SkXfermode::Mode mode = layer->getMode();
395+
GLuint previousLayerFbo = layer->getFbo();
394396

395397
layer->setAlpha(255, SkXfermode::kSrc_Mode);
396398
layer->setFbo(fbo);
397399

398400
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &previousFbo);
401+
glGetIntegerv(GL_VIEWPORT, (GLint*) &previousViewport);
399402
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
400403

401404
glGenTextures(1, &texture);
@@ -463,9 +466,11 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
463466

464467
glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
465468
layer->setAlpha(alpha, mode);
466-
layer->setFbo(0);
469+
layer->setFbo(previousLayerFbo);
467470
glDeleteTextures(1, &texture);
468471
caches.fboCache.put(fbo);
472+
glViewport(previousViewport[0], previousViewport[1],
473+
previousViewport[2], previousViewport[3]);
469474

470475
return status;
471476
}

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)