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

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: 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') | tools/viewer/sk_app/WindowContext.h » ('J')
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 7052a3ac79244d7ee724ea9f23a900e675ef2b64..29160354328b0a321bb15a7bae5cdfccad32df9b 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -10,13 +10,17 @@
#include "GMSlide.h"
#include "ImageSlide.h"
#include "SKPSlide.h"
+#include "sk_app/WindowContext.h"
+#include "GrRenderTarget.h"
#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;
@@ -360,9 +364,27 @@ 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->getContext()->createRenderSurface(nullptr, 0, true, 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') | tools/viewer/sk_app/WindowContext.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698