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

Side by Side Diff: src/gpu/SkGpuDevice.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/gpu/SkGpuDevice.h ('k') | src/pdf/SkPDFDevice.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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 void SkGpuDevice::drawBitmap(const SkDraw& origDraw, 784 void SkGpuDevice::drawBitmap(const SkDraw& origDraw,
785 const SkBitmap& bitmap, 785 const SkBitmap& bitmap,
786 const SkMatrix& m, 786 const SkMatrix& m,
787 const SkPaint& paint) { 787 const SkPaint& paint) {
788 SkMatrix concat; 788 SkMatrix concat;
789 SkTCopyOnFirstWrite<SkDraw> draw(origDraw); 789 SkTCopyOnFirstWrite<SkDraw> draw(origDraw);
790 if (!m.isIdentity()) { 790 if (!m.isIdentity()) {
791 concat.setConcat(*draw->fMatrix, m); 791 concat.setConcat(*draw->fMatrix, m);
792 draw.writable()->fMatrix = &concat; 792 draw.writable()->fMatrix = &concat;
793 } 793 }
794 this->drawBitmapCommon(*draw, bitmap, NULL, NULL, paint, SkCanvas::kNone_Dra wBitmapRectFlag); 794 this->drawBitmapCommon(*draw, bitmap, NULL, NULL, paint, SkCanvas::kStrict_S rcRectConstraint);
795 } 795 }
796 796
797 // This method outsets 'iRect' by 'outset' all around and then clamps its extent s to 797 // This method outsets 'iRect' by 'outset' all around and then clamps its extent s to
798 // 'clamp'. 'offset' is adjusted to remain positioned over the top-left corner 798 // 'clamp'. 'offset' is adjusted to remain positioned over the top-left corner
799 // of 'iRect' for all possible outsets/clamps. 799 // of 'iRect' for all possible outsets/clamps.
800 static inline void clamped_outset_with_offset(SkIRect* iRect, 800 static inline void clamped_outset_with_offset(SkIRect* iRect,
801 int outset, 801 int outset,
802 SkPoint* offset, 802 SkPoint* offset,
803 const SkIRect& clamp) { 803 const SkIRect& clamp) {
804 iRect->outset(outset, outset); 804 iRect->outset(outset, outset);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 896 }
897 } 897 }
898 return needsTextureDomain; 898 return needsTextureDomain;
899 } 899 }
900 900
901 void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, 901 void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
902 const SkBitmap& bitmap, 902 const SkBitmap& bitmap,
903 const SkRect* srcRectPtr, 903 const SkRect* srcRectPtr,
904 const SkSize* dstSizePtr, 904 const SkSize* dstSizePtr,
905 const SkPaint& paint, 905 const SkPaint& paint,
906 SkCanvas::DrawBitmapRectFlags flags) { 906 SkCanvas::SrcRectConstraint constraint) {
907 CHECK_SHOULD_DRAW(draw); 907 CHECK_SHOULD_DRAW(draw);
908 908
909 SkRect srcRect; 909 SkRect srcRect;
910 SkSize dstSize; 910 SkSize dstSize;
911 // If there is no src rect, or the src rect contains the entire bitmap then we're effectively 911 // If there is no src rect, or the src rect contains the entire bitmap then we're effectively
912 // in the (easier) bleed case, so update flags. 912 // in the (easier) bleed case, so update flags.
913 if (NULL == srcRectPtr) { 913 if (NULL == srcRectPtr) {
914 SkScalar w = SkIntToScalar(bitmap.width()); 914 SkScalar w = SkIntToScalar(bitmap.width());
915 SkScalar h = SkIntToScalar(bitmap.height()); 915 SkScalar h = SkIntToScalar(bitmap.height());
916 dstSize.fWidth = w; 916 dstSize.fWidth = w;
917 dstSize.fHeight = h; 917 dstSize.fHeight = h;
918 srcRect.set(0, 0, w, h); 918 srcRect.set(0, 0, w, h);
919 } else { 919 } else {
920 SkASSERT(dstSizePtr); 920 SkASSERT(dstSizePtr);
921 srcRect = *srcRectPtr; 921 srcRect = *srcRectPtr;
922 dstSize = *dstSizePtr; 922 dstSize = *dstSizePtr;
923 } 923 }
924 GrTexture* tex = bitmap.getTexture(); 924 GrTexture* tex = bitmap.getTexture();
925 int width = tex ? tex->width() : bitmap.width(); 925 int width = tex ? tex->width() : bitmap.width();
926 int height = tex ? tex->height() : bitmap.height(); 926 int height = tex ? tex->height() : bitmap.height();
927 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 && 927 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
928 srcRect.fRight >= width && srcRect.fBottom >= height) { 928 srcRect.fRight >= width && srcRect.fBottom >= height) {
929 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBi tmapRectFlag); 929 constraint = SkCanvas::kFast_SrcRectConstraint;
930 } 930 }
931 931
932 // If the render target is not msaa and draw is antialiased, we call 932 // If the render target is not msaa and draw is antialiased, we call
933 // drawRect instead of drawing on the render target directly. 933 // drawRect instead of drawing on the render target directly.
934 // FIXME: the tiled bitmap code path doesn't currently support 934 // FIXME: the tiled bitmap code path doesn't currently support
935 // anti-aliased edges, we work around that for now by drawing directly 935 // anti-aliased edges, we work around that for now by drawing directly
936 // if the image size exceeds maximum texture size. 936 // if the image size exceeds maximum texture size.
937 int maxTextureSize = fContext->caps()->maxTextureSize(); 937 int maxTextureSize = fContext->caps()->maxTextureSize();
938 bool directDraw = fRenderTarget->isUnifiedMultisampled() || 938 bool directDraw = fRenderTarget->isUnifiedMultisampled() ||
939 !paint.isAntiAlias() || 939 !paint.isAntiAlias() ||
(...skipping 29 matching lines...) Expand all
969 const SkBitmap* bitmapPtr = &bitmap; 969 const SkBitmap* bitmapPtr = &bitmap;
970 SkMatrix localM; 970 SkMatrix localM;
971 if (srcRectPtr) { 971 if (srcRectPtr) {
972 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop); 972 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop);
973 localM.postScale(dstSize.fWidth / srcRectPtr->width(), 973 localM.postScale(dstSize.fWidth / srcRectPtr->width(),
974 dstSize.fHeight / srcRectPtr->height()); 974 dstSize.fHeight / srcRectPtr->height());
975 // In bleed mode we position and trim the bitmap based on the src re ct which is 975 // In bleed mode we position and trim the bitmap based on the src re ct which is
976 // already accounted for in 'm' and 'srcRect'. In clamp mode we need to chop out 976 // already accounted for in 'm' and 'srcRect'. In clamp mode we need to chop out
977 // the desired portion of the bitmap and then update 'm' and 'srcRec t' to 977 // the desired portion of the bitmap and then update 'm' and 'srcRec t' to
978 // compensate. 978 // compensate.
979 if (!(SkCanvas::kBleed_DrawBitmapRectFlag & flags)) { 979 if (SkCanvas::kStrict_SrcRectConstraint == constraint) {
980 SkIRect iSrc; 980 SkIRect iSrc;
981 srcRect.roundOut(&iSrc); 981 srcRect.roundOut(&iSrc);
982 982
983 SkPoint offset = SkPoint::Make(SkIntToScalar(iSrc.fLeft), 983 SkPoint offset = SkPoint::Make(SkIntToScalar(iSrc.fLeft),
984 SkIntToScalar(iSrc.fTop)); 984 SkIntToScalar(iSrc.fTop));
985 985
986 if (!bitmap.extractSubset(&tmp, iSrc)) { 986 if (!bitmap.extractSubset(&tmp, iSrc)) {
987 return; // extraction failed 987 return; // extraction failed
988 } 988 }
989 bitmapPtr = &tmp; 989 bitmapPtr = &tmp;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 tileFilterPad = 1; 1057 tileFilterPad = 1;
1058 } 1058 }
1059 params.setFilterMode(textureFilterMode); 1059 params.setFilterMode(textureFilterMode);
1060 1060
1061 int maxTileSize = fContext->caps()->maxTextureSize() - 2 * tileFilterPad; 1061 int maxTileSize = fContext->caps()->maxTextureSize() - 2 * tileFilterPad;
1062 int tileSize; 1062 int tileSize;
1063 1063
1064 SkIRect clippedSrcRect; 1064 SkIRect clippedSrcRect;
1065 if (this->shouldTileBitmap(bitmap, viewM, params, srcRectPtr, maxTileSize, & tileSize, 1065 if (this->shouldTileBitmap(bitmap, viewM, params, srcRectPtr, maxTileSize, & tileSize,
1066 &clippedSrcRect)) { 1066 &clippedSrcRect)) {
1067 this->drawTiledBitmap(bitmap, viewM, srcRect, clippedSrcRect, params, pa int, flags, 1067 this->drawTiledBitmap(bitmap, viewM, srcRect, clippedSrcRect, params, pa int, constraint,
1068 tileSize, doBicubic); 1068 tileSize, doBicubic);
1069 } else { 1069 } else {
1070 // take the simple case 1070 // take the simple case
1071 bool needsTextureDomain = needs_texture_domain(bitmap, 1071 bool needsTextureDomain = needs_texture_domain(bitmap,
1072 srcRect, 1072 srcRect,
1073 params, 1073 params,
1074 viewM, 1074 viewM,
1075 doBicubic); 1075 doBicubic);
1076 this->internalDrawBitmap(bitmap, 1076 this->internalDrawBitmap(bitmap,
1077 viewM, 1077 viewM,
1078 srcRect, 1078 srcRect,
1079 params, 1079 params,
1080 paint, 1080 paint,
1081 flags, 1081 constraint,
1082 doBicubic, 1082 doBicubic,
1083 needsTextureDomain); 1083 needsTextureDomain);
1084 } 1084 }
1085 } 1085 }
1086 1086
1087 // Break 'bitmap' into several tiles to draw it since it has already 1087 // Break 'bitmap' into several tiles to draw it since it has already
1088 // been determined to be too large to fit in VRAM 1088 // been determined to be too large to fit in VRAM
1089 void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap, 1089 void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
1090 const SkMatrix& viewMatrix, 1090 const SkMatrix& viewMatrix,
1091 const SkRect& srcRect, 1091 const SkRect& srcRect,
1092 const SkIRect& clippedSrcIRect, 1092 const SkIRect& clippedSrcIRect,
1093 const GrTextureParams& params, 1093 const GrTextureParams& params,
1094 const SkPaint& paint, 1094 const SkPaint& paint,
1095 SkCanvas::DrawBitmapRectFlags flags, 1095 SkCanvas::SrcRectConstraint constraint,
1096 int tileSize, 1096 int tileSize,
1097 bool bicubic) { 1097 bool bicubic) {
1098 // The following pixel lock is technically redundant, but it is desirable 1098 // The following pixel lock is technically redundant, but it is desirable
1099 // to lock outside of the tile loop to prevent redecoding the whole image 1099 // to lock outside of the tile loop to prevent redecoding the whole image
1100 // at each tile in cases where 'bitmap' holds an SkDiscardablePixelRef that 1100 // at each tile in cases where 'bitmap' holds an SkDiscardablePixelRef that
1101 // is larger than the limit of the discardable memory pool. 1101 // is larger than the limit of the discardable memory pool.
1102 SkAutoLockPixels alp(bitmap); 1102 SkAutoLockPixels alp(bitmap);
1103 SkRect clippedSrcRect = SkRect::Make(clippedSrcIRect); 1103 SkRect clippedSrcRect = SkRect::Make(clippedSrcIRect);
1104 1104
1105 int nx = bitmap.width() / tileSize; 1105 int nx = bitmap.width() / tileSize;
(...skipping 22 matching lines...) Expand all
1128 1128
1129 // Adjust the context matrix to draw at the right x,y in device spac e 1129 // Adjust the context matrix to draw at the right x,y in device spac e
1130 SkMatrix viewM = viewMatrix; 1130 SkMatrix viewM = viewMatrix;
1131 SkMatrix tmpM; 1131 SkMatrix tmpM;
1132 tmpM.setTranslate(offset.fX - srcRect.fLeft, offset.fY - srcRect.fTo p); 1132 tmpM.setTranslate(offset.fX - srcRect.fLeft, offset.fY - srcRect.fTo p);
1133 viewM.preConcat(tmpM); 1133 viewM.preConcat(tmpM);
1134 1134
1135 if (GrTextureParams::kNone_FilterMode != params.filterMode() || bicu bic) { 1135 if (GrTextureParams::kNone_FilterMode != params.filterMode() || bicu bic) {
1136 SkIRect iClampRect; 1136 SkIRect iClampRect;
1137 1137
1138 if (SkCanvas::kBleed_DrawBitmapRectFlag & flags) { 1138 if (SkCanvas::kFast_SrcRectConstraint == constraint) {
1139 // In bleed mode we want to always expand the tile on all ed ges 1139 // In bleed mode we want to always expand the tile on all ed ges
1140 // but stay within the bitmap bounds 1140 // but stay within the bitmap bounds
1141 iClampRect = SkIRect::MakeWH(bitmap.width(), bitmap.height() ); 1141 iClampRect = SkIRect::MakeWH(bitmap.width(), bitmap.height() );
1142 } else { 1142 } else {
1143 // In texture-domain/clamp mode we only want to expand the 1143 // In texture-domain/clamp mode we only want to expand the
1144 // tile on edges interior to "srcRect" (i.e., we want to 1144 // tile on edges interior to "srcRect" (i.e., we want to
1145 // not bleed across the original clamped edges) 1145 // not bleed across the original clamped edges)
1146 srcRect.roundOut(&iClampRect); 1146 srcRect.roundOut(&iClampRect);
1147 } 1147 }
1148 int outset = bicubic ? GrBicubicEffect::kFilterTexelPad : 1; 1148 int outset = bicubic ? GrBicubicEffect::kFilterTexelPad : 1;
1149 clamped_outset_with_offset(&iTileR, outset, &offset, iClampRect) ; 1149 clamped_outset_with_offset(&iTileR, outset, &offset, iClampRect) ;
1150 } 1150 }
1151 1151
1152 if (bitmap.extractSubset(&tmpB, iTileR)) { 1152 if (bitmap.extractSubset(&tmpB, iTileR)) {
1153 // now offset it to make it "local" to our tmp bitmap 1153 // now offset it to make it "local" to our tmp bitmap
1154 tileR.offset(-offset.fX, -offset.fY); 1154 tileR.offset(-offset.fX, -offset.fY);
1155 GrTextureParams paramsTemp = params; 1155 GrTextureParams paramsTemp = params;
1156 bool needsTextureDomain = needs_texture_domain(bitmap, 1156 bool needsTextureDomain = needs_texture_domain(bitmap,
1157 srcRect, 1157 srcRect,
1158 paramsTemp, 1158 paramsTemp,
1159 viewM, 1159 viewM,
1160 bicubic); 1160 bicubic);
1161 this->internalDrawBitmap(tmpB, 1161 this->internalDrawBitmap(tmpB,
1162 viewM, 1162 viewM,
1163 tileR, 1163 tileR,
1164 paramsTemp, 1164 paramsTemp,
1165 paint, 1165 paint,
1166 flags, 1166 constraint,
1167 bicubic, 1167 bicubic,
1168 needsTextureDomain); 1168 needsTextureDomain);
1169 } 1169 }
1170 } 1170 }
1171 } 1171 }
1172 } 1172 }
1173 1173
1174 1174
1175 /* 1175 /*
1176 * This is called by drawBitmap(), which has to handle images that may be too 1176 * This is called by drawBitmap(), which has to handle images that may be too
1177 * large to be represented by a single texture. 1177 * large to be represented by a single texture.
1178 * 1178 *
1179 * internalDrawBitmap assumes that the specified bitmap will fit in a texture 1179 * internalDrawBitmap assumes that the specified bitmap will fit in a texture
1180 * and that non-texture portion of the GrPaint has already been setup. 1180 * and that non-texture portion of the GrPaint has already been setup.
1181 */ 1181 */
1182 void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, 1182 void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
1183 const SkMatrix& viewMatrix, 1183 const SkMatrix& viewMatrix,
1184 const SkRect& srcRect, 1184 const SkRect& srcRect,
1185 const GrTextureParams& params, 1185 const GrTextureParams& params,
1186 const SkPaint& paint, 1186 const SkPaint& paint,
1187 SkCanvas::DrawBitmapRectFlags flags, 1187 SkCanvas::SrcRectConstraint constraint,
1188 bool bicubic, 1188 bool bicubic,
1189 bool needsTextureDomain) { 1189 bool needsTextureDomain) {
1190 SkASSERT(bitmap.width() <= fContext->caps()->maxTextureSize() && 1190 SkASSERT(bitmap.width() <= fContext->caps()->maxTextureSize() &&
1191 bitmap.height() <= fContext->caps()->maxTextureSize()); 1191 bitmap.height() <= fContext->caps()->maxTextureSize());
1192 1192
1193 GrTexture* texture; 1193 GrTexture* texture;
1194 AutoBitmapTexture abt(fContext, bitmap, &params, &texture); 1194 AutoBitmapTexture abt(fContext, bitmap, &params, &texture);
1195 if (NULL == texture) { 1195 if (NULL == texture) {
1196 return; 1196 return;
1197 } 1197 }
1198 1198
1199 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; 1199 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() };
1200 SkRect paintRect; 1200 SkRect paintRect;
1201 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); 1201 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width()));
1202 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); 1202 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height()));
1203 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), 1203 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv),
1204 SkScalarMul(srcRect.fTop, hInv), 1204 SkScalarMul(srcRect.fTop, hInv),
1205 SkScalarMul(srcRect.fRight, wInv), 1205 SkScalarMul(srcRect.fRight, wInv),
1206 SkScalarMul(srcRect.fBottom, hInv)); 1206 SkScalarMul(srcRect.fBottom, hInv));
1207 1207
1208 SkRect textureDomain = SkRect::MakeEmpty(); 1208 SkRect textureDomain = SkRect::MakeEmpty();
1209 1209
1210 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring 1210 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
1211 // the rest from the SkPaint. 1211 // the rest from the SkPaint.
1212 GrPaint grPaint; 1212 GrPaint grPaint;
1213 SkAutoTUnref<GrFragmentProcessor> fp; 1213 SkAutoTUnref<GrFragmentProcessor> fp;
1214 1214
1215 if (needsTextureDomain && !(flags & SkCanvas::kBleed_DrawBitmapRectFlag)) { 1215 if (needsTextureDomain && (SkCanvas::kStrict_SrcRectConstraint == constraint )) {
1216 // Use a constrained texture domain to avoid color bleeding 1216 // Use a constrained texture domain to avoid color bleeding
1217 SkScalar left, top, right, bottom; 1217 SkScalar left, top, right, bottom;
1218 if (srcRect.width() > SK_Scalar1) { 1218 if (srcRect.width() > SK_Scalar1) {
1219 SkScalar border = SK_ScalarHalf / texture->width(); 1219 SkScalar border = SK_ScalarHalf / texture->width();
1220 left = paintRect.left() + border; 1220 left = paintRect.left() + border;
1221 right = paintRect.right() - border; 1221 right = paintRect.right() - border;
1222 } else { 1222 } else {
1223 left = right = SkScalarHalf(paintRect.left() + paintRect.right()); 1223 left = right = SkScalarHalf(paintRect.left() + paintRect.right());
1224 } 1224 }
1225 if (srcRect.height() > SK_Scalar1) { 1225 if (srcRect.height() > SK_Scalar1) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 SkIntToScalar(h)), 1344 SkIntToScalar(h)),
1345 SkRect::MakeXYWH(0, 1345 SkRect::MakeXYWH(0,
1346 0, 1346 0,
1347 SK_Scalar1 * w / texture- >width(), 1347 SK_Scalar1 * w / texture- >width(),
1348 SK_Scalar1 * h / texture- >height())); 1348 SK_Scalar1 * h / texture- >height()));
1349 } 1349 }
1350 1350
1351 void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap, 1351 void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap,
1352 const SkRect* src, const SkRect& dst, 1352 const SkRect* src, const SkRect& dst,
1353 const SkPaint& paint, 1353 const SkPaint& paint,
1354 SkCanvas::DrawBitmapRectFlags flags) { 1354 SK_VIRTUAL_CONSTRAINT_TYPE legacyConstraint) {
1355 SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)legacy Constraint;
1356
1355 SkMatrix matrix; 1357 SkMatrix matrix;
1356 SkRect bitmapBounds, tmpSrc; 1358 SkRect bitmapBounds, tmpSrc;
1357 1359
1358 bitmapBounds.set(0, 0, 1360 bitmapBounds.set(0, 0,
1359 SkIntToScalar(bitmap.width()), 1361 SkIntToScalar(bitmap.width()),
1360 SkIntToScalar(bitmap.height())); 1362 SkIntToScalar(bitmap.height()));
1361 1363
1362 // Compute matrix from the two rectangles 1364 // Compute matrix from the two rectangles
1363 if (src) { 1365 if (src) {
1364 tmpSrc = *src; 1366 tmpSrc = *src;
(...skipping 19 matching lines...) Expand all
1384 if (0 != tmpDst.fLeft || 0 != tmpDst.fTop) { 1386 if (0 != tmpDst.fLeft || 0 != tmpDst.fTop) {
1385 // Translate so that tempDst's top left is at the origin. 1387 // Translate so that tempDst's top left is at the origin.
1386 matrix = *origDraw.fMatrix; 1388 matrix = *origDraw.fMatrix;
1387 matrix.preTranslate(tmpDst.fLeft, tmpDst.fTop); 1389 matrix.preTranslate(tmpDst.fLeft, tmpDst.fTop);
1388 draw.writable()->fMatrix = &matrix; 1390 draw.writable()->fMatrix = &matrix;
1389 } 1391 }
1390 SkSize dstSize; 1392 SkSize dstSize;
1391 dstSize.fWidth = tmpDst.width(); 1393 dstSize.fWidth = tmpDst.width();
1392 dstSize.fHeight = tmpDst.height(); 1394 dstSize.fHeight = tmpDst.height();
1393 1395
1394 this->drawBitmapCommon(*draw, bitmap, &tmpSrc, &dstSize, paint, flags); 1396 this->drawBitmapCommon(*draw, bitmap, &tmpSrc, &dstSize, paint, constraint);
1395 } 1397 }
1396 1398
1397 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, 1399 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
1398 int x, int y, const SkPaint& paint) { 1400 int x, int y, const SkPaint& paint) {
1399 // clear of the source device must occur before CHECK_SHOULD_DRAW 1401 // clear of the source device must occur before CHECK_SHOULD_DRAW
1400 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext); 1402 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext);
1401 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); 1403 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device);
1402 1404
1403 // TODO: If the source device covers the whole of this device, we could 1405 // TODO: If the source device covers the whole of this device, we could
1404 // omit fNeedsClear -related flushing. 1406 // omit fNeedsClear -related flushing.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 1507
1506 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x , SkScalar y, 1508 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x , SkScalar y,
1507 const SkPaint& paint) { 1509 const SkPaint& paint) {
1508 SkBitmap bm; 1510 SkBitmap bm;
1509 if (wrap_as_bm(image, &bm)) { 1511 if (wrap_as_bm(image, &bm)) {
1510 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); 1512 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
1511 } 1513 }
1512 } 1514 }
1513 1515
1514 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src, 1516 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
1515 const SkRect& dst, const SkPaint& paint) { 1517 const SkRect& dst, const SkPaint& paint,
1518 SkCanvas::SrcRectConstraint constraint) {
1516 SkBitmap bm; 1519 SkBitmap bm;
1517 if (wrap_as_bm(image, &bm)) { 1520 if (wrap_as_bm(image, &bm)) {
1518 this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitm apRectFlag); 1521 this->drawBitmapRect(draw, bm, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_T YPE)constraint);
1519 } 1522 }
1520 } 1523 }
1521 1524
1522 /////////////////////////////////////////////////////////////////////////////// 1525 ///////////////////////////////////////////////////////////////////////////////
1523 1526
1524 // must be in SkCanvas::VertexMode order 1527 // must be in SkCanvas::VertexMode order
1525 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { 1528 static const GrPrimitiveType gVertexMode2PrimitiveType[] = {
1526 kTriangles_GrPrimitiveType, 1529 kTriangles_GrPrimitiveType,
1527 kTriangleStrip_GrPrimitiveType, 1530 kTriangleStrip_GrPrimitiveType,
1528 kTriangleFan_GrPrimitiveType, 1531 kTriangleFan_GrPrimitiveType,
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 #endif 1856 #endif
1854 } 1857 }
1855 1858
1856 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1859 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1857 // We always return a transient cache, so it is freed after each 1860 // We always return a transient cache, so it is freed after each
1858 // filter traversal. 1861 // filter traversal.
1859 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1862 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1860 } 1863 }
1861 1864
1862 #endif 1865 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698