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

Side by Side Diff: src/core/SkDevice.cpp

Issue 1992283002: Add drawBitmapLattice() API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rewrite picture impls Created 4 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 unified diff | Download patch
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkLatticeIter.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 2011 Google Inc. 2 * Copyright 2011 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 "SkColorFilter.h" 8 #include "SkColorFilter.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
11 #include "SkDrawFilter.h" 11 #include "SkDrawFilter.h"
12 #include "SkImage_Base.h" 12 #include "SkImage_Base.h"
13 #include "SkImageFilter.h" 13 #include "SkImageFilter.h"
14 #include "SkImageFilterCache.h" 14 #include "SkImageFilterCache.h"
15 #include "SkLatticeIter.h"
15 #include "SkMetaData.h" 16 #include "SkMetaData.h"
16 #include "SkNinePatchIter.h"
17 #include "SkPatchUtils.h" 17 #include "SkPatchUtils.h"
18 #include "SkPathMeasure.h" 18 #include "SkPathMeasure.h"
19 #include "SkRasterClip.h" 19 #include "SkRasterClip.h"
20 #include "SkRSXform.h" 20 #include "SkRSXform.h"
21 #include "SkShader.h" 21 #include "SkShader.h"
22 #include "SkSpecialImage.h" 22 #include "SkSpecialImage.h"
23 #include "SkTextBlobRunIterator.h" 23 #include "SkTextBlobRunIterator.h"
24 #include "SkTextToPathIter.h" 24 #include "SkTextToPathIter.h"
25 25
26 SkBaseDevice::SkBaseDevice(const SkSurfaceProps& surfaceProps) : fSurfaceProps(s urfaceProps) { 26 SkBaseDevice::SkBaseDevice(const SkSurfaceProps& surfaceProps) : fSurfaceProps(s urfaceProps) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x, SkScalar y, 146 void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x, SkScalar y,
147 const SkPaint& paint) { 147 const SkPaint& paint) {
148 // Default impl : turns everything into raster bitmap 148 // Default impl : turns everything into raster bitmap
149 SkBitmap bm; 149 SkBitmap bm;
150 if (as_IB(image)->getROPixels(&bm)) { 150 if (as_IB(image)->getROPixels(&bm)) {
151 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); 151 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
152 } 152 }
153 } 153 }
154 154
155 void SkBaseDevice::drawImageLattice(const SkDraw& draw, const SkImage* image,
156 const SkCanvas::Lattice& lattice, const SkRe ct& dst,
157 const SkPaint& paint) {
158 SkLatticeIter iter(image->width(), image->height(), lattice, dst);
159
160 SkRect srcR, dstR;
161 while (iter.next(&srcR, &dstR)) {
162 this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_S rcRectConstraint);
163 }
164 }
165
155 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src, 166 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
156 const SkRect& dst, const SkPaint& paint, 167 const SkRect& dst, const SkPaint& paint,
157 SkCanvas::SrcRectConstraint constraint) { 168 SkCanvas::SrcRectConstraint constraint) {
158 // Default impl : turns everything into raster bitmap 169 // Default impl : turns everything into raster bitmap
159 SkBitmap bm; 170 SkBitmap bm;
160 if (as_IB(image)->getROPixels(&bm)) { 171 if (as_IB(image)->getROPixels(&bm)) {
161 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); 172 this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
162 } 173 }
163 } 174 }
164 175
165 void SkBaseDevice::drawImageNine(const SkDraw& draw, const SkImage* image, const SkIRect& center, 176 void SkBaseDevice::drawImageNine(const SkDraw& draw, const SkImage* image, const SkIRect& center,
166 const SkRect& dst, const SkPaint& paint) { 177 const SkRect& dst, const SkPaint& paint) {
167 SkNinePatchIter iter(image->width(), image->height(), center, dst); 178 SkLatticeIter iter(image->width(), image->height(), center, dst);
168 179
169 SkRect srcR, dstR; 180 SkRect srcR, dstR;
170 while (iter.next(&srcR, &dstR)) { 181 while (iter.next(&srcR, &dstR)) {
171 this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_S rcRectConstraint); 182 this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_S rcRectConstraint);
172 } 183 }
173 } 184 }
174 185
175 void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, co nst SkIRect& center, 186 void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, co nst SkIRect& center,
176 const SkRect& dst, const SkPaint& paint) { 187 const SkRect& dst, const SkPaint& paint) {
177 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst); 188 SkLatticeIter iter(bitmap.width(), bitmap.height(), center, dst);
178 189
179 SkRect srcR, dstR; 190 SkRect srcR, dstR;
180 while (iter.next(&srcR, &dstR)) { 191 while (iter.next(&srcR, &dstR)) {
181 this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kStrict _SrcRectConstraint); 192 this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kStrict _SrcRectConstraint);
182 } 193 }
183 } 194 }
184 195
185 void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR SXform xform[], 196 void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR SXform xform[],
186 const SkRect tex[], const SkColor colors[], int cou nt, 197 const SkRect tex[], const SkColor colors[], int cou nt,
187 SkXfermode::Mode mode, const SkPaint& paint) { 198 SkXfermode::Mode mode, const SkPaint& paint) {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 523
513 // Also log filter quality independent scale factor. 524 // Also log filter quality independent scale factor.
514 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor, 525 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor,
515 kLast_ScaleFactor + 1); 526 kLast_ScaleFactor + 1);
516 527
517 // Also log an overall histogram of filter quality. 528 // Also log an overall histogram of filter quality.
518 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali ty + 1); 529 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali ty + 1);
519 #endif 530 #endif
520 } 531 }
521 532
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkLatticeIter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698