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

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

Issue 1228083004: add src-rect-constraint to drawImageRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 5 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/SkMiniRecorder.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"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x, SkScalar y, 147 void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x, SkScalar y,
148 const SkPaint& paint) { 148 const SkPaint& paint) {
149 // Default impl : turns everything into raster bitmap 149 // Default impl : turns everything into raster bitmap
150 SkBitmap bm; 150 SkBitmap bm;
151 if (as_IB(image)->getROPixels(&bm)) { 151 if (as_IB(image)->getROPixels(&bm)) {
152 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); 152 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
153 } 153 }
154 } 154 }
155 155
156 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src, 156 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
157 const SkRect& dst, const SkPaint& paint) { 157 const SkRect& dst, const SkPaint& paint,
158 SkCanvas::SrcRectConstraint constraint) {
158 // Default impl : turns everything into raster bitmap 159 // Default impl : turns everything into raster bitmap
159 SkBitmap bm; 160 SkBitmap bm;
160 if (as_IB(image)->getROPixels(&bm)) { 161 if (as_IB(image)->getROPixels(&bm)) {
161 this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitm apRectFlag); 162 this->drawBitmapRect(draw, bm, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_T YPE)constraint);
162 } 163 }
163 } 164 }
164 165
165 void SkBaseDevice::drawImageNine(const SkDraw& draw, const SkImage* image, const SkIRect& center, 166 void SkBaseDevice::drawImageNine(const SkDraw& draw, const SkImage* image, const SkIRect& center,
166 const SkRect& dst, const SkPaint& paint) { 167 const SkRect& dst, const SkPaint& paint) {
167 SkNinePatchIter iter(image->width(), image->height(), center, dst); 168 SkNinePatchIter iter(image->width(), image->height(), center, dst);
168 169
169 SkRect srcR, dstR; 170 SkRect srcR, dstR;
170 while (iter.next(&srcR, &dstR)) { 171 while (iter.next(&srcR, &dstR)) {
171 this->drawImageRect(draw, image, &srcR, dstR, paint); 172 this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_S rcRectConstraint);
172 } 173 }
173 } 174 }
174 175
175 void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, co nst SkIRect& center, 176 void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, co nst SkIRect& center,
176 const SkRect& dst, const SkPaint& paint) { 177 const SkRect& dst, const SkPaint& paint) {
177 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst); 178 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst);
178 179
179 SkRect srcR, dstR; 180 SkRect srcR, dstR;
180 while (iter.next(&srcR, &dstR)) { 181 while (iter.next(&srcR, &dstR)) {
181 this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kNone_D rawBitmapRectFlag); 182 this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint,
183 (SK_VIRTUAL_CONSTRAINT_TYPE)SkCanvas::kStrict_SrcRe ctConstraint);
182 } 184 }
183 } 185 }
184 186
185 void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR SXform xform[], 187 void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR SXform xform[],
186 const SkRect tex[], const SkColor colors[], int cou nt, 188 const SkRect tex[], const SkColor colors[], int cou nt,
187 SkXfermode::Mode mode, const SkPaint& paint) { 189 SkXfermode::Mode mode, const SkPaint& paint) {
188 SkPath path; 190 SkPath path;
189 path.setIsVolatile(true); 191 path.setIsVolatile(true);
190 192
191 for (int i = 0; i < count; ++i) { 193 for (int i = 0; i < count; ++i) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() 409 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry()
408 || this->onShouldDisableLCD(paint)) { 410 || this->onShouldDisableLCD(paint)) {
409 411
410 flags &= ~SkPaint::kLCDRenderText_Flag; 412 flags &= ~SkPaint::kLCDRenderText_Flag;
411 flags |= SkPaint::kGenA8FromLCD_Flag; 413 flags |= SkPaint::kGenA8FromLCD_Flag;
412 } 414 }
413 415
414 return flags; 416 return flags;
415 } 417 }
416 418
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkMiniRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698