Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: tools/viewer/Viewer.cpp

Issue 2069653002: Use Offscreen Surface for Split Screen (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Better merge Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/viewer/sk_app/Window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/Viewer.cpp
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 9aec01f3ecc327ba1c1b7b9de5b948ae13fc7110..be80f5748bce9bf83c6fe4fa2653da73a1245f26 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -14,10 +14,12 @@
#include "SkCanvas.h"
#include "SkCommonFlags.h"
+#include "SkDashPathEffect.h"
#include "SkMetaData.h"
#include "SkOSFile.h"
#include "SkRandom.h"
#include "SkStream.h"
+#include "SkSurface.h"
using namespace sk_app;
@@ -371,9 +373,26 @@ void Viewer::drawSlide(SkCanvas* canvas, bool inSplitScreen) {
canvas->concat(fDefaultMatrix);
canvas->concat(computeMatrix());
- canvas->getMetaData().setBool(kImageColorXformMetaData, inSplitScreen);
- fSlides[fCurrentSlide]->draw(canvas);
+ if (inSplitScreen) {
+ sk_sp<SkSurface> offscreenSurface = fWindow->getOffscreenSurface(true);
+ fSlides[fCurrentSlide]->draw(offscreenSurface->getCanvas());
+ sk_sp<SkImage> snapshot = offscreenSurface->makeImageSnapshot();
+ canvas->drawImage(snapshot, 0, 0);
+ } else {
+ fSlides[fCurrentSlide]->draw(canvas);
+ }
+
canvas->restoreToCount(count);
+
+ if (inSplitScreen) {
+ // Draw split line
+ SkPaint paint;
+ SkScalar intervals[] = {10.0f, 5.0f};
+ paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0.0f));
+ SkRect contentRect = fWindow->getContentRect();
+ SkScalar middleX = (contentRect.fLeft + contentRect.fRight) * 0.5f;
+ canvas->drawLine(middleX, contentRect.fTop, middleX, contentRect.fBottom, paint);
+ }
}
void Viewer::onPaint(SkCanvas* canvas) {
« no previous file with comments | « no previous file | tools/viewer/sk_app/Window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698