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

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

Issue 1057693002: Revert of Implement approx-match support in image filter saveLayer() offscreen. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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/gpu/effects/GrMatrixConvolutionEffect.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 "GrBitmapTextContext.h" 10 #include "GrBitmapTextContext.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 struct GrSkDrawProcs : public SkDrawProcs { 114 struct GrSkDrawProcs : public SkDrawProcs {
115 public: 115 public:
116 GrContext* fContext; 116 GrContext* fContext;
117 GrTextContext* fTextContext; 117 GrTextContext* fTextContext;
118 GrFontScaler* fFontScaler; // cached in the skia glyphcache 118 GrFontScaler* fFontScaler; // cached in the skia glyphcache
119 }; 119 };
120 120
121 /////////////////////////////////////////////////////////////////////////////// 121 ///////////////////////////////////////////////////////////////////////////////
122 122
123 SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, const SkSurfaceProps* props , unsigned flags) { 123 SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, const SkSurfaceProps* props , unsigned flags) {
124 return SkGpuDevice::Create(rt, rt->width(), rt->height(), props, flags);
125 }
126
127 SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height,
128 const SkSurfaceProps* props, unsigned flags) {
129 if (!rt || rt->wasDestroyed()) { 124 if (!rt || rt->wasDestroyed()) {
130 return NULL; 125 return NULL;
131 } 126 }
132 return SkNEW_ARGS(SkGpuDevice, (rt, width, height, props, flags)); 127 return SkNEW_ARGS(SkGpuDevice, (rt, props, flags));
133 } 128 }
134 129
135 static SkDeviceProperties surfaceprops_to_deviceprops(const SkSurfaceProps* prop s) { 130 static SkDeviceProperties surfaceprops_to_deviceprops(const SkSurfaceProps* prop s) {
136 if (props) { 131 if (props) {
137 return SkDeviceProperties(props->pixelGeometry()); 132 return SkDeviceProperties(props->pixelGeometry());
138 } else { 133 } else {
139 return SkDeviceProperties(SkDeviceProperties::kLegacyLCD_InitType); 134 return SkDeviceProperties(SkDeviceProperties::kLegacyLCD_InitType);
140 } 135 }
141 } 136 }
142 137
143 static SkSurfaceProps copy_or_default_props(const SkSurfaceProps* props) { 138 static SkSurfaceProps copy_or_default_props(const SkSurfaceProps* props) {
144 if (props) { 139 if (props) {
145 return SkSurfaceProps(*props); 140 return SkSurfaceProps(*props);
146 } else { 141 } else {
147 return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); 142 return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
148 } 143 }
149 } 144 }
150 145
151 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, 146 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, const SkSurfaceProps* props, unsign ed flags)
152 const SkSurfaceProps* props, unsigned flags)
153 : INHERITED(surfaceprops_to_deviceprops(props)) 147 : INHERITED(surfaceprops_to_deviceprops(props))
154 , fSurfaceProps(copy_or_default_props(props)) 148 , fSurfaceProps(copy_or_default_props(props))
155 { 149 {
156 fDrawProcs = NULL; 150 fDrawProcs = NULL;
157 151
158 fContext = SkRef(rt->getContext()); 152 fContext = SkRef(rt->getContext());
159 fNeedClear = flags & kNeedClear_Flag; 153 fNeedClear = flags & kNeedClear_Flag;
160 154
161 fRenderTarget = SkRef(rt); 155 fRenderTarget = SkRef(rt);
162 156
163 SkImageInfo info = rt->surfacePriv().info().makeWH(width, height); 157 SkImageInfo info = rt->surfacePriv().info();
164 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt)); 158 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt));
165 fLegacyBitmap.setInfo(info); 159 fLegacyBitmap.setInfo(info);
166 fLegacyBitmap.setPixelRef(pr)->unref(); 160 fLegacyBitmap.setPixelRef(pr)->unref();
167 161
168 bool useDFT = fSurfaceProps.isUseDistanceFieldFonts(); 162 bool useDFT = fSurfaceProps.isUseDistanceFieldFonts();
169 fTextContext = fContext->createTextContext(fRenderTarget, this, this->getLea kyProperties(), 163 fTextContext = fContext->createTextContext(fRenderTarget, this, this->getLea kyProperties(),
170 useDFT); 164 useDFT);
171 } 165 }
172 166
173 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B udgeted budgeted, 167 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B udgeted budgeted,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 204
211 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete d, 205 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete d,
212 const SkImageInfo& info, int sampleCount, 206 const SkImageInfo& info, int sampleCount,
213 const SkSurfaceProps* props, unsigned flags) { 207 const SkSurfaceProps* props, unsigned flags) {
214 208
215 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(context, budgeted, info, sampleCount)); 209 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(context, budgeted, info, sampleCount));
216 if (NULL == rt) { 210 if (NULL == rt) {
217 return NULL; 211 return NULL;
218 } 212 }
219 213
220 return SkNEW_ARGS(SkGpuDevice, (rt, info.width(), info.height(), props, flag s)); 214 return SkNEW_ARGS(SkGpuDevice, (rt, props, flags));
221 } 215 }
222 216
223 SkGpuDevice::~SkGpuDevice() { 217 SkGpuDevice::~SkGpuDevice() {
224 if (fDrawProcs) { 218 if (fDrawProcs) {
225 delete fDrawProcs; 219 delete fDrawProcs;
226 } 220 }
227 221
228 delete fTextContext; 222 delete fTextContext;
229 223
230 fRenderTarget->unref(); 224 fRenderTarget->unref();
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // setup new clip 729 // setup new clip
736 GrClip clip(clipRect); 730 GrClip clip(clipRect);
737 731
738 // Draw the mask into maskTexture with the path's top-left at the origin usi ng tempPaint. 732 // Draw the mask into maskTexture with the path's top-left at the origin usi ng tempPaint.
739 SkMatrix translate; 733 SkMatrix translate;
740 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); 734 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop);
741 context->drawPath(mask->asRenderTarget(), clip, tempPaint, translate, devPat h, strokeInfo); 735 context->drawPath(mask->asRenderTarget(), clip, tempPaint, translate, devPat h, strokeInfo);
742 return mask; 736 return mask;
743 } 737 }
744 738
745 SkBitmap wrap_texture(GrTexture* texture, int width, int height) { 739 SkBitmap wrap_texture(GrTexture* texture) {
746 SkBitmap result; 740 SkBitmap result;
747 result.setInfo(SkImageInfo::MakeN32Premul(width, height)); 741 result.setInfo(texture->surfacePriv().info());
748 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre f(); 742 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre f();
749 return result; 743 return result;
750 } 744 }
751 745
752 }; 746 };
753 747
754 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, 748 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
755 const SkPaint& paint, const SkMatrix* prePathMatrix, 749 const SkPaint& paint, const SkMatrix* prePathMatrix,
756 bool pathIsMutable) { 750 bool pathIsMutable) {
757 CHECK_FOR_ANNOTATION(paint); 751 CHECK_FOR_ANNOTATION(paint);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 // border does not overlap any pixel centers. Yay! 1090 // border does not overlap any pixel centers. Yay!
1097 return inner != outer; 1091 return inner != outer;
1098 } 1092 }
1099 1093
1100 static bool needs_texture_domain(const SkBitmap& bitmap, 1094 static bool needs_texture_domain(const SkBitmap& bitmap,
1101 const SkRect& srcRect, 1095 const SkRect& srcRect,
1102 GrTextureParams &params, 1096 GrTextureParams &params,
1103 const SkMatrix& contextMatrix, 1097 const SkMatrix& contextMatrix,
1104 bool bicubic) { 1098 bool bicubic) {
1105 bool needsTextureDomain = false; 1099 bool needsTextureDomain = false;
1106 GrTexture* tex = bitmap.getTexture();
1107 int width = tex ? tex->width() : bitmap.width();
1108 int height = tex ? tex->height() : bitmap.height();
1109 1100
1110 if (bicubic || params.filterMode() != GrTextureParams::kNone_FilterMode) { 1101 if (bicubic || params.filterMode() != GrTextureParams::kNone_FilterMode) {
1111 // Need texture domain if drawing a sub rect 1102 // Need texture domain if drawing a sub rect
1112 needsTextureDomain = srcRect.width() < width || 1103 needsTextureDomain = srcRect.width() < bitmap.width() ||
1113 srcRect.height() < height; 1104 srcRect.height() < bitmap.height();
1114 if (!bicubic && needsTextureDomain && contextMatrix.rectStaysRect()) { 1105 if (!bicubic && needsTextureDomain && contextMatrix.rectStaysRect()) {
1115 // sampling is axis-aligned 1106 // sampling is axis-aligned
1116 SkRect transformedRect; 1107 SkRect transformedRect;
1117 contextMatrix.mapRect(&transformedRect, srcRect); 1108 contextMatrix.mapRect(&transformedRect, srcRect);
1118 1109
1119 if (has_aligned_samples(srcRect, transformedRect)) { 1110 if (has_aligned_samples(srcRect, transformedRect)) {
1120 params.setFilterMode(GrTextureParams::kNone_FilterMode); 1111 params.setFilterMode(GrTextureParams::kNone_FilterMode);
1121 needsTextureDomain = false; 1112 needsTextureDomain = false;
1122 } else { 1113 } else {
1123 needsTextureDomain = may_color_bleed(srcRect, transformedRect, c ontextMatrix); 1114 needsTextureDomain = may_color_bleed(srcRect, transformedRect, c ontextMatrix);
(...skipping 14 matching lines...) Expand all
1138 SkRect srcRect; 1129 SkRect srcRect;
1139 SkSize dstSize; 1130 SkSize dstSize;
1140 // If there is no src rect, or the src rect contains the entire bitmap then we're effectively 1131 // If there is no src rect, or the src rect contains the entire bitmap then we're effectively
1141 // in the (easier) bleed case, so update flags. 1132 // in the (easier) bleed case, so update flags.
1142 if (NULL == srcRectPtr) { 1133 if (NULL == srcRectPtr) {
1143 SkScalar w = SkIntToScalar(bitmap.width()); 1134 SkScalar w = SkIntToScalar(bitmap.width());
1144 SkScalar h = SkIntToScalar(bitmap.height()); 1135 SkScalar h = SkIntToScalar(bitmap.height());
1145 dstSize.fWidth = w; 1136 dstSize.fWidth = w;
1146 dstSize.fHeight = h; 1137 dstSize.fHeight = h;
1147 srcRect.set(0, 0, w, h); 1138 srcRect.set(0, 0, w, h);
1139 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBi tmapRectFlag);
1148 } else { 1140 } else {
1149 SkASSERT(dstSizePtr); 1141 SkASSERT(dstSizePtr);
1150 srcRect = *srcRectPtr; 1142 srcRect = *srcRectPtr;
1151 dstSize = *dstSizePtr; 1143 dstSize = *dstSizePtr;
1152 } 1144 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
1153 GrTexture* tex = bitmap.getTexture(); 1145 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height ()) {
1154 int width = tex ? tex->width() : bitmap.width(); 1146 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr awBitmapRectFlag);
1155 int height = tex ? tex->height() : bitmap.height(); 1147 }
1156 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
1157 srcRect.fRight >= width && srcRect.fBottom >= height) {
1158 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBi tmapRectFlag);
1159 } 1148 }
1160 1149
1161 // If the render target is not msaa and draw is antialiased, we call 1150 // If the render target is not msaa and draw is antialiased, we call
1162 // drawRect instead of drawing on the render target directly. 1151 // drawRect instead of drawing on the render target directly.
1163 // FIXME: the tiled bitmap code path doesn't currently support 1152 // FIXME: the tiled bitmap code path doesn't currently support
1164 // anti-aliased edges, we work around that for now by drawing directly 1153 // anti-aliased edges, we work around that for now by drawing directly
1165 // if the image size exceeds maximum texture size. 1154 // if the image size exceeds maximum texture size.
1166 int maxTextureSize = fContext->getMaxTextureSize(); 1155 int maxTextureSize = fContext->getMaxTextureSize();
1167 bool directDraw = fRenderTarget->isMultisampled() || 1156 bool directDraw = fRenderTarget->isMultisampled() ||
1168 !paint.isAntiAlias() || 1157 !paint.isAntiAlias() ||
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); 1467 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType());
1479 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor() ) : 1468 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor() ) :
1480 SkColor2GrColor(paint.getColor()); 1469 SkColor2GrColor(paint.getColor());
1481 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, paintColor, f alse, &grPaint); 1470 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, paintColor, f alse, &grPaint);
1482 1471
1483 fContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dst Rect, 1472 fContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dst Rect,
1484 paintRect); 1473 paintRect);
1485 } 1474 }
1486 1475
1487 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, 1476 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
1488 int width, int height,
1489 const SkImageFilter* filter, 1477 const SkImageFilter* filter,
1490 const SkImageFilter::Context& ctx, 1478 const SkImageFilter::Context& ctx,
1491 SkBitmap* result, SkIPoint* offset) { 1479 SkBitmap* result, SkIPoint* offset) {
1492 SkASSERT(filter); 1480 SkASSERT(filter);
1493 1481
1494 // FIXME: plumb actual surface props such that we don't have to lie about th e flags here 1482 // FIXME: plumb actual surface props such that we don't have to lie about th e flags here
1495 // (https://code.google.com/p/skia/issues/detail?id=3148). 1483 // (https://code.google.com/p/skia/issues/detail?id=3148).
1496 SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties(). pixelGeometry())); 1484 SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties(). pixelGeometry()));
1497 1485
1498 if (filter->canFilterImageGPU()) { 1486 if (filter->canFilterImageGPU()) {
1499 return filter->filterImageGPU(&proxy, wrap_texture(texture, width, heigh t), 1487 return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result , offset);
1500 ctx, result, offset);
1501 } else { 1488 } else {
1502 return false; 1489 return false;
1503 } 1490 }
1504 } 1491 }
1505 1492
1506 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, 1493 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
1507 int left, int top, const SkPaint& paint) { 1494 int left, int top, const SkPaint& paint) {
1508 // drawSprite is defined to be in device coords. 1495 // drawSprite is defined to be in device coords.
1509 CHECK_SHOULD_DRAW(draw); 1496 CHECK_SHOULD_DRAW(draw);
1510 1497
(...skipping 18 matching lines...) Expand all
1529 1516
1530 if (filter) { 1517 if (filter) {
1531 SkIPoint offset = SkIPoint::Make(0, 0); 1518 SkIPoint offset = SkIPoint::Make(0, 0);
1532 SkMatrix matrix(*draw.fMatrix); 1519 SkMatrix matrix(*draw.fMatrix);
1533 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); 1520 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
1534 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); 1521 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height());
1535 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); 1522 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache());
1536 // This cache is transient, and is freed (along with all its contained 1523 // This cache is transient, and is freed (along with all its contained
1537 // textures) when it goes out of scope. 1524 // textures) when it goes out of scope.
1538 SkImageFilter::Context ctx(matrix, clipBounds, cache); 1525 SkImageFilter::Context ctx(matrix, clipBounds, cache);
1539 if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredB itmap, 1526 if (this->filterTexture(fContext, texture, filter, ctx, &filteredBitmap,
1540 &offset)) { 1527 &offset)) {
1541 texture = (GrTexture*) filteredBitmap.getTexture(); 1528 texture = (GrTexture*) filteredBitmap.getTexture();
1542 w = filteredBitmap.width(); 1529 w = filteredBitmap.width();
1543 h = filteredBitmap.height(); 1530 h = filteredBitmap.height();
1544 left += offset.x(); 1531 left += offset.x();
1545 top += offset.y(); 1532 top += offset.y();
1546 } else { 1533 } else {
1547 return; 1534 return;
1548 } 1535 }
1549 } 1536 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 1630
1644 if (filter) { 1631 if (filter) {
1645 SkIPoint offset = SkIPoint::Make(0, 0); 1632 SkIPoint offset = SkIPoint::Make(0, 0);
1646 SkMatrix matrix(*draw.fMatrix); 1633 SkMatrix matrix(*draw.fMatrix);
1647 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); 1634 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
1648 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); 1635 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height());
1649 // This cache is transient, and is freed (along with all its contained 1636 // This cache is transient, and is freed (along with all its contained
1650 // textures) when it goes out of scope. 1637 // textures) when it goes out of scope.
1651 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); 1638 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache());
1652 SkImageFilter::Context ctx(matrix, clipBounds, cache); 1639 SkImageFilter::Context ctx(matrix, clipBounds, cache);
1653 if (this->filterTexture(fContext, devTex, device->width(), device->heigh t(), 1640 if (this->filterTexture(fContext, devTex, filter, ctx, &filteredBitmap,
1654 filter, ctx, &filteredBitmap, &offset)) { 1641 &offset)) {
1655 devTex = filteredBitmap.getTexture(); 1642 devTex = filteredBitmap.getTexture();
1656 w = filteredBitmap.width(); 1643 w = filteredBitmap.width();
1657 h = filteredBitmap.height(); 1644 h = filteredBitmap.height();
1658 x += offset.fX; 1645 x += offset.fX;
1659 y += offset.fY; 1646 y += offset.fY;
1660 } else { 1647 } else {
1661 return; 1648 return;
1662 } 1649 }
1663 } 1650 }
1664 1651
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 SkAutoLockPixels alp(src, !src.getTexture()); 1684 SkAutoLockPixels alp(src, !src.getTexture());
1698 if (!src.getTexture() && !src.readyToDraw()) { 1685 if (!src.getTexture() && !src.readyToDraw()) {
1699 return false; 1686 return false;
1700 } 1687 }
1701 1688
1702 GrTexture* texture; 1689 GrTexture* texture;
1703 // We assume here that the filter will not attempt to tile the src. Otherwis e, this cache lookup 1690 // We assume here that the filter will not attempt to tile the src. Otherwis e, this cache lookup
1704 // must be pushed upstack. 1691 // must be pushed upstack.
1705 AutoBitmapTexture abt(fContext, src, NULL, &texture); 1692 AutoBitmapTexture abt(fContext, src, NULL, &texture);
1706 1693
1707 return this->filterTexture(fContext, texture, src.width(), src.height(), 1694 return this->filterTexture(fContext, texture, filter, ctx, result, offset);
1708 filter, ctx, result, offset);
1709 } 1695 }
1710 1696
1711 /////////////////////////////////////////////////////////////////////////////// 1697 ///////////////////////////////////////////////////////////////////////////////
1712 1698
1713 // must be in SkCanvas::VertexMode order 1699 // must be in SkCanvas::VertexMode order
1714 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { 1700 static const GrPrimitiveType gVertexMode2PrimitiveType[] = {
1715 kTriangles_GrPrimitiveType, 1701 kTriangles_GrPrimitiveType,
1716 kTriangleStrip_GrPrimitiveType, 1702 kTriangleStrip_GrPrimitiveType,
1717 kTriangleFan_GrPrimitiveType, 1703 kTriangleFan_GrPrimitiveType,
1718 }; 1704 };
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 1894
1909 // layers are never draw in repeat modes, so we can request an approx 1895 // layers are never draw in repeat modes, so we can request an approx
1910 // match and ignore any padding. 1896 // match and ignore any padding.
1911 const GrContext::ScratchTexMatch match = (kNever_TileUsage == cinfo.fTileUsa ge) ? 1897 const GrContext::ScratchTexMatch match = (kNever_TileUsage == cinfo.fTileUsa ge) ?
1912 GrContext::kApprox_ScratchTexMat ch : 1898 GrContext::kApprox_ScratchTexMat ch :
1913 GrContext::kExact_ScratchTexMatc h; 1899 GrContext::kExact_ScratchTexMatc h;
1914 texture.reset(fContext->refScratchTexture(desc, match)); 1900 texture.reset(fContext->refScratchTexture(desc, match));
1915 1901
1916 if (texture) { 1902 if (texture) {
1917 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry); 1903 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry);
1918 return SkGpuDevice::Create( 1904 return SkGpuDevice::Create(texture->asRenderTarget(), &props, flags);
1919 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, flags);
1920 } else { 1905 } else {
1921 SkErrorInternals::SetError( kInternalError_SkError, 1906 SkErrorInternals::SetError( kInternalError_SkError,
1922 "---- failed to create compatible device tex ture [%d %d]\n", 1907 "---- failed to create compatible device tex ture [%d %d]\n",
1923 cinfo.fInfo.width(), cinfo.fInfo.height()); 1908 cinfo.fInfo.width(), cinfo.fInfo.height());
1924 return NULL; 1909 return NULL;
1925 } 1910 }
1926 } 1911 }
1927 1912
1928 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) { 1913 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) {
1929 // TODO: Change the signature of newSurface to take a budgeted parameter. 1914 // TODO: Change the signature of newSurface to take a budgeted parameter.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 #endif 1983 #endif
1999 } 1984 }
2000 1985
2001 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1986 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
2002 // We always return a transient cache, so it is freed after each 1987 // We always return a transient cache, so it is freed after each
2003 // filter traversal. 1988 // filter traversal.
2004 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1989 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
2005 } 1990 }
2006 1991
2007 #endif 1992 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/effects/GrMatrixConvolutionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698