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

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 2175873002: remove/deprecate SkBitmap::getTexture, as it now always returns false (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: kill AutoBitmapTexture Created 4 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/GrImageIDTextureAdjuster.cpp ('k') | src/gpu/SkGr.cpp » ('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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 do { \ 60 do { \
61 if (gShouldDrawProc && !gShouldDrawProc()) return; \ 61 if (gShouldDrawProc && !gShouldDrawProc()) return; \
62 this->prepareDraw(draw); \ 62 this->prepareDraw(draw); \
63 } while (0) 63 } while (0)
64 #else 64 #else
65 #define CHECK_SHOULD_DRAW(draw) this->prepareDraw(draw) 65 #define CHECK_SHOULD_DRAW(draw) this->prepareDraw(draw)
66 #endif 66 #endif
67 67
68 /////////////////////////////////////////////////////////////////////////////// 68 ///////////////////////////////////////////////////////////////////////////////
69 69
70 // Helper for turning a bitmap into a texture. If the bitmap is GrTexture backed this
71 // just accesses the backing GrTexture. Otherwise, it creates a cached texture
72 // representation and releases it in the destructor.
73 class AutoBitmapTexture : public SkNoncopyable {
74 public:
75 AutoBitmapTexture() {}
76
77 AutoBitmapTexture(GrContext* context,
78 const SkBitmap& bitmap,
79 const GrTextureParams& params,
80 SkSourceGammaTreatment gammaTreatment,
81 GrTexture** texture) {
82 SkASSERT(texture);
83 *texture = this->set(context, bitmap, params, gammaTreatment);
84 }
85
86 GrTexture* set(GrContext* context,
87 const SkBitmap& bitmap,
88 const GrTextureParams& params,
89 SkSourceGammaTreatment gammaTreatment) {
90 // Either get the texture directly from the bitmap, or else use the cach e and
91 // remember to unref it.
92 if (GrTexture* bmpTexture = bitmap.getTexture()) {
93 fTexture.reset(nullptr);
94 return bmpTexture;
95 } else {
96 fTexture.reset(GrRefCachedBitmapTexture(context, bitmap, params, gam maTreatment));
97 return fTexture.get();
98 }
99 }
100
101 private:
102 SkAutoTUnref<GrTexture> fTexture;
103 };
104
105 ///////////////////////////////////////////////////////////////////////////////
106
107 /** Checks that the alpha type is legal and gets constructor flags. Returns fals e if device creation 70 /** Checks that the alpha type is legal and gets constructor flags. Returns fals e if device creation
108 should fail. */ 71 should fail. */
109 bool SkGpuDevice::CheckAlphaTypeAndGetFlags( 72 bool SkGpuDevice::CheckAlphaTypeAndGetFlags(
110 const SkImageInfo* info, SkGpuDevice::InitContents init, unsigned* flags) { 73 const SkImageInfo* info, SkGpuDevice::InitContents init, unsigned* flags) {
111 *flags = 0; 74 *flags = 0;
112 if (info) { 75 if (info) {
113 switch (info->alphaType()) { 76 switch (info->alphaType()) {
114 case kPremul_SkAlphaType: 77 case kPremul_SkAlphaType:
115 break; 78 break;
116 case kOpaque_SkAlphaType: 79 case kOpaque_SkAlphaType:
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 } 792 }
830 793
831 bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap, 794 bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap,
832 const SkMatrix& viewMatrix, 795 const SkMatrix& viewMatrix,
833 const GrTextureParams& params, 796 const GrTextureParams& params,
834 const SkRect* srcRectPtr, 797 const SkRect* srcRectPtr,
835 int maxTileSize, 798 int maxTileSize,
836 int* tileSize, 799 int* tileSize,
837 SkIRect* clippedSrcRect) const { 800 SkIRect* clippedSrcRect) const {
838 ASSERT_SINGLE_OWNER 801 ASSERT_SINGLE_OWNER
839 // if bitmap is explictly texture backed then just use the texture
840 if (bitmap.getTexture()) {
841 return false;
842 }
843
844 return this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(), viewMatrix, params, 802 return this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(), viewMatrix, params,
845 srcRectPtr, maxTileSize, tileSize, clippedSrc Rect); 803 srcRectPtr, maxTileSize, tileSize, clippedSrc Rect);
846 } 804 }
847 805
848 bool SkGpuDevice::shouldTileImage(const SkImage* image, const SkRect* srcRectPtr , 806 bool SkGpuDevice::shouldTileImage(const SkImage* image, const SkRect* srcRectPtr ,
849 SkCanvas::SrcRectConstraint constraint, SkFilt erQuality quality, 807 SkCanvas::SrcRectConstraint constraint, SkFilt erQuality quality,
850 const SkMatrix& viewMatrix) const { 808 const SkMatrix& viewMatrix) const {
851 ASSERT_SINGLE_OWNER 809 ASSERT_SINGLE_OWNER
852 // if image is explictly texture backed then just use the texture 810 // if image is explictly texture backed then just use the texture
853 if (as_IB(image)->peekTexture()) { 811 if (as_IB(image)->peekTexture()) {
(...skipping 26 matching lines...) Expand all
880 } 838 }
881 839
882 void SkGpuDevice::drawBitmap(const SkDraw& origDraw, 840 void SkGpuDevice::drawBitmap(const SkDraw& origDraw,
883 const SkBitmap& bitmap, 841 const SkBitmap& bitmap,
884 const SkMatrix& m, 842 const SkMatrix& m,
885 const SkPaint& paint) { 843 const SkPaint& paint) {
886 ASSERT_SINGLE_OWNER 844 ASSERT_SINGLE_OWNER
887 CHECK_SHOULD_DRAW(origDraw); 845 CHECK_SHOULD_DRAW(origDraw);
888 SkMatrix viewMatrix; 846 SkMatrix viewMatrix;
889 viewMatrix.setConcat(*origDraw.fMatrix, m); 847 viewMatrix.setConcat(*origDraw.fMatrix, m);
890 if (bitmap.getTexture()) { 848
891 GrBitmapTextureAdjuster adjuster(&bitmap);
892 // We can use kFast here because we know texture-backed bitmaps don't su pport extractSubset.
893 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S rcRectConstraint,
894 viewMatrix, fClip, paint);
895 return;
896 }
897 int maxTileSize = fContext->caps()->maxTileSize(); 849 int maxTileSize = fContext->caps()->maxTileSize();
898 850
899 // The tile code path doesn't currently support AA, so if the paint asked fo r aa and we could 851 // The tile code path doesn't currently support AA, so if the paint asked fo r aa and we could
900 // draw untiled, then we bypass checking for tiling purely for optimization reasons. 852 // draw untiled, then we bypass checking for tiling purely for optimization reasons.
901 bool drawAA = !fDrawContext->isUnifiedMultisampled() && 853 bool drawAA = !fDrawContext->isUnifiedMultisampled() &&
902 paint.isAntiAlias() && 854 paint.isAntiAlias() &&
903 bitmap.width() <= maxTileSize && 855 bitmap.width() <= maxTileSize &&
904 bitmap.height() <= maxTileSize; 856 bitmap.height() <= maxTileSize;
905 857
906 bool skipTileCheck = drawAA || paint.getMaskFilter(); 858 bool skipTileCheck = drawAA || paint.getMaskFilter();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 const SkMatrix& viewMatrix, 1035 const SkMatrix& viewMatrix,
1084 const SkRect& srcRect, 1036 const SkRect& srcRect,
1085 const GrTextureParams& params, 1037 const GrTextureParams& params,
1086 const SkPaint& paint, 1038 const SkPaint& paint,
1087 SkCanvas::SrcRectConstraint constraint, 1039 SkCanvas::SrcRectConstraint constraint,
1088 bool bicubic, 1040 bool bicubic,
1089 bool needsTextureDomain) { 1041 bool needsTextureDomain) {
1090 // We should have already handled bitmaps larger than the max texture size. 1042 // We should have already handled bitmaps larger than the max texture size.
1091 SkASSERT(bitmap.width() <= fContext->caps()->maxTextureSize() && 1043 SkASSERT(bitmap.width() <= fContext->caps()->maxTextureSize() &&
1092 bitmap.height() <= fContext->caps()->maxTextureSize()); 1044 bitmap.height() <= fContext->caps()->maxTextureSize());
1093 // Unless the bitmap is inherently texture-backed, we should be respecting t he max tile size 1045 // We should be respecting the max tile size by the time we get here.
1094 // by the time we get here. 1046 SkASSERT(bitmap.width() <= fContext->caps()->maxTileSize() &&
1095 SkASSERT(bitmap.getTexture() || 1047 bitmap.height() <= fContext->caps()->maxTileSize());
1096 (bitmap.width() <= fContext->caps()->maxTileSize() &&
1097 bitmap.height() <= fContext->caps()->maxTileSize()));
1098 1048
1099 GrTexture* texture;
1100 SkSourceGammaTreatment gammaTreatment = this->surfaceProps().isGammaCorrect( ) 1049 SkSourceGammaTreatment gammaTreatment = this->surfaceProps().isGammaCorrect( )
1101 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore; 1050 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
1102 AutoBitmapTexture abt(fContext, bitmap, params, gammaTreatment, &texture); 1051 sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(fContext, bitmap, param s, gammaTreatment);
1103 if (nullptr == texture) { 1052 if (nullptr == texture) {
1104 return; 1053 return;
1105 } 1054 }
1106 1055
1107 SkColorSpace* dstColorSpace = nullptr; // XFORMTODO 1056 SkColorSpace* dstColorSpace = nullptr; // XFORMTODO
1108 sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(bitmap.co lorSpace(), 1057 sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(bitmap.co lorSpace(),
1109 dstColorS pace); 1058 dstColorS pace);
1110 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; 1059 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() };
1111 SkRect paintRect; 1060 SkRect paintRect;
1112 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); 1061 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width()));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 } 1093 }
1145 if (srcRect.height() > SK_Scalar1) { 1094 if (srcRect.height() > SK_Scalar1) {
1146 SkScalar border = SK_ScalarHalf / texture->height(); 1095 SkScalar border = SK_ScalarHalf / texture->height();
1147 top = paintRect.top() + border; 1096 top = paintRect.top() + border;
1148 bottom = paintRect.bottom() - border; 1097 bottom = paintRect.bottom() - border;
1149 } else { 1098 } else {
1150 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); 1099 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom());
1151 } 1100 }
1152 textureDomain.setLTRB(left, top, right, bottom); 1101 textureDomain.setLTRB(left, top, right, bottom);
1153 if (bicubic) { 1102 if (bicubic) {
1154 fp = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), texM atrix, 1103 fp = GrBicubicEffect::Make(texture.get(), std::move(colorSpaceXform) , texMatrix,
f(malita) 2016/07/25 12:58:15 std::move(texture)?
1155 textureDomain); 1104 textureDomain);
1156 } else { 1105 } else {
1157 fp = GrTextureDomainEffect::Make(texture, std::move(colorSpaceXform) , texMatrix, 1106 fp = GrTextureDomainEffect::Make(texture.get(), std::move(colorSpace Xform), texMatrix,
f(malita) 2016/07/25 12:58:15 ditto
1158 textureDomain, GrTextureDomain::kCl amp_Mode, 1107 textureDomain, GrTextureDomain::kCl amp_Mode,
1159 params.filterMode()); 1108 params.filterMode());
1160 } 1109 }
1161 } else if (bicubic) { 1110 } else if (bicubic) {
1162 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); 1111 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
1163 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() }; 1112 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() };
1164 fp = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), texMatri x, tileModes); 1113 fp = GrBicubicEffect::Make(texture.get(), std::move(colorSpaceXform), te xMatrix, tileModes);
f(malita) 2016/07/25 12:58:15 ditto
1165 } else { 1114 } else {
1166 fp = GrSimpleTextureEffect::Make(texture, std::move(colorSpaceXform), te xMatrix, params); 1115 fp = GrSimpleTextureEffect::Make(texture.get(), std::move(colorSpaceXfor m), texMatrix, params);
f(malita) 2016/07/25 12:58:15 ditto
bsalomon 2016/07/25 13:50:07 We aren't widely using sk_sp for GrResource types
1167 } 1116 }
1168 1117
1169 GrPaint grPaint; 1118 GrPaint grPaint;
1170 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::mo ve(fp), 1119 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::mo ve(fp),
1171 kAlpha_8_SkColorType == bitmap.colorType(), 1120 kAlpha_8_SkColorType == bitmap.colorType(),
1172 this->surfaceProps().isGammaCorrect(), &grP aint)) { 1121 this->surfaceProps().isGammaCorrect(), &grP aint)) {
1173 return; 1122 return;
1174 } 1123 }
1175 1124
1176 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { 1125 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) {
1177 // We don't have local coords in this case and have previously set the t ransform 1126 // We don't have local coords in this case and have previously set the t ransform
1178 // matrices directly on the texture processor. 1127 // matrices directly on the texture processor.
1179 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect); 1128 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect);
1180 } else { 1129 } else {
1181 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR ect); 1130 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR ect);
1182 } 1131 }
1183 } 1132 }
1184 1133
1185 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, 1134 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
1186 int left, int top, const SkPaint& paint) { 1135 int left, int top, const SkPaint& paint) {
1187 ASSERT_SINGLE_OWNER 1136 ASSERT_SINGLE_OWNER
1188 CHECK_SHOULD_DRAW(draw); 1137 CHECK_SHOULD_DRAW(draw);
1189 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawSprite", fContext); 1138 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawSprite", fContext);
1190 1139
1191 if (fContext->abandoned()) { 1140 if (fContext->abandoned()) {
1192 return; 1141 return;
1193 } 1142 }
1194 1143
1195 sk_sp<GrTexture> texture = sk_ref_sp(bitmap.getTexture()); 1144 sk_sp<GrTexture> texture;
1196 if (!texture) { 1145 {
1197 SkAutoLockPixels alp(bitmap, true); 1146 SkAutoLockPixels alp(bitmap, true);
1198 if (!bitmap.readyToDraw()) { 1147 if (!bitmap.readyToDraw()) {
1199 return; 1148 return;
1200 } 1149 }
1201 1150
1202 // draw sprite neither filters nor tiles. 1151 // draw sprite neither filters nor tiles.
1203 texture.reset(GrRefCachedBitmapTexture(fContext, bitmap, 1152 texture.reset(GrRefCachedBitmapTexture(fContext, bitmap,
1204 GrTextureParams::ClampNoFilter(), 1153 GrTextureParams::ClampNoFilter(),
1205 SkSourceGammaTreatment::kRespect) ); 1154 SkSourceGammaTreatment::kRespect) );
1206 if (!texture) { 1155 if (!texture) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 SkIntToScalar(subset.fTop) / t exture->height(), 1224 SkIntToScalar(subset.fTop) / t exture->height(),
1276 SkIntToScalar(subset.width()) / texture->width(), 1225 SkIntToScalar(subset.width()) / texture->width(),
1277 SkIntToScalar(subset.height()) / texture->height())); 1226 SkIntToScalar(subset.height()) / texture->height()));
1278 } 1227 }
1279 1228
1280 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, 1229 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
1281 const SkRect* src, const SkRect& origDst, 1230 const SkRect* src, const SkRect& origDst,
1282 const SkPaint& paint, SkCanvas::SrcRectConstrai nt constraint) { 1231 const SkPaint& paint, SkCanvas::SrcRectConstrai nt constraint) {
1283 ASSERT_SINGLE_OWNER 1232 ASSERT_SINGLE_OWNER
1284 CHECK_SHOULD_DRAW(draw); 1233 CHECK_SHOULD_DRAW(draw);
1285 if (bitmap.getTexture()) { 1234
1286 GrBitmapTextureAdjuster adjuster(&bitmap);
1287 this->drawTextureProducer(&adjuster, src, &origDst, constraint, *draw.fM atrix, fClip,
1288 paint);
1289 return;
1290 }
1291 // The src rect is inferred to be the bmp bounds if not provided. Otherwise, the src rect must 1235 // The src rect is inferred to be the bmp bounds if not provided. Otherwise, the src rect must
1292 // be clipped to the bmp bounds. To determine tiling parameters we need the filter mode which 1236 // be clipped to the bmp bounds. To determine tiling parameters we need the filter mode which
1293 // in turn requires knowing the src-to-dst mapping. If the src was clipped t o the bmp bounds 1237 // in turn requires knowing the src-to-dst mapping. If the src was clipped t o the bmp bounds
1294 // then we use the src-to-dst mapping to compute a new clipped dst rect. 1238 // then we use the src-to-dst mapping to compute a new clipped dst rect.
1295 const SkRect* dst = &origDst; 1239 const SkRect* dst = &origDst;
1296 const SkRect bmpBounds = SkRect::MakeIWH(bitmap.width(), bitmap.height()); 1240 const SkRect bmpBounds = SkRect::MakeIWH(bitmap.width(), bitmap.height());
1297 // Compute matrix from the two rectangles 1241 // Compute matrix from the two rectangles
1298 if (!src) { 1242 if (!src) {
1299 src = &bmpBounds; 1243 src = &bmpBounds;
1300 } 1244 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 this->drawTiledBitmap(bitmap, viewMatrix, *src, clippedSrcRect, para ms, paint, 1303 this->drawTiledBitmap(bitmap, viewMatrix, *src, clippedSrcRect, para ms, paint,
1360 constraint, tileSize, doBicubic); 1304 constraint, tileSize, doBicubic);
1361 return; 1305 return;
1362 } 1306 }
1363 } 1307 }
1364 GrBitmapTextureMaker maker(fContext, bitmap); 1308 GrBitmapTextureMaker maker(fContext, bitmap);
1365 this->drawTextureProducer(&maker, src, dst, constraint, *draw.fMatrix, fClip , paint); 1309 this->drawTextureProducer(&maker, src, dst, constraint, *draw.fMatrix, fClip , paint);
1366 } 1310 }
1367 1311
1368 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) { 1312 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
1369 SkASSERT(!bitmap.getTexture());
1370
1371 SkAutoLockPixels alp(bitmap, true); 1313 SkAutoLockPixels alp(bitmap, true);
1372 if (!bitmap.readyToDraw()) { 1314 if (!bitmap.readyToDraw()) {
1373 return nullptr; 1315 return nullptr;
1374 } 1316 }
1375 1317
1376 GrTexture* texture; 1318 sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(fContext, bitmap,
1377 AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(),» 1319 GrTextureParams::ClampN oFilter(),
1378 SkSourceGammaTreatment::kRespect, &texture); 1320 SkSourceGammaTreatment: :kRespect);
1379 if (!texture) { 1321 if (!texture) {
1380 return nullptr; 1322 return nullptr;
1381 } 1323 }
1382 1324
1383 return SkSpecialImage::MakeFromGpu(bitmap.bounds(), 1325 return SkSpecialImage::MakeFromGpu(bitmap.bounds(),
1384 bitmap.getGenerationID(), 1326 bitmap.getGenerationID(),
robertphillips 2016/07/25 12:08:28 std::move ?
1385 sk_ref_sp(texture), 1327 texture,
1386 sk_ref_sp(bitmap.colorSpace()), 1328 sk_ref_sp(bitmap.colorSpace()),
1387 &this->surfaceProps()); 1329 &this->surfaceProps());
1388 } 1330 }
1389 1331
1390 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) { 1332 sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) {
1391 SkPixmap pm; 1333 SkPixmap pm;
1392 if (image->isTextureBacked()) { 1334 if (image->isTextureBacked()) {
1393 GrTexture* texture = as_IB(image)->peekTexture(); 1335 GrTexture* texture = as_IB(image)->peekTexture();
1394 1336
1395 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(image->width(), image ->height()), 1337 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(image->width(), image ->height()),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 this->drawProducerNine(draw, &maker, center, dst, paint); 1511 this->drawProducerNine(draw, &maker, center, dst, paint);
1570 } else if (as_IB(image)->getROPixels(&bm)) { 1512 } else if (as_IB(image)->getROPixels(&bm)) {
1571 this->drawBitmapNine(draw, bm, center, dst, paint); 1513 this->drawBitmapNine(draw, bm, center, dst, paint);
1572 } 1514 }
1573 } 1515 }
1574 } 1516 }
1575 1517
1576 void SkGpuDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, con st SkIRect& center, 1518 void SkGpuDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, con st SkIRect& center,
1577 const SkRect& dst, const SkPaint& paint) { 1519 const SkRect& dst, const SkPaint& paint) {
1578 ASSERT_SINGLE_OWNER 1520 ASSERT_SINGLE_OWNER
1579 if (bitmap.getTexture()) { 1521 GrBitmapTextureMaker maker(fContext, bitmap);
1580 GrBitmapTextureAdjuster adjuster(&bitmap); 1522 this->drawProducerNine(draw, &maker, center, dst, paint);
1581 this->drawProducerNine(draw, &adjuster, center, dst, paint);
1582 } else {
1583 GrBitmapTextureMaker maker(fContext, bitmap);
1584 this->drawProducerNine(draw, &maker, center, dst, paint);
1585 }
1586 } 1523 }
1587 1524
1588 /////////////////////////////////////////////////////////////////////////////// 1525 ///////////////////////////////////////////////////////////////////////////////
1589 1526
1590 // must be in SkCanvas::VertexMode order 1527 // must be in SkCanvas::VertexMode order
1591 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { 1528 static const GrPrimitiveType gVertexMode2PrimitiveType[] = {
1592 kTriangles_GrPrimitiveType, 1529 kTriangles_GrPrimitiveType,
1593 kTriangleStrip_GrPrimitiveType, 1530 kTriangleStrip_GrPrimitiveType,
1594 kTriangleFan_GrPrimitiveType, 1531 kTriangleFan_GrPrimitiveType,
1595 }; 1532 };
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 } 1808 }
1872 1809
1873 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1810 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1874 ASSERT_SINGLE_OWNER 1811 ASSERT_SINGLE_OWNER
1875 // We always return a transient cache, so it is freed after each 1812 // We always return a transient cache, so it is freed after each
1876 // filter traversal. 1813 // filter traversal.
1877 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1814 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1878 } 1815 }
1879 1816
1880 #endif 1817 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.cpp ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698