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

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

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