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

Side by Side Diff: gm/lattice.cpp

Issue 2305433002: Add option to skip rects to drawImageLattice() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Better detection for zero divs Created 4 years, 3 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 | « bench/DrawLatticeBench.cpp ('k') | include/core/SkCanvas.h » ('j') | 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 2016 Google Inc. 2 * Copyright 2016 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 #include "SkSurface.h" 9 #include "SkSurface.h"
10 10
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 canvas->drawImage(image, 10, 10, nullptr); 106 canvas->drawImage(image, 10, 10, nullptr);
107 107
108 SkScalar x = SkIntToScalar(100); 108 SkScalar x = SkIntToScalar(100);
109 SkScalar y = SkIntToScalar(100); 109 SkScalar y = SkIntToScalar(100);
110 110
111 SkCanvas::Lattice lattice; 111 SkCanvas::Lattice lattice;
112 lattice.fXCount = 4; 112 lattice.fXCount = 4;
113 lattice.fXDivs = xDivs + 1; 113 lattice.fXDivs = xDivs + 1;
114 lattice.fYCount = 4; 114 lattice.fYCount = 4;
115 lattice.fYDivs = yDivs + 1; 115 lattice.fYDivs = yDivs + 1;
116 lattice.fFlags = nullptr;
116 117
117 for (int iy = 0; iy < 2; ++iy) { 118 for (int iy = 0; iy < 2; ++iy) {
118 for (int ix = 0; ix < 2; ++ix) { 119 for (int ix = 0; ix < 2; ++ix) {
119 int i = ix * 2 + iy; 120 int i = ix * 2 + iy;
120 SkRect r = SkRect::MakeXYWH(x + ix * 60, y + iy * 60, 121 SkRect r = SkRect::MakeXYWH(x + ix * 60, y + iy * 60,
121 size[i].width(), size[i].height()); 122 size[i].width(), size[i].height());
122 canvas->drawBitmapLattice(bitmap, lattice, r); 123 canvas->drawBitmapLattice(bitmap, lattice, r);
123 } 124 }
124 } 125 }
125 126
126 // Include the degenerate first div. While normally the first patch is "scalable", 127 // Include the degenerate first div. While normally the first patch is "scalable",
127 // this will mean that the first non-degenerate patch is "fixed". 128 // this will mean that the first non-degenerate patch is "fixed".
128 lattice.fXCount = 5; 129 lattice.fXCount = 5;
129 lattice.fXDivs = xDivs; 130 lattice.fXDivs = xDivs;
130 lattice.fYCount = 5; 131 lattice.fYCount = 5;
131 lattice.fYDivs = yDivs; 132 lattice.fYDivs = yDivs;
132 133
134 // Let's skip a few rects.
135 SkCanvas::Lattice::Flags flags[36];
136 sk_bzero(flags, 36 * sizeof(SkCanvas::Lattice::Flags));
137 flags[4] = SkCanvas::Lattice::kTransparent_Flags;
138 flags[9] = SkCanvas::Lattice::kTransparent_Flags;
139 flags[12] = SkCanvas::Lattice::kTransparent_Flags;
140 flags[19] = SkCanvas::Lattice::kTransparent_Flags;
141 lattice.fFlags = flags;
142
133 canvas->translate(400, 0); 143 canvas->translate(400, 0);
134 for (int iy = 0; iy < 2; ++iy) { 144 for (int iy = 0; iy < 2; ++iy) {
135 for (int ix = 0; ix < 2; ++ix) { 145 for (int ix = 0; ix < 2; ++ix) {
136 int i = ix * 2 + iy; 146 int i = ix * 2 + iy;
137 SkRect r = SkRect::MakeXYWH(x + ix * 60, y + iy * 60, 147 SkRect r = SkRect::MakeXYWH(x + ix * 60, y + iy * 60,
138 size[i].width(), size[i].height()); 148 size[i].width(), size[i].height());
139 canvas->drawImageLattice(image.get(), lattice, r); 149 canvas->drawImageLattice(image.get(), lattice, r);
140 } 150 }
141 } 151 }
142 } 152 }
143 153
144 private: 154 private:
145 typedef skiagm::GM INHERITED; 155 typedef skiagm::GM INHERITED;
146 }; 156 };
147 DEF_GM( return new LatticeGM; ) 157 DEF_GM( return new LatticeGM; )
OLDNEW
« no previous file with comments | « bench/DrawLatticeBench.cpp ('k') | include/core/SkCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698