Merge "Re-enable empty damage drop optimization"

This commit is contained in:
TreeHugger Robot
2019-03-08 03:26:30 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 5 deletions

View File

@@ -401,11 +401,11 @@ void CanvasContext::draw() {
SkRect dirty;
mDamageAccumulator.finish(&dirty);
// TODO: Re-enable after figuring out cause of b/22592975
// if (dirty.isEmpty() && Properties::skipEmptyFrames) {
// mCurrentFrameInfo->addFlag(FrameInfoFlags::SkippedFrame);
// return;
// }
if (dirty.isEmpty() && Properties::skipEmptyFrames
&& !surfaceRequiresRedraw()) {
mCurrentFrameInfo->addFlag(FrameInfoFlags::SkippedFrame);
return;
}
mCurrentFrameInfo->markIssueDrawCommandsStart();
@@ -638,6 +638,19 @@ int64_t CanvasContext::getFrameNumber() {
return mFrameNumber;
}
bool CanvasContext::surfaceRequiresRedraw() {
if (!mNativeSurface) return false;
if (mHaveNewSurface) return true;
int width = -1;
int height = -1;
ReliableSurface* surface = mNativeSurface.get();
surface->query(NATIVE_WINDOW_WIDTH, &width);
surface->query(NATIVE_WINDOW_HEIGHT, &height);
return width == mLastFrameWidth && height == mLastFrameHeight;
}
SkRect CanvasContext::computeDirtyRect(const Frame& frame, SkRect* dirty) {
if (frame.width() != mLastFrameWidth || frame.height() != mLastFrameHeight) {
// can't rely on prior content of window if viewport size changes

View File

@@ -217,6 +217,7 @@ private:
void freePrefetchedLayers();
bool isSwapChainStuffed();
bool surfaceRequiresRedraw();
SkRect computeDirtyRect(const Frame& frame, SkRect* dirty);