* commit '4c97ef9094f7a52dbc983ed12ce5f3b586f2d769': Add support for QCOM_tiled_rendering Bug #7186819
This commit is contained in:
@@ -1136,9 +1136,8 @@ public abstract class HardwareRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int status = onPreDraw(dirty);
|
int saveCount = 0;
|
||||||
int saveCount = canvas.save();
|
int status = DisplayList.STATUS_DONE;
|
||||||
callbacks.onHardwarePreDraw(canvas);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
view.mRecreateDisplayList = (view.mPrivateFlags & View.PFLAG_INVALIDATED)
|
view.mRecreateDisplayList = (view.mPrivateFlags & View.PFLAG_INVALIDATED)
|
||||||
@@ -1164,6 +1163,10 @@ public abstract class HardwareRenderer {
|
|||||||
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
|
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status = onPreDraw(dirty);
|
||||||
|
saveCount = canvas.save();
|
||||||
|
callbacks.onHardwarePreDraw(canvas);
|
||||||
|
|
||||||
if (mProfileEnabled) {
|
if (mProfileEnabled) {
|
||||||
long now = System.nanoTime();
|
long now = System.nanoTime();
|
||||||
float total = (now - getDisplayListStartTime) * 0.000001f;
|
float total = (now - getDisplayListStartTime) * 0.000001f;
|
||||||
|
|||||||
@@ -429,13 +429,13 @@ void Caches::resetScissor() {
|
|||||||
|
|
||||||
void Caches::startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool opaque) {
|
void Caches::startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool opaque) {
|
||||||
if (extensions.hasTiledRendering()) {
|
if (extensions.hasTiledRendering()) {
|
||||||
|
glStartTilingQCOM(x, y, width, height, GL_COLOR_BUFFER_BIT0_QCOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Caches::endTiling() {
|
void Caches::endTiling() {
|
||||||
if (extensions.hasTiledRendering()) {
|
if (extensions.hasTiledRendering()) {
|
||||||
|
glEndTilingQCOM(GL_COLOR_BUFFER_BIT0_QCOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ int OpenGLRenderer::prepareDirty(float left, float top, float right, float botto
|
|||||||
mSaveCount = 1;
|
mSaveCount = 1;
|
||||||
|
|
||||||
mSnapshot->setClip(left, top, right, bottom);
|
mSnapshot->setClip(left, top, right, bottom);
|
||||||
mDirtyClip = opaque;
|
mDirtyClip = mOpaqueFrame = opaque;
|
||||||
|
|
||||||
// If we know that we are going to redraw the entire framebuffer,
|
// If we know that we are going to redraw the entire framebuffer,
|
||||||
// perform a discard to let the driver know we don't need to preserve
|
// perform a discard to let the driver know we don't need to preserve
|
||||||
@@ -188,6 +188,9 @@ int OpenGLRenderer::prepareDirty(float left, float top, float right, float botto
|
|||||||
|
|
||||||
syncState();
|
syncState();
|
||||||
|
|
||||||
|
mTilingSnapshot = mSnapshot;
|
||||||
|
startTiling();
|
||||||
|
|
||||||
if (!opaque) {
|
if (!opaque) {
|
||||||
mCaches.enableScissor();
|
mCaches.enableScissor();
|
||||||
mCaches.setScissor(left, mSnapshot->height - bottom, right - left, bottom - top);
|
mCaches.setScissor(left, mSnapshot->height - bottom, right - left, bottom - top);
|
||||||
@@ -210,7 +213,30 @@ void OpenGLRenderer::syncState() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLRenderer::startTiling() {
|
||||||
|
startTiling(mTilingSnapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLRenderer::startTiling(const sp<Snapshot>& s) {
|
||||||
|
bool opaque = mOpaqueFrame;
|
||||||
|
Rect* clip = mTilingSnapshot->clipRect;
|
||||||
|
|
||||||
|
if (s->flags & Snapshot::kFlagIsFboLayer) {
|
||||||
|
opaque = !s->layer->isBlend();
|
||||||
|
clip = s->clipRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCaches.startTiling(clip->left, s->height - clip->bottom,
|
||||||
|
clip->right - clip->left, clip->bottom - clip->top, opaque);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLRenderer::endTiling() {
|
||||||
|
mCaches.endTiling();
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::finish() {
|
void OpenGLRenderer::finish() {
|
||||||
|
endTiling();
|
||||||
|
|
||||||
#if DEBUG_OPENGL
|
#if DEBUG_OPENGL
|
||||||
GLenum status = GL_NO_ERROR;
|
GLenum status = GL_NO_ERROR;
|
||||||
while ((status = glGetError()) != GL_NO_ERROR) {
|
while ((status = glGetError()) != GL_NO_ERROR) {
|
||||||
@@ -637,6 +663,7 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip, GLui
|
|||||||
mSnapshot->flags |= Snapshot::kFlagDirtyOrtho;
|
mSnapshot->flags |= Snapshot::kFlagDirtyOrtho;
|
||||||
mSnapshot->orthoMatrix.load(mOrthoMatrix);
|
mSnapshot->orthoMatrix.load(mOrthoMatrix);
|
||||||
|
|
||||||
|
endTiling();
|
||||||
// Bind texture to FBO
|
// Bind texture to FBO
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, layer->getFbo());
|
glBindFramebuffer(GL_FRAMEBUFFER, layer->getFbo());
|
||||||
layer->bindTexture();
|
layer->bindTexture();
|
||||||
@@ -650,18 +677,7 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip, GLui
|
|||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||||
layer->getTexture(), 0);
|
layer->getTexture(), 0);
|
||||||
|
|
||||||
#if DEBUG_LAYERS_AS_REGIONS
|
startTiling(mSnapshot);
|
||||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
|
||||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
|
||||||
ALOGE("Framebuffer incomplete (GL error code 0x%x)", status);
|
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
|
|
||||||
|
|
||||||
Caches::getInstance().resourceCache.decrementRefcount(layer);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Clear the FBO, expand the clear region by 1 to get nice bilinear filtering
|
// Clear the FBO, expand the clear region by 1 to get nice bilinear filtering
|
||||||
mCaches.enableScissor();
|
mCaches.enableScissor();
|
||||||
@@ -690,11 +706,14 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) {
|
|||||||
const bool fboLayer = current->flags & Snapshot::kFlagIsFboLayer;
|
const bool fboLayer = current->flags & Snapshot::kFlagIsFboLayer;
|
||||||
|
|
||||||
if (fboLayer) {
|
if (fboLayer) {
|
||||||
|
endTiling();
|
||||||
|
|
||||||
// Detach the texture from the FBO
|
// Detach the texture from the FBO
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
||||||
|
|
||||||
// Unbind current FBO and restore previous one
|
// Unbind current FBO and restore previous one
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, previous->fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, previous->fbo);
|
||||||
|
|
||||||
|
startTiling(previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer* layer = current->layer;
|
Layer* layer = current->layer;
|
||||||
@@ -2621,12 +2640,15 @@ status_t OpenGLRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* pain
|
|||||||
OpenGLRenderer* renderer = layer->renderer;
|
OpenGLRenderer* renderer = layer->renderer;
|
||||||
Rect& dirty = layer->dirtyRect;
|
Rect& dirty = layer->dirtyRect;
|
||||||
|
|
||||||
|
endTiling();
|
||||||
|
|
||||||
renderer->setViewport(layer->layer.getWidth(), layer->layer.getHeight());
|
renderer->setViewport(layer->layer.getWidth(), layer->layer.getHeight());
|
||||||
renderer->prepareDirty(dirty.left, dirty.top, dirty.right, dirty.bottom, !layer->isBlend());
|
renderer->prepareDirty(dirty.left, dirty.top, dirty.right, dirty.bottom, !layer->isBlend());
|
||||||
renderer->drawDisplayList(layer->displayList, dirty, DisplayList::kReplayFlag_ClipChildren);
|
renderer->drawDisplayList(layer->displayList, dirty, DisplayList::kReplayFlag_ClipChildren);
|
||||||
renderer->finish();
|
renderer->finish();
|
||||||
|
|
||||||
resumeAfterLayer();
|
resumeAfterLayer();
|
||||||
|
startTiling(mSnapshot);
|
||||||
|
|
||||||
dirty.setEmpty();
|
dirty.setEmpty();
|
||||||
layer->deferredUpdateScheduled = false;
|
layer->deferredUpdateScheduled = false;
|
||||||
|
|||||||
@@ -346,6 +346,20 @@ private:
|
|||||||
*/
|
*/
|
||||||
void syncState();
|
void syncState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells the GPU what part of the screen is about to be redrawn.
|
||||||
|
* This method needs to be invoked every time getTargetFbo() is
|
||||||
|
* bound again.
|
||||||
|
*/
|
||||||
|
void startTiling();
|
||||||
|
void startTiling(const sp<Snapshot>& snapshot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells the GPU that we are done drawing the frame or that we
|
||||||
|
* are switching to another render target.
|
||||||
|
*/
|
||||||
|
void endTiling();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the current state of the renderer as a new snapshot.
|
* Saves the current state of the renderer as a new snapshot.
|
||||||
* The new snapshot is saved in mSnapshot and the previous snapshot
|
* The new snapshot is saved in mSnapshot and the previous snapshot
|
||||||
@@ -735,6 +749,8 @@ private:
|
|||||||
sp<Snapshot> mFirstSnapshot;
|
sp<Snapshot> mFirstSnapshot;
|
||||||
// Current state
|
// Current state
|
||||||
sp<Snapshot> mSnapshot;
|
sp<Snapshot> mSnapshot;
|
||||||
|
// State used to define the clipping region
|
||||||
|
sp<Snapshot> mTilingSnapshot;
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
SkiaShader* mShader;
|
SkiaShader* mShader;
|
||||||
@@ -784,6 +800,8 @@ private:
|
|||||||
GLuint mTextureUnit;
|
GLuint mTextureUnit;
|
||||||
// Track dirty regions, true by default
|
// Track dirty regions, true by default
|
||||||
bool mTrackDirtyRegions;
|
bool mTrackDirtyRegions;
|
||||||
|
// Indicate whether we are drawing an opaque frame
|
||||||
|
bool mOpaqueFrame;
|
||||||
|
|
||||||
friend class DisplayListRenderer;
|
friend class DisplayListRenderer;
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
android:fadingEdgeLength="16sp"
|
android:fadingEdgeLength="16sp"
|
||||||
android:fadingEdge="horizontal"
|
android:fadingEdge="horizontal"
|
||||||
|
android:requiresFadingEdge="horizontal"
|
||||||
android:text="This is a really really really really really really long string"
|
android:text="This is a really really really really really really long string"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import android.content.Context;
|
|||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"})
|
@SuppressWarnings({"UnusedDeclaration"})
|
||||||
public class TextFadeActivity extends Activity {
|
public class TextFadeActivity extends Activity {
|
||||||
@@ -30,5 +32,8 @@ public class TextFadeActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.text_fade);
|
setContentView(R.layout.text_fade);
|
||||||
|
|
||||||
|
findViewById(R.id.contact_tile_name).setHorizontalFadingEdgeEnabled(true);
|
||||||
|
((TextView) findViewById(R.id.contact_tile_name)).setEllipsize(TextUtils.TruncateAt.MARQUEE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,11 +81,14 @@ public class ViewLayersActivity extends Activity {
|
|||||||
leftList.setAlpha(0.5f);
|
leftList.setAlpha(0.5f);
|
||||||
middleList.setLayerType(View.LAYER_TYPE_HARDWARE, p3);
|
middleList.setLayerType(View.LAYER_TYPE_HARDWARE, p3);
|
||||||
middleList.setAlpha(0.5f);
|
middleList.setAlpha(0.5f);
|
||||||
|
middleList.setVerticalFadingEdgeEnabled(true);
|
||||||
rightList.setLayerType(View.LAYER_TYPE_SOFTWARE, p2);
|
rightList.setLayerType(View.LAYER_TYPE_SOFTWARE, p2);
|
||||||
|
|
||||||
moveRight.start();
|
moveRight.start();
|
||||||
moveLeft.start();
|
moveLeft.start();
|
||||||
rotate.start();
|
rotate.start();
|
||||||
|
|
||||||
|
((View) leftList.getParent()).setAlpha(0.5f);
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user