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

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

Issue 1001503002: Implement support for mixed sampled render targets (Closed) Base URL: https://skia.googlesource.com/skia.git@mix1
Patch Set: Rebase Created 5 years, 6 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
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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 318
319 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { 319 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
320 // Caller must have accessed the render target, because it knows the rt must be replaced. 320 // Caller must have accessed the render target, because it knows the rt must be replaced.
321 SkASSERT(!fNeedClear); 321 SkASSERT(!fNeedClear);
322 322
323 SkSurface::Budgeted budgeted = 323 SkSurface::Budgeted budgeted =
324 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete d 324 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete d
325 : SkSurface::kNo_Budgeted ; 325 : SkSurface::kNo_Budgeted ;
326 326
327 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( 327 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget(
328 fRenderTarget->getContext(), budgeted, this->imageInfo(), fRenderTarget- >numSamples())); 328 fRenderTarget->getContext(), budgeted, this->imageInfo(), fRenderTarget- >desc().fSampleCnt));
329 329
330 if (NULL == newRT) { 330 if (NULL == newRT) {
331 return; 331 return;
332 } 332 }
333 333
334 if (shouldRetainContent) { 334 if (shouldRetainContent) {
335 if (fRenderTarget->wasDestroyed()) { 335 if (fRenderTarget->wasDestroyed()) {
336 return; 336 return;
337 } 337 }
338 this->context()->copySurface(newRT, fRenderTarget); 338 this->context()->copySurface(newRT, fRenderTarget);
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 } 1675 }
1676 1676
1677 /////////////////////////////////////////////////////////////////////////////// 1677 ///////////////////////////////////////////////////////////////////////////////
1678 1678
1679 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint *) { 1679 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint *) {
1680 GrSurfaceDesc desc; 1680 GrSurfaceDesc desc;
1681 desc.fConfig = fRenderTarget->config(); 1681 desc.fConfig = fRenderTarget->config();
1682 desc.fFlags = kRenderTarget_GrSurfaceFlag; 1682 desc.fFlags = kRenderTarget_GrSurfaceFlag;
1683 desc.fWidth = cinfo.fInfo.width(); 1683 desc.fWidth = cinfo.fInfo.width();
1684 desc.fHeight = cinfo.fInfo.height(); 1684 desc.fHeight = cinfo.fInfo.height();
1685 desc.fSampleCnt = fRenderTarget->numSamples(); 1685 desc.fSampleCnt = fRenderTarget->desc().fSampleCnt;
1686 1686
1687 SkAutoTUnref<GrTexture> texture; 1687 SkAutoTUnref<GrTexture> texture;
1688 // Skia's convention is to only clear a device if it is non-opaque. 1688 // Skia's convention is to only clear a device if it is non-opaque.
1689 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag; 1689 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag;
1690 1690
1691 // layers are never draw in repeat modes, so we can request an approx 1691 // layers are never draw in repeat modes, so we can request an approx
1692 // match and ignore any padding. 1692 // match and ignore any padding.
1693 const GrTextureProvider::ScratchTexMatch match = (kNever_TileUsage == cinfo. fTileUsage) ? 1693 const GrTextureProvider::ScratchTexMatch match = (kNever_TileUsage == cinfo. fTileUsage) ?
1694 GrTextureProvider::kApprox_Scr atchTexMatch : 1694 GrTextureProvider::kApprox_Scr atchTexMatch :
1695 GrTextureProvider::kExact_Scra tchTexMatch; 1695 GrTextureProvider::kExact_Scra tchTexMatch;
1696 texture.reset(fContext->textureProvider()->refScratchTexture(desc, match)); 1696 texture.reset(fContext->textureProvider()->refScratchTexture(desc, match));
1697 1697
1698 if (texture) { 1698 if (texture) {
1699 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry); 1699 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry);
1700 return SkGpuDevice::Create( 1700 return SkGpuDevice::Create(
1701 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, flags); 1701 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, flags);
1702 } else { 1702 } else {
1703 SkErrorInternals::SetError( kInternalError_SkError, 1703 SkErrorInternals::SetError( kInternalError_SkError,
1704 "---- failed to create gpu device texture [% d %d]\n", 1704 "---- failed to create gpu device texture [% d %d]\n",
1705 cinfo.fInfo.width(), cinfo.fInfo.height()); 1705 cinfo.fInfo.width(), cinfo.fInfo.height());
1706 return NULL; 1706 return NULL;
1707 } 1707 }
1708 } 1708 }
1709 1709
1710 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) { 1710 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) {
1711 // TODO: Change the signature of newSurface to take a budgeted parameter. 1711 // TODO: Change the signature of newSurface to take a budgeted parameter.
1712 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; 1712 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted;
1713 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget-> numSamples(), 1713 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget-> desc().fSampleCnt,
1714 &props); 1714 &props);
1715 } 1715 }
1716 1716
1717 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture, 1717 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture,
1718 const SkMatrix* matrix, const SkPaint * paint) { 1718 const SkMatrix* matrix, const SkPaint * paint) {
1719 #ifndef SK_IGNORE_GPU_LAYER_HOISTING 1719 #ifndef SK_IGNORE_GPU_LAYER_HOISTING
1720 // todo: should handle this natively 1720 // todo: should handle this natively
1721 if (paint) { 1721 if (paint) {
1722 return false; 1722 return false;
1723 } 1723 }
(...skipping 19 matching lines...) Expand all
1743 } 1743 }
1744 1744
1745 SkRect clipBounds = SkRect::Make(iBounds); 1745 SkRect clipBounds = SkRect::Make(iBounds);
1746 1746
1747 SkMatrix initialMatrix = mainCanvas->getTotalMatrix(); 1747 SkMatrix initialMatrix = mainCanvas->getTotalMatrix();
1748 1748
1749 GrLayerHoister::FindLayersToAtlas(fContext, mainPicture, 1749 GrLayerHoister::FindLayersToAtlas(fContext, mainPicture,
1750 initialMatrix, 1750 initialMatrix,
1751 clipBounds, 1751 clipBounds,
1752 &atlasedNeedRendering, &atlasedRecycled, 1752 &atlasedNeedRendering, &atlasedRecycled,
1753 fRenderTarget->numSamples()); 1753 fRenderTarget->numColorSamples());
1754 1754
1755 GrLayerHoister::DrawLayersToAtlas(fContext, atlasedNeedRendering); 1755 GrLayerHoister::DrawLayersToAtlas(fContext, atlasedNeedRendering);
1756 1756
1757 SkTDArray<GrHoistedLayer> needRendering, recycled; 1757 SkTDArray<GrHoistedLayer> needRendering, recycled;
1758 1758
1759 SkAutoCanvasMatrixPaint acmp(mainCanvas, matrix, paint, mainPicture->cullRec t()); 1759 SkAutoCanvasMatrixPaint acmp(mainCanvas, matrix, paint, mainPicture->cullRec t());
1760 1760
1761 GrLayerHoister::FindLayersToHoist(fContext, mainPicture, 1761 GrLayerHoister::FindLayersToHoist(fContext, mainPicture,
1762 initialMatrix, 1762 initialMatrix,
1763 clipBounds, 1763 clipBounds,
1764 &needRendering, &recycled, 1764 &needRendering, &recycled,
1765 fRenderTarget->numSamples()); 1765 fRenderTarget->numColorSamples());
1766 1766
1767 GrLayerHoister::DrawLayers(fContext, needRendering); 1767 GrLayerHoister::DrawLayers(fContext, needRendering);
1768 1768
1769 // Render the entire picture using new layers 1769 // Render the entire picture using new layers
1770 GrRecordReplaceDraw(mainPicture, mainCanvas, fContext->getLayerCache(), 1770 GrRecordReplaceDraw(mainPicture, mainCanvas, fContext->getLayerCache(),
1771 initialMatrix, NULL); 1771 initialMatrix, NULL);
1772 1772
1773 GrLayerHoister::UnlockLayers(fContext, needRendering); 1773 GrLayerHoister::UnlockLayers(fContext, needRendering);
1774 GrLayerHoister::UnlockLayers(fContext, recycled); 1774 GrLayerHoister::UnlockLayers(fContext, recycled);
1775 GrLayerHoister::UnlockLayers(fContext, atlasedNeedRendering); 1775 GrLayerHoister::UnlockLayers(fContext, atlasedNeedRendering);
1776 GrLayerHoister::UnlockLayers(fContext, atlasedRecycled); 1776 GrLayerHoister::UnlockLayers(fContext, atlasedRecycled);
1777 1777
1778 return true; 1778 return true;
1779 #else 1779 #else
1780 return false; 1780 return false;
1781 #endif 1781 #endif
1782 } 1782 }
1783 1783
1784 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1784 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1785 // We always return a transient cache, so it is freed after each 1785 // We always return a transient cache, so it is freed after each
1786 // filter traversal. 1786 // filter traversal.
1787 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1787 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1788 } 1788 }
1789 1789
1790 #endif 1790 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698