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

Side by Side Diff: gm/multipicturedraw.cpp

Issue 632743002: Fix multipicturedraw_biglayer GM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 9
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 SkPaint stroke; 100 SkPaint stroke;
101 stroke.setStyle(SkPaint::kStroke_Style); 101 stroke.setStyle(SkPaint::kStroke_Style);
102 stroke.setStrokeWidth(3); 102 stroke.setStrokeWidth(3);
103 103
104 SkPictureRecorder recorder; 104 SkPictureRecorder recorder;
105 105
106 static const SkScalar kBig = 10000.0f; 106 static const SkScalar kBig = 10000.0f;
107 SkCanvas* canvas = recorder.beginRecording(kBig, kBig); 107 SkCanvas* canvas = recorder.beginRecording(kBig, kBig);
108 108
109 canvas->saveLayer(NULL, NULL);
110
109 SkScalar xPos = 0.0f, yPos = 0.0f; 111 SkScalar xPos = 0.0f, yPos = 0.0f;
110 112
111 for (int y = 0; yPos < kBig; ++y) { 113 for (int y = 0; yPos < kBig; ++y) {
112 xPos = 0; 114 xPos = 0;
113 115
114 for (int x = 0; xPos < kBig; ++x) { 116 for (int x = 0; xPos < kBig; ++x) {
115 canvas->save(); 117 canvas->save();
116 canvas->translate(xPos, yPos + ((x % 2) ? kRoot3Over2 * kHexSide : 0 )); 118 canvas->translate(xPos, yPos + ((x % 2) ? kRoot3Over2 * kHexSide : 0 ));
117 // The color of the filled hex is swapped to yield a different 119 // The color of the filled hex is swapped to yield a different
118 // pattern in each tile. This allows an error in layer hoisting (e.g ., 120 // pattern in each tile. This allows an error in layer hoisting (e.g .,
119 // the clip isn't blocking cache reuse) to cause a visual discrepanc y. 121 // the clip isn't blocking cache reuse) to cause a visual discrepanc y.
120 canvas->drawPath(hex, ((x+y) % 3) ? whiteFill : greyFill); 122 canvas->drawPath(hex, ((x+y) % 3) ? whiteFill : greyFill);
121 canvas->drawPath(hex, stroke); 123 canvas->drawPath(hex, stroke);
122 canvas->restore(); 124 canvas->restore();
123 125
124 xPos += 1.5f * kHexSide; 126 xPos += 1.5f * kHexSide;
125 } 127 }
126 128
127 yPos += 2 * kHexSide * kRoot3Over2; 129 yPos += 2 * kHexSide * kRoot3Over2;
128 } 130 }
129 131
132 canvas->restore();
133
130 return recorder.endRecording(); 134 return recorder.endRecording();
131 } 135 }
132 136
133 // Make an equilateral triangle path with its top corner at (originX, originY) 137 // Make an equilateral triangle path with its top corner at (originX, originY)
134 static SkPath make_tri_path(SkScalar originX, SkScalar originY) { 138 static SkPath make_tri_path(SkScalar originX, SkScalar originY) {
135 SkPath tri; 139 SkPath tri;
136 tri.moveTo(originX, originY); 140 tri.moveTo(originX, originY);
137 tri.rLineTo(SkScalarHalf(kTriSide), 1.5f * kTriSide / kRoot3); 141 tri.rLineTo(SkScalarHalf(kTriSide), 1.5f * kTriSide / kRoot3);
138 tri.rLineTo(-kTriSide, 0); 142 tri.rLineTo(-kTriSide, 0);
139 tri.close(); 143 tri.close();
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 MultiPictureDraw::kTiled_Layout) );) 546 MultiPictureDraw::kTiled_Layout) );)
543 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kPathClipMulti _Content, 547 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kPathClipMulti _Content,
544 MultiPictureDraw::kTiled_Layout) );) 548 MultiPictureDraw::kTiled_Layout) );)
545 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kInvPathClipMu lti_Content, 549 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kInvPathClipMu lti_Content,
546 MultiPictureDraw::kTiled_Layout) );) 550 MultiPictureDraw::kTiled_Layout) );)
547 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kSierpinski_Co ntent, 551 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kSierpinski_Co ntent,
548 MultiPictureDraw::kTiled_Layout) );) 552 MultiPictureDraw::kTiled_Layout) );)
549 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kBigLayer_Cont ent, 553 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kBigLayer_Cont ent,
550 MultiPictureDraw::kTiled_Layout) );) 554 MultiPictureDraw::kTiled_Layout) );)
551 } 555 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698