Skip to content

Commit

Permalink
Add tile dimensions into snapshot and use it for setting tile rect
Browse files Browse the repository at this point in the history
Current tile rendering implementation in hwui sets the current
clip rect as tile rect during restore. This will limit the rendering
to the restored clip rect. Later in case if the app tries to render
outside the tile rect by setting a new clip rect, then all the pixels,
which are falling outside the tile rect are clipped off, this may result
into UI artifacats. This change adds the support for preserving the tile
clip as part of the snapshot and the same tile clip is used while
setting the tile rect. This way it is taken care that the correct tile
dimensions are preserved during save and retrieved during restore.

CRs-Fixed: 499767
Change-Id: Ia66b6dc8e7be5857949751a81e9f702c2d1c5a57
  • Loading branch information
Sreedhar Telukuntla authored and Gerrit Code Review committed Jul 23, 2013
1 parent aa18a86 commit 3307cd4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libs/hwui/DisplayListRenderer.cpp
Expand Up @@ -1442,6 +1442,9 @@ status_t DisplayListRenderer::prepareDirty(float left, float top,
mSaveCount = 1;

mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
#ifdef QCOM_HARDWARE
mSnapshot->setTileClip(0.0f, 0.0f, mWidth, mHeight);
#endif
mDirtyClip = opaque;

mRestoreSaveCount = -1;
Expand Down
11 changes: 10 additions & 1 deletion libs/hwui/OpenGLRenderer.cpp
Expand Up @@ -179,6 +179,9 @@ status_t OpenGLRenderer::prepareDirty(float left, float top, float right, float
mSaveCount = 1;

mSnapshot->setClip(left, top, right, bottom);
#ifdef QCOM_HARDWARE
mSnapshot->setTileClip(left, top, right, bottom);
#endif
mDirtyClip = true;

updateLayers();
Expand Down Expand Up @@ -246,11 +249,14 @@ void OpenGLRenderer::syncState() {

void OpenGLRenderer::startTiling(const sp<Snapshot>& s, bool opaque) {
if (!mSuppressTiling) {
#ifdef QCOM_HARDWARE
const Rect* clip = &mSnapshot->getTileClip();
#else
Rect* clip = mTilingSnapshot->clipRect;
if (s->flags & Snapshot::kFlagIsFboLayer) {
clip = s->clipRect;
}

#endif
mCaches.startTiling(clip->left, s->height - clip->bottom,
clip->right - clip->left, clip->bottom - clip->top, opaque);
}
Expand Down Expand Up @@ -800,6 +806,9 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip, GLui
mSnapshot->fbo = layer->getFbo();
mSnapshot->resetTransform(-bounds.left, -bounds.top, 0.0f);
mSnapshot->resetClip(clip.left, clip.top, clip.right, clip.bottom);
#ifdef QCOM_HARDWARE
mSnapshot->setTileClip(clip.left, clip.top, clip.right, clip.bottom);
#endif
mSnapshot->viewport.set(0.0f, 0.0f, bounds.getWidth(), bounds.getHeight());
mSnapshot->height = bounds.getHeight();
mSnapshot->flags |= Snapshot::kFlagDirtyOrtho;
Expand Down
13 changes: 13 additions & 0 deletions libs/hwui/Snapshot.cpp
Expand Up @@ -74,6 +74,9 @@ Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags):
} else {
region = NULL;
}
#ifdef QCOM_HARDWARE
mTileClip.set(s->getTileClip());
#endif
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -192,6 +195,16 @@ const Rect& Snapshot::getLocalClip() {
return mLocalClip;
}

#ifdef QCOM_HARDWARE
void Snapshot::setTileClip(float left, float top, float right, float bottom) {
mTileClip.set(left, top, right, bottom);
}

const Rect& Snapshot::getTileClip() {
return mTileClip;
}
#endif

void Snapshot::resetClip(float left, float top, float right, float bottom) {
clipRect = &mClipRectRoot;
setClip(left, top, right, bottom);
Expand Down
15 changes: 15 additions & 0 deletions libs/hwui/Snapshot.h
Expand Up @@ -104,6 +104,18 @@ class Snapshot: public LightRefBase<Snapshot> {
*/
const Rect& getLocalClip();

#ifdef QCOM_HARDWARE
/**
* Sets the current tile clip.
*/
void setTileClip(float left, float top, float right, float bottom);

/**
* Returns the current tile clip in local coordinates.
*/
const Rect& getTileClip();
#endif

/**
* Resets the clip to the specified rect.
*/
Expand Down Expand Up @@ -233,6 +245,9 @@ class Snapshot: public LightRefBase<Snapshot> {
mat4 mTransformRoot;
Rect mClipRectRoot;
Rect mLocalClip;
#ifdef QCOM_HARDWARE
Rect mTileClip;
#endif

#if STENCIL_BUFFER_SIZE
SkRegion mClipRegionRoot;
Expand Down

0 comments on commit 3307cd4

Please sign in to comment.