Loading libs/hwui/DisplayListRenderer.cpp +3 −0 Original line number Original line Diff line number Diff line Loading @@ -57,6 +57,9 @@ DisplayListData* DisplayListRenderer::finishRecording() { } } void DisplayListRenderer::setViewport(int width, int height) { void DisplayListRenderer::setViewport(int width, int height) { // TODO: DisplayListRenderer shouldn't have a projection matrix, as it should never be used mProjectionMatrix.loadOrtho(0, width, height, 0, -1, 1); initializeViewport(width, height); initializeViewport(width, height); } } Loading libs/hwui/OpenGLRenderer.cpp +15 −13 Original line number Original line Diff line number Diff line Loading @@ -171,7 +171,7 @@ void OpenGLRenderer::setViewport(int width, int height) { } } void OpenGLRenderer::initViewport(int width, int height) { void OpenGLRenderer::initViewport(int width, int height) { mSnapshot->orthoMatrix.loadOrtho(0, width, height, 0, -1, 1); mProjectionMatrix.loadOrtho(0, width, height, 0, -1, 1); initializeViewport(width, height); initializeViewport(width, height); } } Loading Loading @@ -621,13 +621,14 @@ void OpenGLRenderer::flushLayerUpdates() { /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void OpenGLRenderer::onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) { void OpenGLRenderer::onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) { bool restoreViewport = removed.flags & Snapshot::kFlagIsFboLayer; bool restoreOrtho = removed.flags & Snapshot::kFlagDirtyOrtho; bool restoreClip = removed.flags & Snapshot::kFlagClipSet; bool restoreClip = removed.flags & Snapshot::kFlagClipSet; bool restoreLayer = removed.flags & Snapshot::kFlagIsLayer; bool restoreLayer = removed.flags & Snapshot::kFlagIsLayer; if (restoreViewport) { if (restoreOrtho) { const Rect& r = restored.viewport; const Rect& r = restored.viewport; glViewport(r.left, r.top, r.right, r.bottom); glViewport(r.left, r.top, r.right, r.bottom); mProjectionMatrix.load(removed.orthoMatrix); // TODO: should ortho be stored in 'restored'? } } if (restoreClip) { if (restoreClip) { Loading Loading @@ -846,12 +847,14 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip) { layer->setFbo(mCaches.fboCache.get()); layer->setFbo(mCaches.fboCache.get()); mSnapshot->region = &mSnapshot->layer->region; mSnapshot->region = &mSnapshot->layer->region; mSnapshot->flags |= Snapshot::kFlagFboTarget | Snapshot::kFlagIsFboLayer; mSnapshot->flags |= Snapshot::kFlagFboTarget | Snapshot::kFlagIsFboLayer | Snapshot::kFlagDirtyOrtho; mSnapshot->fbo = layer->getFbo(); mSnapshot->fbo = layer->getFbo(); mSnapshot->resetTransform(-bounds.left, -bounds.top, 0.0f); mSnapshot->resetTransform(-bounds.left, -bounds.top, 0.0f); mSnapshot->resetClip(clip.left, clip.top, clip.right, clip.bottom); mSnapshot->resetClip(clip.left, clip.top, clip.right, clip.bottom); mSnapshot->viewport.set(0.0f, 0.0f, bounds.getWidth(), bounds.getHeight()); mSnapshot->viewport.set(0.0f, 0.0f, bounds.getWidth(), bounds.getHeight()); mSnapshot->height = bounds.getHeight(); mSnapshot->height = bounds.getHeight(); mSnapshot->orthoMatrix.load(mProjectionMatrix); endTiling(); endTiling(); debugOverdraw(false, false); debugOverdraw(false, false); Loading Loading @@ -880,7 +883,8 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip) { // Change the ortho projection // Change the ortho projection glViewport(0, 0, bounds.getWidth(), bounds.getHeight()); glViewport(0, 0, bounds.getWidth(), bounds.getHeight()); mSnapshot->orthoMatrix.loadOrtho(0.0f, bounds.getWidth(), bounds.getHeight(), 0.0f, -1.0f, 1.0f); mProjectionMatrix.loadOrtho(0.0f, bounds.getWidth(), bounds.getHeight(), 0.0f, -1.0f, 1.0f); return true; return true; } } Loading Loading @@ -1690,14 +1694,12 @@ void OpenGLRenderer::setupDrawModelView(ModelViewMode mode, bool offset, } } bool dirty = right - left > 0.0f && bottom - top > 0.0f; bool dirty = right - left > 0.0f && bottom - top > 0.0f; const Matrix4& transformMatrix = ignoreTransform ? Matrix4::identity() : *currentTransform(); mCaches.currentProgram->set(mSnapshot->orthoMatrix, mModelViewMatrix, transformMatrix, offset); if (dirty && mTrackDirtyRegions) { if (!ignoreTransform) { if (!ignoreTransform) { dirtyLayer(left, top, right, bottom, *currentTransform()); mCaches.currentProgram->set(mProjectionMatrix, mModelViewMatrix, *currentTransform(), offset); if (dirty && mTrackDirtyRegions) dirtyLayer(left, top, right, bottom, *currentTransform()); } else { } else { dirtyLayer(left, top, right, bottom); mCaches.currentProgram->set(mProjectionMatrix, mModelViewMatrix, mat4::identity(), offset); } if (dirty && mTrackDirtyRegions) dirtyLayer(left, top, right, bottom); } } } } Loading libs/hwui/OpenGLRenderer.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -930,6 +930,9 @@ private: */ */ Texture* getTexture(const SkBitmap* bitmap); Texture* getTexture(const SkBitmap* bitmap); // Ortho matrix used for projection in shaders mat4 mProjectionMatrix; /** /** * Model-view matrix used to position/size objects * Model-view matrix used to position/size objects * * Loading libs/hwui/Snapshot.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -55,7 +55,6 @@ Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags) , empty(false) , empty(false) , viewport(s->viewport) , viewport(s->viewport) , height(s->height) , height(s->height) , orthoMatrix(s->orthoMatrix) , alpha(s->alpha) { , alpha(s->alpha) { if (saveFlags & SkCanvas::kMatrix_SaveFlag) { if (saveFlags & SkCanvas::kMatrix_SaveFlag) { Loading libs/hwui/Snapshot.h +6 −5 Original line number Original line Diff line number Diff line Loading @@ -65,16 +65,17 @@ public: * Indicates that this snapshot is a special type of layer * Indicates that this snapshot is a special type of layer * backed by an FBO. This flag only makes sense when the * backed by an FBO. This flag only makes sense when the * flag kFlagIsLayer is also set. * flag kFlagIsLayer is also set. * * Viewport has been modified to fit the new Fbo, and must be * restored when this snapshot is restored. */ */ kFlagIsFboLayer = 0x4, kFlagIsFboLayer = 0x4, /** * Indicates that this snapshot has changed the ortho matrix. */ kFlagDirtyOrtho = 0x8, /** /** * Indicates that this snapshot or an ancestor snapshot is * Indicates that this snapshot or an ancestor snapshot is * an FBO layer. * an FBO layer. */ */ kFlagFboTarget = 0x8, kFlagFboTarget = 0x10 }; }; /** /** Loading Loading @@ -182,7 +183,7 @@ public: int height; int height; /** /** * Contains the current orthographic, projection matrix. * Contains the previous ortho matrix. */ */ mat4 orthoMatrix; mat4 orthoMatrix; Loading Loading
libs/hwui/DisplayListRenderer.cpp +3 −0 Original line number Original line Diff line number Diff line Loading @@ -57,6 +57,9 @@ DisplayListData* DisplayListRenderer::finishRecording() { } } void DisplayListRenderer::setViewport(int width, int height) { void DisplayListRenderer::setViewport(int width, int height) { // TODO: DisplayListRenderer shouldn't have a projection matrix, as it should never be used mProjectionMatrix.loadOrtho(0, width, height, 0, -1, 1); initializeViewport(width, height); initializeViewport(width, height); } } Loading
libs/hwui/OpenGLRenderer.cpp +15 −13 Original line number Original line Diff line number Diff line Loading @@ -171,7 +171,7 @@ void OpenGLRenderer::setViewport(int width, int height) { } } void OpenGLRenderer::initViewport(int width, int height) { void OpenGLRenderer::initViewport(int width, int height) { mSnapshot->orthoMatrix.loadOrtho(0, width, height, 0, -1, 1); mProjectionMatrix.loadOrtho(0, width, height, 0, -1, 1); initializeViewport(width, height); initializeViewport(width, height); } } Loading Loading @@ -621,13 +621,14 @@ void OpenGLRenderer::flushLayerUpdates() { /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void OpenGLRenderer::onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) { void OpenGLRenderer::onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) { bool restoreViewport = removed.flags & Snapshot::kFlagIsFboLayer; bool restoreOrtho = removed.flags & Snapshot::kFlagDirtyOrtho; bool restoreClip = removed.flags & Snapshot::kFlagClipSet; bool restoreClip = removed.flags & Snapshot::kFlagClipSet; bool restoreLayer = removed.flags & Snapshot::kFlagIsLayer; bool restoreLayer = removed.flags & Snapshot::kFlagIsLayer; if (restoreViewport) { if (restoreOrtho) { const Rect& r = restored.viewport; const Rect& r = restored.viewport; glViewport(r.left, r.top, r.right, r.bottom); glViewport(r.left, r.top, r.right, r.bottom); mProjectionMatrix.load(removed.orthoMatrix); // TODO: should ortho be stored in 'restored'? } } if (restoreClip) { if (restoreClip) { Loading Loading @@ -846,12 +847,14 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip) { layer->setFbo(mCaches.fboCache.get()); layer->setFbo(mCaches.fboCache.get()); mSnapshot->region = &mSnapshot->layer->region; mSnapshot->region = &mSnapshot->layer->region; mSnapshot->flags |= Snapshot::kFlagFboTarget | Snapshot::kFlagIsFboLayer; mSnapshot->flags |= Snapshot::kFlagFboTarget | Snapshot::kFlagIsFboLayer | Snapshot::kFlagDirtyOrtho; mSnapshot->fbo = layer->getFbo(); mSnapshot->fbo = layer->getFbo(); mSnapshot->resetTransform(-bounds.left, -bounds.top, 0.0f); mSnapshot->resetTransform(-bounds.left, -bounds.top, 0.0f); mSnapshot->resetClip(clip.left, clip.top, clip.right, clip.bottom); mSnapshot->resetClip(clip.left, clip.top, clip.right, clip.bottom); mSnapshot->viewport.set(0.0f, 0.0f, bounds.getWidth(), bounds.getHeight()); mSnapshot->viewport.set(0.0f, 0.0f, bounds.getWidth(), bounds.getHeight()); mSnapshot->height = bounds.getHeight(); mSnapshot->height = bounds.getHeight(); mSnapshot->orthoMatrix.load(mProjectionMatrix); endTiling(); endTiling(); debugOverdraw(false, false); debugOverdraw(false, false); Loading Loading @@ -880,7 +883,8 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip) { // Change the ortho projection // Change the ortho projection glViewport(0, 0, bounds.getWidth(), bounds.getHeight()); glViewport(0, 0, bounds.getWidth(), bounds.getHeight()); mSnapshot->orthoMatrix.loadOrtho(0.0f, bounds.getWidth(), bounds.getHeight(), 0.0f, -1.0f, 1.0f); mProjectionMatrix.loadOrtho(0.0f, bounds.getWidth(), bounds.getHeight(), 0.0f, -1.0f, 1.0f); return true; return true; } } Loading Loading @@ -1690,14 +1694,12 @@ void OpenGLRenderer::setupDrawModelView(ModelViewMode mode, bool offset, } } bool dirty = right - left > 0.0f && bottom - top > 0.0f; bool dirty = right - left > 0.0f && bottom - top > 0.0f; const Matrix4& transformMatrix = ignoreTransform ? Matrix4::identity() : *currentTransform(); mCaches.currentProgram->set(mSnapshot->orthoMatrix, mModelViewMatrix, transformMatrix, offset); if (dirty && mTrackDirtyRegions) { if (!ignoreTransform) { if (!ignoreTransform) { dirtyLayer(left, top, right, bottom, *currentTransform()); mCaches.currentProgram->set(mProjectionMatrix, mModelViewMatrix, *currentTransform(), offset); if (dirty && mTrackDirtyRegions) dirtyLayer(left, top, right, bottom, *currentTransform()); } else { } else { dirtyLayer(left, top, right, bottom); mCaches.currentProgram->set(mProjectionMatrix, mModelViewMatrix, mat4::identity(), offset); } if (dirty && mTrackDirtyRegions) dirtyLayer(left, top, right, bottom); } } } } Loading
libs/hwui/OpenGLRenderer.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -930,6 +930,9 @@ private: */ */ Texture* getTexture(const SkBitmap* bitmap); Texture* getTexture(const SkBitmap* bitmap); // Ortho matrix used for projection in shaders mat4 mProjectionMatrix; /** /** * Model-view matrix used to position/size objects * Model-view matrix used to position/size objects * * Loading
libs/hwui/Snapshot.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -55,7 +55,6 @@ Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags) , empty(false) , empty(false) , viewport(s->viewport) , viewport(s->viewport) , height(s->height) , height(s->height) , orthoMatrix(s->orthoMatrix) , alpha(s->alpha) { , alpha(s->alpha) { if (saveFlags & SkCanvas::kMatrix_SaveFlag) { if (saveFlags & SkCanvas::kMatrix_SaveFlag) { Loading
libs/hwui/Snapshot.h +6 −5 Original line number Original line Diff line number Diff line Loading @@ -65,16 +65,17 @@ public: * Indicates that this snapshot is a special type of layer * Indicates that this snapshot is a special type of layer * backed by an FBO. This flag only makes sense when the * backed by an FBO. This flag only makes sense when the * flag kFlagIsLayer is also set. * flag kFlagIsLayer is also set. * * Viewport has been modified to fit the new Fbo, and must be * restored when this snapshot is restored. */ */ kFlagIsFboLayer = 0x4, kFlagIsFboLayer = 0x4, /** * Indicates that this snapshot has changed the ortho matrix. */ kFlagDirtyOrtho = 0x8, /** /** * Indicates that this snapshot or an ancestor snapshot is * Indicates that this snapshot or an ancestor snapshot is * an FBO layer. * an FBO layer. */ */ kFlagFboTarget = 0x8, kFlagFboTarget = 0x10 }; }; /** /** Loading Loading @@ -182,7 +183,7 @@ public: int height; int height; /** /** * Contains the current orthographic, projection matrix. * Contains the previous ortho matrix. */ */ mat4 orthoMatrix; mat4 orthoMatrix; Loading