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

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

Issue 266203003: Infrastructure changes to support pull saveLayers forward task (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fixed Android error Created 6 years, 7 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') | tests/PictureTest.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 "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 GrPrintf("---- failed to create compatible device texture [%d %d]\n", 1903 GrPrintf("---- failed to create compatible device texture [%d %d]\n",
1904 info.width(), info.height()); 1904 info.width(), info.height());
1905 return NULL; 1905 return NULL;
1906 } 1906 }
1907 } 1907 }
1908 1908
1909 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) { 1909 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) {
1910 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples( )); 1910 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples( ));
1911 } 1911 }
1912 1912
1913 // In the future this may not be a static method if we need to incorporate the
1914 // clip and matrix state into the key
1915 SkPicture::AccelData::Key SkGpuDevice::ComputeAccelDataKey() {
1916 static const SkPicture::AccelData::Key gGPUID = SkPicture::AccelData::Genera teDomain();
1917
1918 return gGPUID;
1919 }
1920
1921 void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) { 1913 void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) {
1922 SkPicture::AccelData::Key key = ComputeAccelDataKey(); 1914 SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey();
1923 1915
1924 GPUAccelData* data = SkNEW_ARGS(GPUAccelData, (key)); 1916 GPUAccelData* data = SkNEW_ARGS(GPUAccelData, (key));
1925 1917
1926 picture->EXPERIMENTAL_addAccelData(data); 1918 picture->EXPERIMENTAL_addAccelData(data);
1927 1919
1928 GatherGPUInfo(picture, data); 1920 GatherGPUInfo(picture, data);
1929 } 1921 }
1930 1922
1931 void SkGpuDevice::EXPERIMENTAL_purge(SkPicture* picture) { 1923 void SkGpuDevice::EXPERIMENTAL_purge(SkPicture* picture) {
1932 1924
1933 } 1925 }
1934 1926
1935 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) { 1927 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) {
1936 1928
1937 SkPicture::AccelData::Key key = ComputeAccelDataKey(); 1929 SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey();
1938 1930
1939 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key); 1931 const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key);
1940 if (NULL == data) { 1932 if (NULL == data) {
1941 return false; 1933 return false;
1942 } 1934 }
1943 1935
1944 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); 1936 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data);
1945 1937
1946 //#define SK_PRINT_PULL_FORWARD_INFO 1
1947
1948 #ifdef SK_PRINT_PULL_FORWARD_INFO
1949 static bool gPrintedAccelData = false;
1950
1951 if (!gPrintedAccelData) {
1952 for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
1953 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i);
1954
1955 SkDebugf("%d: Width: %d Height: %d SL: %d R: %d hasNestedLayers: %s\ n",
1956 i,
1957 info.fSize.fWidth,
1958 info.fSize.fHeight,
1959 info.fSaveLayerOpID,
1960 info.fRestoreOpID,
1961 info.fHasNestedLayers ? "T" : "F");
1962 }
1963 gPrintedAccelData = true;
1964 }
1965 #endif
1966
1967 SkAutoTArray<bool> pullForward(gpuData->numSaveLayers()); 1938 SkAutoTArray<bool> pullForward(gpuData->numSaveLayers());
1968 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { 1939 for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
1969 pullForward[i] = false; 1940 pullForward[i] = false;
1970 } 1941 }
1971 1942
1972 SkIRect clip; 1943 SkIRect clip;
1973 1944
1974 fClipData.getConservativeBounds(this->width(), this->height(), &clip, NULL); 1945 fClipData.getConservativeBounds(this->width(), this->height(), &clip, NULL);
1975 1946
1976 SkMatrix inv; 1947 SkMatrix inv;
1977 if (!fContext->getMatrix().invert(&inv)) { 1948 if (!fContext->getMatrix().invert(&inv)) {
1978 return false; 1949 return false;
1979 } 1950 }
1980 1951
1981 SkRect r = SkRect::Make(clip); 1952 SkRect r = SkRect::Make(clip);
1982 inv.mapRect(&r); 1953 inv.mapRect(&r);
1983 r.roundOut(&clip); 1954 r.roundOut(&clip);
1984 1955
1985 const SkPicture::OperationList& ops = picture->EXPERIMENTAL_getActiveOps(cli p); 1956 const SkPicture::OperationList& ops = picture->EXPERIMENTAL_getActiveOps(cli p);
1986 1957
1987 #ifdef SK_PRINT_PULL_FORWARD_INFO
1988 SkDebugf("rect: %d %d %d %d\n", clip.fLeft, clip.fTop, clip.fRight, clip.fBo ttom);
1989 #endif
1990
1991 for (int i = 0; i < ops.numOps(); ++i) { 1958 for (int i = 0; i < ops.numOps(); ++i) {
1992 for (int j = 0; j < gpuData->numSaveLayers(); ++j) { 1959 for (int j = 0; j < gpuData->numSaveLayers(); ++j) {
1993 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(j); 1960 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(j);
1994 1961
1995 if (ops.offset(i) > info.fSaveLayerOpID && ops.offset(i) < info.fRes toreOpID) { 1962 if (ops.offset(i) > info.fSaveLayerOpID && ops.offset(i) < info.fRes toreOpID) {
1996 pullForward[j] = true; 1963 pullForward[j] = true;
1997 } 1964 }
1998 } 1965 }
1999 } 1966 }
2000 1967
2001 #ifdef SK_PRINT_PULL_FORWARD_INFO
2002 SkDebugf("Need SaveLayers: ");
2003 for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
2004 if (pullForward[i]) {
2005 const GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrC reate(picture, i);
2006
2007 SkDebugf("%d (%d), ", i, layer->layerID());
2008 }
2009 }
2010 SkDebugf("\n");
2011 #endif
2012
2013 return false; 1968 return false;
2014 } 1969 }
OLDNEW
« no previous file with comments | « src/gpu/GrPictureUtils.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698