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

Unified Diff: gm/optimizations.cpp

Issue 513983002: Try out scalar picture sizes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT again Created 6 years, 4 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 | « gm/multipicturedraw.cpp ('k') | gm/pictureshader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/optimizations.cpp
diff --git a/gm/optimizations.cpp b/gm/optimizations.cpp
index a33f45711f9f3117aac343e46c390da611a062aa..00be04cee61461b06924936d8e4190514c344808 100644
--- a/gm/optimizations.cpp
+++ b/gm/optimizations.cpp
@@ -17,8 +17,8 @@
// heavy-weight operation since we are drawing the picture into a debug canvas
// to extract the commands.
static bool check_pattern(SkPicture& input, const SkTDArray<DrawType> &pattern) {
- SkDebugCanvas debugCanvas(input.width(), input.height());
- debugCanvas.setBounds(input.width(), input.height());
+ SkDebugCanvas debugCanvas(SkScalarCeilToInt(input.cullRect().width()),
+ SkScalarCeilToInt(input.cullRect().height()));
input.draw(&debugCanvas);
if (pattern.count() != debugCanvas.getSize()) {
@@ -340,7 +340,7 @@ protected:
};
SkTDArray<DrawType> prePattern, postPattern;
- int xPos = 0, yPos = 0;
+ SkScalar xPos = 0, yPos = 0;
for (size_t i = 0; i < SK_ARRAY_COUNT(gOpts); ++i) {
SkAutoTUnref<SkPicture> pre((*gOpts[i])(&prePattern, &postPattern, fCheckerboard));
@@ -351,16 +351,18 @@ protected:
}
canvas->save();
- canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos));
+ canvas->translate(xPos, yPos);
pre->draw(canvas);
- xPos += pre->width();
+ xPos += pre->cullRect().width();
canvas->restore();
// re-render the 'pre' picture and thus 'apply' the optimization
SkPictureRecorder recorder;
SkCanvas* recordCanvas =
- recorder.DEPRECATED_beginRecording(pre->width(), pre->height(), NULL, 0);
+ recorder.DEPRECATED_beginRecording(pre->cullRect().width(),
+ pre->cullRect().height(),
+ NULL, 0);
pre->draw(recordCanvas);
@@ -372,15 +374,15 @@ protected:
}
canvas->save();
- canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos));
+ canvas->translate(xPos, yPos);
post->draw(canvas);
- xPos += post->width();
+ xPos += post->cullRect().width();
canvas->restore();
if (xPos >= kWidth) {
// start a new line
xPos = 0;
- yPos += post->height();
+ yPos += post->cullRect().height();
}
// TODO: we could also render the pre and post pictures to bitmaps
« no previous file with comments | « gm/multipicturedraw.cpp ('k') | gm/pictureshader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698