Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 | 115 |
| 116 struct GrSkDrawProcs : public SkDrawProcs { | 116 struct GrSkDrawProcs : public SkDrawProcs { |
| 117 public: | 117 public: |
| 118 GrContext* fContext; | 118 GrContext* fContext; |
| 119 GrTextContext* fTextContext; | 119 GrTextContext* fTextContext; |
| 120 GrFontScaler* fFontScaler; // cached in the skia glyphcache | 120 GrFontScaler* fFontScaler; // cached in the skia glyphcache |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 /////////////////////////////////////////////////////////////////////////////// | 123 /////////////////////////////////////////////////////////////////////////////// |
| 124 | 124 |
| 125 SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, const SkSurfaceProps* props , unsigned flags) { | 125 /** Checks that the alpha type is legal and gets constructor flags. Returns fals e if device creation |
| 126 return SkGpuDevice::Create(rt, rt->width(), rt->height(), props, flags); | 126 should fail. */ |
| 127 bool SkGpuDevice::CheckAlphaTypeAndGetFlags( | |
| 128 const SkImageInfo* info, SkGpuDevice::InitContents init, unsigned* flags) { | |
| 129 *flags = 0; | |
| 130 if (info) { | |
| 131 switch (info->alphaType()) { | |
| 132 case kPremul_SkAlphaType: | |
| 133 break; | |
| 134 case kOpaque_SkAlphaType: | |
| 135 *flags |= SkGpuDevice::kIsOpaque_Flag; | |
| 136 break; | |
| 137 default: | |
|
robertphillips
2015/06/23 19:48:09
// If it is unpremul or unknown don't try to rende
bsalomon
2015/06/25 21:47:17
Done.
| |
| 138 return false; | |
| 139 } | |
| 140 } | |
| 141 if (kClear_InitContents == init) { | |
| 142 *flags |= kNeedClear_Flag; | |
| 143 } | |
| 144 return true; | |
| 145 } | |
| 146 | |
| 147 SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, const SkSurfaceProps* props , | |
| 148 InitContents init) { | |
| 149 return SkGpuDevice::Create(rt, rt->width(), rt->height(), props, init); | |
| 127 } | 150 } |
| 128 | 151 |
| 129 SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height, | 152 SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height, |
| 130 const SkSurfaceProps* props, unsigned flags) { | 153 const SkSurfaceProps* props, InitContents init) { |
| 131 if (!rt || rt->wasDestroyed()) { | 154 if (!rt || rt->wasDestroyed()) { |
| 132 return NULL; | 155 return NULL; |
| 133 } | 156 } |
| 157 unsigned flags; | |
| 158 if (!CheckAlphaTypeAndGetFlags(NULL, init, &flags)) { | |
| 159 return NULL; | |
| 160 } | |
| 134 return SkNEW_ARGS(SkGpuDevice, (rt, width, height, props, flags)); | 161 return SkNEW_ARGS(SkGpuDevice, (rt, width, height, props, flags)); |
| 135 } | 162 } |
| 136 | 163 |
| 164 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete d, | |
| 165 const SkImageInfo& info, int sampleCount, | |
| 166 const SkSurfaceProps* props, InitContents init) { | |
| 167 | |
| 168 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(context, budgeted, info, sampleCount)); | |
| 169 if (NULL == rt) { | |
| 170 return NULL; | |
| 171 } | |
| 172 | |
|
robertphillips
2015/06/23 19:48:09
Should we change the alpha type & flags first ?
bsalomon
2015/06/25 21:47:17
Done.
| |
| 173 unsigned flags; | |
| 174 if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) { | |
| 175 return NULL; | |
| 176 } | |
| 177 | |
| 178 return SkNEW_ARGS(SkGpuDevice, (rt, info.width(), info.height(), props, flag s)); | |
| 179 } | |
| 180 | |
| 137 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, | 181 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, |
| 138 const SkSurfaceProps* props, unsigned flags) | 182 const SkSurfaceProps* props, unsigned flags) |
| 139 : INHERITED(SkSurfacePropsCopyOrDefault(props)) | 183 : INHERITED(SkSurfacePropsCopyOrDefault(props)) |
| 140 { | 184 { |
| 141 fDrawProcs = NULL; | 185 fDrawProcs = NULL; |
| 142 | 186 |
| 143 fContext = SkRef(rt->getContext()); | 187 fContext = SkRef(rt->getContext()); |
| 144 fNeedClear = flags & kNeedClear_Flag; | 188 fNeedClear = SkToBool(flags & kNeedClear_Flag); |
| 189 fOpaque = SkToBool(flags & kIsOpaque_Flag); | |
| 145 | 190 |
| 146 fRenderTarget = SkRef(rt); | 191 fRenderTarget = SkRef(rt); |
| 147 | 192 |
| 148 SkImageInfo info = rt->surfacePriv().info().makeWH(width, height); | 193 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
| 194 SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height); | |
|
robertphillips
2015/06/23 19:48:09
Why do we need this ?
bsalomon
2015/06/25 21:47:17
oops, needed before I added the param to info().
| |
| 195 if (fOpaque) { | |
| 196 info = info.makeAlphaType(kOpaque_SkAlphaType); | |
| 197 } | |
| 149 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt)); | 198 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt)); |
| 150 fLegacyBitmap.setInfo(info); | 199 fLegacyBitmap.setInfo(info); |
| 151 fLegacyBitmap.setPixelRef(pr)->unref(); | 200 fLegacyBitmap.setPixelRef(pr)->unref(); |
| 152 | 201 |
| 153 fDrawContext.reset(SkRef(fContext->drawContext(&this->surfaceProps()))); | 202 fDrawContext.reset(SkRef(fContext->drawContext(&this->surfaceProps()))); |
| 154 } | 203 } |
| 155 | 204 |
| 156 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B udgeted budgeted, | 205 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B udgeted budgeted, |
| 157 const SkImageInfo& origInfo, int sampleCount) { | 206 const SkImageInfo& origInfo, int sampleCount) { |
| 158 if (kUnknown_SkColorType == origInfo.colorType() || | 207 if (kUnknown_SkColorType == origInfo.colorType() || |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 185 desc.fSampleCnt = sampleCount; | 234 desc.fSampleCnt = sampleCount; |
| 186 GrTexture* texture = context->textureProvider()->createTexture( | 235 GrTexture* texture = context->textureProvider()->createTexture( |
| 187 desc, SkToBool(budgeted), NULL, 0); | 236 desc, SkToBool(budgeted), NULL, 0); |
| 188 if (NULL == texture) { | 237 if (NULL == texture) { |
| 189 return NULL; | 238 return NULL; |
| 190 } | 239 } |
| 191 SkASSERT(NULL != texture->asRenderTarget()); | 240 SkASSERT(NULL != texture->asRenderTarget()); |
| 192 return texture->asRenderTarget(); | 241 return texture->asRenderTarget(); |
| 193 } | 242 } |
| 194 | 243 |
| 195 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete d, | |
| 196 const SkImageInfo& info, int sampleCount, | |
| 197 const SkSurfaceProps* props, unsigned flags) { | |
| 198 | |
| 199 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(context, budgeted, info, sampleCount)); | |
| 200 if (NULL == rt) { | |
| 201 return NULL; | |
| 202 } | |
| 203 | |
| 204 return SkNEW_ARGS(SkGpuDevice, (rt, info.width(), info.height(), props, flag s)); | |
| 205 } | |
| 206 | |
| 207 SkGpuDevice::~SkGpuDevice() { | 244 SkGpuDevice::~SkGpuDevice() { |
| 208 if (fDrawProcs) { | 245 if (fDrawProcs) { |
| 209 delete fDrawProcs; | 246 delete fDrawProcs; |
| 210 } | 247 } |
| 211 | 248 |
| 212 fRenderTarget->unref(); | 249 fRenderTarget->unref(); |
| 213 fContext->unref(); | 250 fContext->unref(); |
| 214 } | 251 } |
| 215 | 252 |
| 216 /////////////////////////////////////////////////////////////////////////////// | 253 /////////////////////////////////////////////////////////////////////////////// |
| 217 | 254 |
| 218 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes, | 255 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes, |
| 219 int x, int y) { | 256 int x, int y) { |
| 220 DO_DEFERRED_CLEAR(); | 257 DO_DEFERRED_CLEAR(); |
| 221 | 258 |
| 222 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels | 259 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels |
| 223 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo); | 260 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo); |
| 224 if (kUnknown_GrPixelConfig == config) { | 261 if (kUnknown_GrPixelConfig == config) { |
| 225 return false; | 262 return false; |
| 226 } | 263 } |
| 227 | 264 |
| 228 uint32_t flags = 0; | 265 uint32_t flags = 0; |
| 229 if (kUnpremul_SkAlphaType == dstInfo.alphaType()) { | 266 if (kUnpremul_SkAlphaType == dstInfo.alphaType()) { |
| 230 flags = GrContext::kUnpremul_PixelOpsFlag; | 267 flags = GrContext::kUnpremul_PixelOpsFlag; |
| 231 } | 268 } |
| 232 return fContext->readRenderTargetPixels(fRenderTarget, x, y, dstInfo.width() , dstInfo.height(), | 269 return fRenderTarget->readPixels(x, y, dstInfo.width(), dstInfo.height(), co nfig, dstPixels, |
| 233 config, dstPixels, dstRowBytes, flag s); | 270 dstRowBytes, flags); |
| 234 } | 271 } |
| 235 | 272 |
| 236 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz e_t rowBytes, | 273 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz e_t rowBytes, |
| 237 int x, int y) { | 274 int x, int y) { |
| 238 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels | 275 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels |
| 239 GrPixelConfig config = SkImageInfo2GrPixelConfig(info); | 276 GrPixelConfig config = SkImageInfo2GrPixelConfig(info); |
| 240 if (kUnknown_GrPixelConfig == config) { | 277 if (kUnknown_GrPixelConfig == config) { |
| 241 return false; | 278 return false; |
| 242 } | 279 } |
| 243 uint32_t flags = 0; | 280 uint32_t flags = 0; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 return; | 361 return; |
| 325 } | 362 } |
| 326 this->context()->copySurface(newRT, fRenderTarget); | 363 this->context()->copySurface(newRT, fRenderTarget); |
| 327 } | 364 } |
| 328 | 365 |
| 329 SkASSERT(fRenderTarget != newRT); | 366 SkASSERT(fRenderTarget != newRT); |
| 330 | 367 |
| 331 fRenderTarget->unref(); | 368 fRenderTarget->unref(); |
| 332 fRenderTarget = newRT.detach(); | 369 fRenderTarget = newRT.detach(); |
| 333 | 370 |
| 334 SkASSERT(fRenderTarget->surfacePriv().info() == fLegacyBitmap.info()); | 371 #ifdef SK_DEBUG |
| 335 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (fRenderTarget->surfacePriv().info (), fRenderTarget)); | 372 SkImageInfo info = fRenderTarget->surfacePriv().info(fOpaque ? kOpaque_SkAlp haType : |
| 373 kPremul_SkAlp haType); | |
| 374 SkASSERT(info == fLegacyBitmap.info()); | |
| 375 #endif | |
| 376 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (fLegacyBitmap.info(), fRenderTarg et)); | |
| 336 fLegacyBitmap.setPixelRef(pr)->unref(); | 377 fLegacyBitmap.setPixelRef(pr)->unref(); |
| 337 | 378 |
| 338 fDrawContext.reset(SkRef(fRenderTarget->getContext()->drawContext(&this->sur faceProps()))); | 379 fDrawContext.reset(SkRef(fRenderTarget->getContext()->drawContext(&this->sur faceProps()))); |
| 339 } | 380 } |
| 340 | 381 |
| 341 /////////////////////////////////////////////////////////////////////////////// | 382 /////////////////////////////////////////////////////////////////////////////// |
| 342 | 383 |
| 343 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 384 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
| 344 CHECK_SHOULD_DRAW(draw); | 385 CHECK_SHOULD_DRAW(draw); |
| 345 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); | 386 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 | 696 |
| 656 if (maxTileTotalTileSize > 2 * smallTotalTileSize) { | 697 if (maxTileTotalTileSize > 2 * smallTotalTileSize) { |
| 657 return kBmpSmallTileSize; | 698 return kBmpSmallTileSize; |
| 658 } else { | 699 } else { |
| 659 return maxTileSize; | 700 return maxTileSize; |
| 660 } | 701 } |
| 661 } | 702 } |
| 662 | 703 |
| 663 // Given a bitmap, an optional src rect, and a context with a clip and matrix de termine what | 704 // Given a bitmap, an optional src rect, and a context with a clip and matrix de termine what |
| 664 // pixels from the bitmap are necessary. | 705 // pixels from the bitmap are necessary. |
| 665 static void determine_clipped_src_rect(const GrContext* context, | 706 static void determine_clipped_src_rect(const GrRenderTarget* rt, |
| 666 const GrRenderTarget* rt, | |
| 667 const GrClip& clip, | 707 const GrClip& clip, |
| 668 const SkMatrix& viewMatrix, | 708 const SkMatrix& viewMatrix, |
| 669 const SkBitmap& bitmap, | 709 const SkBitmap& bitmap, |
| 670 const SkRect* srcRectPtr, | 710 const SkRect* srcRectPtr, |
| 671 SkIRect* clippedSrcIRect) { | 711 SkIRect* clippedSrcIRect) { |
| 672 clip.getConservativeBounds(rt, clippedSrcIRect, NULL); | 712 clip.getConservativeBounds(rt, clippedSrcIRect, NULL); |
| 673 SkMatrix inv; | 713 SkMatrix inv; |
| 674 if (!viewMatrix.invert(&inv)) { | 714 if (!viewMatrix.invert(&inv)) { |
| 675 clippedSrcIRect->setEmpty(); | 715 clippedSrcIRect->setEmpty(); |
| 676 return; | 716 return; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 699 int maxTileSize, | 739 int maxTileSize, |
| 700 int* tileSize, | 740 int* tileSize, |
| 701 SkIRect* clippedSrcRect) const { | 741 SkIRect* clippedSrcRect) const { |
| 702 // if bitmap is explictly texture backed then just use the texture | 742 // if bitmap is explictly texture backed then just use the texture |
| 703 if (bitmap.getTexture()) { | 743 if (bitmap.getTexture()) { |
| 704 return false; | 744 return false; |
| 705 } | 745 } |
| 706 | 746 |
| 707 // if it's larger than the max tile size, then we have no choice but tiling. | 747 // if it's larger than the max tile size, then we have no choice but tiling. |
| 708 if (bitmap.width() > maxTileSize || bitmap.height() > maxTileSize) { | 748 if (bitmap.width() > maxTileSize || bitmap.height() > maxTileSize) { |
| 709 determine_clipped_src_rect(fContext, fRenderTarget, fClip, viewMatrix, b itmap, | 749 determine_clipped_src_rect(fRenderTarget, fClip, viewMatrix, bitmap, |
| 710 srcRectPtr, clippedSrcRect); | 750 srcRectPtr, clippedSrcRect); |
| 711 *tileSize = determine_tile_size(bitmap, *clippedSrcRect, maxTileSize); | 751 *tileSize = determine_tile_size(bitmap, *clippedSrcRect, maxTileSize); |
| 712 return true; | 752 return true; |
| 713 } | 753 } |
| 714 | 754 |
| 715 if (bitmap.width() * bitmap.height() < 4 * kBmpSmallTileSize * kBmpSmallTile Size) { | 755 if (bitmap.width() * bitmap.height() < 4 * kBmpSmallTileSize * kBmpSmallTile Size) { |
| 716 return false; | 756 return false; |
| 717 } | 757 } |
| 718 | 758 |
| 719 // if the entire texture is already in our cache then no reason to tile it | 759 // if the entire texture is already in our cache then no reason to tile it |
| 720 if (GrIsBitmapInCache(fContext, bitmap, ¶ms)) { | 760 if (GrIsBitmapInCache(fContext, bitmap, ¶ms)) { |
| 721 return false; | 761 return false; |
| 722 } | 762 } |
| 723 | 763 |
| 724 // At this point we know we could do the draw by uploading the entire bitmap | 764 // At this point we know we could do the draw by uploading the entire bitmap |
| 725 // as a texture. However, if the texture would be large compared to the | 765 // as a texture. However, if the texture would be large compared to the |
| 726 // cache size and we don't require most of it for this draw then tile to | 766 // cache size and we don't require most of it for this draw then tile to |
| 727 // reduce the amount of upload and cache spill. | 767 // reduce the amount of upload and cache spill. |
| 728 | 768 |
| 729 // assumption here is that sw bitmap size is a good proxy for its size as | 769 // assumption here is that sw bitmap size is a good proxy for its size as |
| 730 // a texture | 770 // a texture |
| 731 size_t bmpSize = bitmap.getSize(); | 771 size_t bmpSize = bitmap.getSize(); |
| 732 size_t cacheSize; | 772 size_t cacheSize; |
| 733 fContext->getResourceCacheLimits(NULL, &cacheSize); | 773 fContext->getResourceCacheLimits(NULL, &cacheSize); |
| 734 if (bmpSize < cacheSize / 2) { | 774 if (bmpSize < cacheSize / 2) { |
| 735 return false; | 775 return false; |
| 736 } | 776 } |
| 737 | 777 |
| 738 // Figure out how much of the src we will need based on the src rect and cli pping. | 778 // Figure out how much of the src we will need based on the src rect and cli pping. |
| 739 determine_clipped_src_rect(fContext, fRenderTarget, fClip, viewMatrix, bitma p, srcRectPtr, | 779 determine_clipped_src_rect(fRenderTarget, fClip, viewMatrix, bitmap, srcRect Ptr, |
| 740 clippedSrcRect); | 780 clippedSrcRect); |
| 741 *tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max sized tile. | 781 *tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max sized tile. |
| 742 size_t usedTileBytes = get_tile_count(*clippedSrcRect, kBmpSmallTileSize) * | 782 size_t usedTileBytes = get_tile_count(*clippedSrcRect, kBmpSmallTileSize) * |
| 743 kBmpSmallTileSize * kBmpSmallTileSize; | 783 kBmpSmallTileSize * kBmpSmallTileSize; |
| 744 | 784 |
| 745 return usedTileBytes < 2 * bmpSize; | 785 return usedTileBytes < 2 * bmpSize; |
| 746 } | 786 } |
| 747 | 787 |
| 748 void SkGpuDevice::drawBitmap(const SkDraw& origDraw, | 788 void SkGpuDevice::drawBitmap(const SkDraw& origDraw, |
| 749 const SkBitmap& bitmap, | 789 const SkBitmap& bitmap, |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1665 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint *) { | 1705 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint *) { |
| 1666 GrSurfaceDesc desc; | 1706 GrSurfaceDesc desc; |
| 1667 desc.fConfig = fRenderTarget->config(); | 1707 desc.fConfig = fRenderTarget->config(); |
| 1668 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 1708 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 1669 desc.fWidth = cinfo.fInfo.width(); | 1709 desc.fWidth = cinfo.fInfo.width(); |
| 1670 desc.fHeight = cinfo.fInfo.height(); | 1710 desc.fHeight = cinfo.fInfo.height(); |
| 1671 desc.fSampleCnt = fRenderTarget->desc().fSampleCnt; | 1711 desc.fSampleCnt = fRenderTarget->desc().fSampleCnt; |
| 1672 | 1712 |
| 1673 SkAutoTUnref<GrTexture> texture; | 1713 SkAutoTUnref<GrTexture> texture; |
| 1674 // Skia's convention is to only clear a device if it is non-opaque. | 1714 // Skia's convention is to only clear a device if it is non-opaque. |
| 1675 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag; | 1715 InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_I nitContents; |
| 1676 | 1716 |
| 1677 // layers are never draw in repeat modes, so we can request an approx | 1717 // layers are never draw in repeat modes, so we can request an approx |
| 1678 // match and ignore any padding. | 1718 // match and ignore any padding. |
| 1679 const GrTextureProvider::ScratchTexMatch match = (kNever_TileUsage == cinfo. fTileUsage) ? | 1719 const GrTextureProvider::ScratchTexMatch match = (kNever_TileUsage == cinfo. fTileUsage) ? |
| 1680 GrTextureProvider::kApprox_Scr atchTexMatch : | 1720 GrTextureProvider::kApprox_Scr atchTexMatch : |
| 1681 GrTextureProvider::kExact_Scra tchTexMatch; | 1721 GrTextureProvider::kExact_Scra tchTexMatch; |
| 1682 texture.reset(fContext->textureProvider()->refScratchTexture(desc, match)); | 1722 texture.reset(fContext->textureProvider()->refScratchTexture(desc, match)); |
| 1683 | 1723 |
| 1684 if (texture) { | 1724 if (texture) { |
| 1685 SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry) ; | 1725 SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry) ; |
| 1686 return SkGpuDevice::Create( | 1726 return SkGpuDevice::Create( |
| 1687 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, flags); | 1727 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, init); |
| 1688 } else { | 1728 } else { |
| 1689 SkErrorInternals::SetError( kInternalError_SkError, | 1729 SkErrorInternals::SetError( kInternalError_SkError, |
| 1690 "---- failed to create gpu device texture [% d %d]\n", | 1730 "---- failed to create gpu device texture [% d %d]\n", |
| 1691 cinfo.fInfo.width(), cinfo.fInfo.height()); | 1731 cinfo.fInfo.width(), cinfo.fInfo.height()); |
| 1692 return NULL; | 1732 return NULL; |
| 1693 } | 1733 } |
| 1694 } | 1734 } |
| 1695 | 1735 |
| 1696 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) { | 1736 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) { |
| 1697 // TODO: Change the signature of newSurface to take a budgeted parameter. | 1737 // TODO: Change the signature of newSurface to take a budgeted parameter. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1767 #endif | 1807 #endif |
| 1768 } | 1808 } |
| 1769 | 1809 |
| 1770 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1810 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
| 1771 // We always return a transient cache, so it is freed after each | 1811 // We always return a transient cache, so it is freed after each |
| 1772 // filter traversal. | 1812 // filter traversal. |
| 1773 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1813 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
| 1774 } | 1814 } |
| 1775 | 1815 |
| 1776 #endif | 1816 #endif |
| OLD | NEW |