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

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

Issue 212933002: Actually identify required saveLayers in SkGpuDevice::EXPERIMENTAL_drawPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review issue Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrPictureUtils.cpp ('k') | tools/PictureRenderer.h » ('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 "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
11 #include "effects/GrTextureDomain.h" 11 #include "effects/GrTextureDomain.h"
12 #include "effects/GrSimpleTextureEffect.h" 12 #include "effects/GrSimpleTextureEffect.h"
13 13
14 #include "GrContext.h" 14 #include "GrContext.h"
15 #include "GrBitmapTextContext.h" 15 #include "GrBitmapTextContext.h"
16 #include "GrDistanceFieldTextContext.h" 16 #include "GrDistanceFieldTextContext.h"
17 #include "GrPictureUtils.h"
17 18
18 #include "SkGrTexturePixelRef.h" 19 #include "SkGrTexturePixelRef.h"
19 20
20 #include "SkBounder.h" 21 #include "SkBounder.h"
21 #include "SkColorFilter.h" 22 #include "SkColorFilter.h"
22 #include "SkDeviceImageFilterProxy.h" 23 #include "SkDeviceImageFilterProxy.h"
23 #include "SkDrawProcs.h" 24 #include "SkDrawProcs.h"
24 #include "SkGlyphCache.h" 25 #include "SkGlyphCache.h"
25 #include "SkImageFilter.h" 26 #include "SkImageFilter.h"
26 #include "SkMaskFilter.h" 27 #include "SkMaskFilter.h"
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 GrPrintf("---- failed to create compatible device texture [%d %d]\n", 1938 GrPrintf("---- failed to create compatible device texture [%d %d]\n",
1938 info.width(), info.height()); 1939 info.width(), info.height());
1939 return NULL; 1940 return NULL;
1940 } 1941 }
1941 } 1942 }
1942 1943
1943 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) { 1944 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) {
1944 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples( )); 1945 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples( ));
1945 } 1946 }
1946 1947
1947 class GPUAccelData : public SkPicture::AccelData {
1948 public:
1949 GPUAccelData(Key key) : INHERITED(key) { }
1950
1951 protected:
1952
1953 private:
1954 typedef SkPicture::AccelData INHERITED;
1955 };
1956
1957 // In the future this may not be a static method if we need to incorporate the 1948 // In the future this may not be a static method if we need to incorporate the
1958 // clip and matrix state into the key 1949 // clip and matrix state into the key
1959 SkPicture::AccelData::Key SkGpuDevice::ComputeAccelDataKey() { 1950 SkPicture::AccelData::Key SkGpuDevice::ComputeAccelDataKey() {
1960 static const SkPicture::AccelData::Key gGPUID = SkPicture::AccelData::Genera teDomain(); 1951 static const SkPicture::AccelData::Key gGPUID = SkPicture::AccelData::Genera teDomain();
1961 1952
1962 return gGPUID; 1953 return gGPUID;
1963 } 1954 }
1964 1955
1965 void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) { 1956 void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) {
1966 SkPicture::AccelData::Key key = ComputeAccelDataKey(); 1957 SkPicture::AccelData::Key key = ComputeAccelDataKey();
1967 1958
1968 GPUAccelData* data = SkNEW_ARGS(GPUAccelData, (key)); 1959 GPUAccelData* data = SkNEW_ARGS(GPUAccelData, (key));
1969 1960
1970 picture->EXPERIMENTAL_addAccelData(data); 1961 picture->EXPERIMENTAL_addAccelData(data);
1962
1963 GatherGPUInfo(picture, data);
1971 } 1964 }
1972 1965
1973 bool SkGpuDevice::EXPERIMENTAL_drawPicture(const SkPicture& picture) { 1966 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkPicture* picture) {
1967
1974 SkPicture::AccelData::Key key = ComputeAccelDataKey(); 1968 SkPicture::AccelData::Key key = ComputeAccelDataKey();
1975 1969
1976 const SkPicture::AccelData* data = picture.EXPERIMENTAL_getAccelData(key); 1970 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key);
1977 if (NULL == data) { 1971 if (NULL == data) {
1978 return false; 1972 return false;
1979 } 1973 }
1980 1974
1981 #if 0
1982 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); 1975 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data);
1976
1977 //#define SK_PRINT_PULL_FORWARD_INFO 1
1978
1979 #ifdef SK_PRINT_PULL_FORWARD_INFO
1980 static bool gPrintedAccelData = false;
1981
1982 if (!gPrintedAccelData) {
1983 for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
1984 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i);
1985
1986 SkDebugf("%d: Width: %d Height: %d SL: %d R: %d hasNestedLayers: %s\ n",
1987 i,
1988 info.fSize.fWidth,
1989 info.fSize.fHeight,
1990 info.fSaveLayerOpID,
1991 info.fRestoreOpID,
1992 info.fHasNestedLayers ? "T" : "F");
1993 }
1994 gPrintedAccelData = true;
1995 }
1996 #endif
1997
1998 SkAutoTArray<bool> pullForward(gpuData->numSaveLayers());
1999 for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
2000 pullForward[i] = false;
2001 }
2002
2003 SkIRect clip;
2004
2005 fClipData.getConservativeBounds(this->width(), this->height(), &clip, NULL);
2006
2007 SkMatrix inv;
2008 if (!fContext->getMatrix().invert(&inv)) {
2009 return false;
2010 }
2011
2012 SkRect r = SkRect::Make(clip);
2013 inv.mapRect(&r);
2014 r.roundOut(&clip);
2015
2016 const SkPicture::OperationList& ops = picture->EXPERIMENTAL_getActiveOps(cli p);
2017
2018 #ifdef SK_PRINT_PULL_FORWARD_INFO
2019 SkDebugf("rect: %d %d %d %d\n", clip.fLeft, clip.fTop, clip.fRight, clip.fBo ttom);
2020 #endif
2021
2022 for (int i = 0; i < ops.numOps(); ++i) {
2023 for (int j = 0; j < gpuData->numSaveLayers(); ++j) {
2024 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(j);
2025
2026 if (ops.offset(i) > info.fSaveLayerOpID && ops.offset(i) < info.fRes toreOpID) {
2027 pullForward[j] = true;
2028 }
2029 }
2030 }
2031
2032 #ifdef SK_PRINT_PULL_FORWARD_INFO
2033 SkDebugf("Need SaveLayers: ");
2034 for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
2035 if (pullForward[i]) {
2036 SkDebugf("%d, ", i);
2037 }
2038 }
2039 SkDebugf("\n");
1983 #endif 2040 #endif
1984 2041
1985 return false; 2042 return false;
1986 } 2043 }
OLDNEW
« no previous file with comments | « src/gpu/GrPictureUtils.cpp ('k') | tools/PictureRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698