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

Unified Diff: tools/vulkan/viewer/VulkanViewer.cpp

Issue 1903253003: VulkanViewer on Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gyp Created 4 years, 8 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 | « tools/vulkan/viewer/Slide.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/vulkan/viewer/VulkanViewer.cpp
diff --git a/tools/vulkan/viewer/VulkanViewer.cpp b/tools/vulkan/viewer/VulkanViewer.cpp
index a88a337017be47c8cbedd128fde9e6d5e293ec8e..faa30142dd2470947eb8aa7251003673afbe99e8 100644
--- a/tools/vulkan/viewer/VulkanViewer.cpp
+++ b/tools/vulkan/viewer/VulkanViewer.cpp
@@ -81,10 +81,12 @@ VulkanViewer::VulkanViewer(int argc, char** argv, void* platformData)
// set up slides
this->initSlides();
+ fAnimTimer.run();
+
// set up first frame
fCurrentSlide = 0;
setupCurrentSlide(-1);
- fLocalMatrix.reset();
+ updateMatrix();
fWindow->show();
}
@@ -254,10 +256,24 @@ bool VulkanViewer::onChar(SkUnichar c, uint32_t modifiers) {
void VulkanViewer::onPaint(SkCanvas* canvas) {
- canvas->clear(SK_ColorWHITE);
-
int count = canvas->save();
- canvas->setMatrix(fLocalMatrix);
+
+ if (fWindow->supportsContentRect()) {
+ SkRect contentRect = fWindow->getContentRect();
+ canvas->clipRect(contentRect);
+ canvas->translate(contentRect.fLeft, contentRect.fTop);
+ }
+
+ canvas->clear(SK_ColorWHITE);
+ if (fWindow->supportsContentRect() && fWindow->scaleContentToFit()) {
+ const SkRect contentRect = fWindow->getContentRect();
+ const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions();
+ const SkRect slideBounds = SkRect::MakeIWH(slideSize.width(), slideSize.height());
+ SkMatrix matrix;
+ matrix.setRectToRect(slideBounds, contentRect, SkMatrix::kCenter_ScaleToFit);
+ canvas->concat(matrix);
+ }
+ canvas->concat(fLocalMatrix);
fSlides[fCurrentSlide]->draw(canvas);
canvas->restoreToCount(count);
@@ -282,6 +298,12 @@ void VulkanViewer::drawStats(SkCanvas* canvas) {
SkPaint paint;
canvas->save();
+ if (fWindow->supportsContentRect()) {
+ SkRect contentRect = fWindow->getContentRect();
+ canvas->clipRect(contentRect);
+ canvas->translate(contentRect.fLeft, contentRect.fTop);
+ }
+
canvas->clipRect(rect);
paint.setColor(SK_ColorBLACK);
canvas->drawRect(rect, paint);
« no previous file with comments | « tools/vulkan/viewer/Slide.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698