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

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: Handle numSamples cases in SkGpuDevice 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
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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { 316 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
317 // Caller must have accessed the render target, because it knows the rt must be replaced. 317 // Caller must have accessed the render target, because it knows the rt must be replaced.
318 SkASSERT(!fNeedClear); 318 SkASSERT(!fNeedClear);
319 319
320 SkSurface::Budgeted budgeted = 320 SkSurface::Budgeted budgeted =
321 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete d 321 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete d
322 : SkSurface::kNo_Budgeted ; 322 : SkSurface::kNo_Budgeted ;
323 323
324 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( 324 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget(
325 fRenderTarget->getContext(), budgeted, this->imageInfo(), fRenderTarget- >numSamples())); 325 fRenderTarget->getContext(), budgeted, this->imageInfo(), fRenderTarget- >desc().fSampleCnt));
326 326
327 if (NULL == newRT) { 327 if (NULL == newRT) {
328 return; 328 return;
329 } 329 }
330 330
331 if (shouldRetainContent) { 331 if (shouldRetainContent) {
332 if (fRenderTarget->wasDestroyed()) { 332 if (fRenderTarget->wasDestroyed()) {
333 return; 333 return;
334 } 334 }
335 this->context()->copySurface(newRT, fRenderTarget); 335 this->context()->copySurface(newRT, fRenderTarget);
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 } 1928 }
1929 1929
1930 /////////////////////////////////////////////////////////////////////////////// 1930 ///////////////////////////////////////////////////////////////////////////////
1931 1931
1932 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint *) { 1932 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint *) {
1933 GrSurfaceDesc desc; 1933 GrSurfaceDesc desc;
1934 desc.fConfig = fRenderTarget->config(); 1934 desc.fConfig = fRenderTarget->config();
1935 desc.fFlags = kRenderTarget_GrSurfaceFlag; 1935 desc.fFlags = kRenderTarget_GrSurfaceFlag;
1936 desc.fWidth = cinfo.fInfo.width(); 1936 desc.fWidth = cinfo.fInfo.width();
1937 desc.fHeight = cinfo.fInfo.height(); 1937 desc.fHeight = cinfo.fInfo.height();
1938 desc.fSampleCnt = fRenderTarget->numSamples(); 1938 desc.fSampleCnt = fRenderTarget->desc().fSampleCnt;
1939 1939
1940 SkAutoTUnref<GrTexture> texture; 1940 SkAutoTUnref<GrTexture> texture;
1941 // Skia's convention is to only clear a device if it is non-opaque. 1941 // Skia's convention is to only clear a device if it is non-opaque.
1942 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag; 1942 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag;
1943 1943
1944 // layers are never draw in repeat modes, so we can request an approx 1944 // layers are never draw in repeat modes, so we can request an approx
1945 // match and ignore any padding. 1945 // match and ignore any padding.
1946 const GrContext::ScratchTexMatch match = (kNever_TileUsage == cinfo.fTileUsa ge) ? 1946 const GrContext::ScratchTexMatch match = (kNever_TileUsage == cinfo.fTileUsa ge) ?
1947 GrContext::kApprox_ScratchTexMat ch : 1947 GrContext::kApprox_ScratchTexMat ch :
1948 GrContext::kExact_ScratchTexMatc h; 1948 GrContext::kExact_ScratchTexMatc h;
1949 texture.reset(fContext->refScratchTexture(desc, match)); 1949 texture.reset(fContext->refScratchTexture(desc, match));
1950 1950
1951 if (texture) { 1951 if (texture) {
1952 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry); 1952 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry);
1953 return SkGpuDevice::Create( 1953 return SkGpuDevice::Create(
1954 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, flags); 1954 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, flags);
1955 } else { 1955 } else {
1956 SkErrorInternals::SetError( kInternalError_SkError, 1956 SkErrorInternals::SetError( kInternalError_SkError,
1957 "---- failed to create compatible device tex ture [%d %d]\n", 1957 "---- failed to create compatible device tex ture [%d %d]\n",
1958 cinfo.fInfo.width(), cinfo.fInfo.height()); 1958 cinfo.fInfo.width(), cinfo.fInfo.height());
1959 return NULL; 1959 return NULL;
1960 } 1960 }
1961 } 1961 }
1962 1962
1963 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) { 1963 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) {
1964 // TODO: Change the signature of newSurface to take a budgeted parameter. 1964 // TODO: Change the signature of newSurface to take a budgeted parameter.
1965 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; 1965 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted;
1966 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget-> numSamples(), 1966 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget-> desc().fSampleCnt,
1967 &props); 1967 &props);
1968 } 1968 }
1969 1969
1970 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture, 1970 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture,
1971 const SkMatrix* matrix, const SkPaint * paint) { 1971 const SkMatrix* matrix, const SkPaint * paint) {
1972 #ifndef SK_IGNORE_GPU_LAYER_HOISTING 1972 #ifndef SK_IGNORE_GPU_LAYER_HOISTING
1973 // todo: should handle this natively 1973 // todo: should handle this natively
1974 if (paint) { 1974 if (paint) {
1975 return false; 1975 return false;
1976 } 1976 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 #endif 2033 #endif
2034 } 2034 }
2035 2035
2036 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 2036 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
2037 // We always return a transient cache, so it is freed after each 2037 // We always return a transient cache, so it is freed after each
2038 // filter traversal. 2038 // filter traversal.
2039 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 2039 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
2040 } 2040 }
2041 2041
2042 #endif 2042 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698