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

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

Issue 540543002: Switch Layer Hoisting over to SkRecord backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « src/gpu/GrRecordReplaceDraw.cpp ('k') | no next file » | 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/GrDashingEffect.h" 11 #include "effects/GrDashingEffect.h"
12 #include "effects/GrTextureDomain.h" 12 #include "effects/GrTextureDomain.h"
13 #include "effects/GrSimpleTextureEffect.h" 13 #include "effects/GrSimpleTextureEffect.h"
14 14
15 #include "GrContext.h" 15 #include "GrContext.h"
16 #include "GrBitmapTextContext.h" 16 #include "GrBitmapTextContext.h"
17 #include "GrDistanceFieldTextContext.h" 17 #include "GrDistanceFieldTextContext.h"
18 #include "GrLayerCache.h" 18 #include "GrLayerCache.h"
19 #include "GrLayerHoister.h" 19 #include "GrLayerHoister.h"
20 #include "GrPictureUtils.h" 20 #include "GrPictureUtils.h"
21 #include "GrRecordReplaceDraw.h"
21 #include "GrStrokeInfo.h" 22 #include "GrStrokeInfo.h"
22 #include "GrTracing.h" 23 #include "GrTracing.h"
23 24
24 #include "SkGrTexturePixelRef.h" 25 #include "SkGrTexturePixelRef.h"
25 26
26 #include "SkDeviceImageFilterProxy.h" 27 #include "SkDeviceImageFilterProxy.h"
27 #include "SkDrawProcs.h" 28 #include "SkDrawProcs.h"
28 #include "SkGlyphCache.h" 29 #include "SkGlyphCache.h"
29 #include "SkImageFilter.h" 30 #include "SkImageFilter.h"
30 #include "SkMaskFilter.h" 31 #include "SkMaskFilter.h"
31 #include "SkPathEffect.h" 32 #include "SkPathEffect.h"
32 #include "SkPicture.h" 33 #include "SkPicture.h"
33 #include "SkPictureData.h" 34 #include "SkPictureData.h"
34 #include "SkPictureRangePlayback.h" 35 #include "SkRecord.h"
35 #include "SkPictureReplacementPlayback.h"
36 #include "SkRRect.h" 36 #include "SkRRect.h"
37 #include "SkStroke.h" 37 #include "SkStroke.h"
38 #include "SkSurface.h" 38 #include "SkSurface.h"
39 #include "SkTLazy.h" 39 #include "SkTLazy.h"
40 #include "SkUtils.h" 40 #include "SkUtils.h"
41 #include "SkVertState.h" 41 #include "SkVertState.h"
42 #include "SkXfermode.h" 42 #include "SkXfermode.h"
43 #include "SkErrorInternals.h" 43 #include "SkErrorInternals.h"
44 44
45 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; 45 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 };
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 1868
1869 SkRect clipBounds; 1869 SkRect clipBounds;
1870 if (!mainCanvas->getClipBounds(&clipBounds)) { 1870 if (!mainCanvas->getClipBounds(&clipBounds)) {
1871 return true; 1871 return true;
1872 } 1872 }
1873 1873
1874 if (!GrLayerHoister::FindLayersToHoist(gpuData, clipBounds, pullForward.get( ))) { 1874 if (!GrLayerHoister::FindLayersToHoist(gpuData, clipBounds, pullForward.get( ))) {
1875 return false; 1875 return false;
1876 } 1876 }
1877 1877
1878 SkPictureReplacementPlayback::PlaybackReplacements replacements; 1878 GrReplacements replacements;
1879 1879
1880 SkTDArray<GrCachedLayer*> atlased, nonAtlased; 1880 SkTDArray<GrCachedLayer*> atlased, nonAtlased;
1881 atlased.setReserve(gpuData->numSaveLayers()); 1881 atlased.setReserve(gpuData->numSaveLayers());
1882 1882
1883 // Generate the layer and/or ensure it is locked 1883 // Generate the layer and/or ensure it is locked
1884 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { 1884 for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
1885 if (pullForward[i]) { 1885 if (pullForward[i]) {
1886 const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i); 1886 const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i);
1887 1887
1888 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate( picture->uniqueID(), 1888 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate( picture->uniqueID(),
1889 info.fSaveLayerOpID, 1889 info.fSaveLayerOpID,
1890 info.fRestoreOpID, 1890 info.fRestoreOpID,
1891 info.fOriginXform); 1891 info.fOriginXform);
1892 1892
1893 SkPictureReplacementPlayback::PlaybackReplacements::ReplacementInfo* layerInfo = 1893 GrReplacements::ReplacementInfo* layerInfo = replacements.push();
1894 replacem ents.push();
1895 layerInfo->fStart = info.fSaveLayerOpID; 1894 layerInfo->fStart = info.fSaveLayerOpID;
1896 layerInfo->fStop = info.fRestoreOpID; 1895 layerInfo->fStop = info.fRestoreOpID;
1897 layerInfo->fPos = info.fOffset; 1896 layerInfo->fPos = info.fOffset;
1898 1897
1899 GrTextureDesc desc; 1898 GrTextureDesc desc;
1900 desc.fFlags = kRenderTarget_GrTextureFlagBit; 1899 desc.fFlags = kRenderTarget_GrTextureFlagBit;
1901 desc.fWidth = info.fSize.fWidth; 1900 desc.fWidth = info.fSize.fWidth;
1902 desc.fHeight = info.fSize.fHeight; 1901 desc.fHeight = info.fSize.fHeight;
1903 desc.fConfig = kSkia8888_GrPixelConfig; 1902 desc.fConfig = kSkia8888_GrPixelConfig;
1904 // TODO: need to deal with sample count 1903 // TODO: need to deal with sample count
1905 1904
1906 bool needsRendering = fContext->getLayerCache()->lock(layer, desc, 1905 bool needsRendering = fContext->getLayerCache()->lock(layer, desc,
1907 info.fHasNestedLayers || inf o.fIsNested); 1906 info.fHasNestedLayers || inf o.fIsNested);
1908 if (NULL == layer->texture()) { 1907 if (NULL == layer->texture()) {
1909 continue; 1908 continue;
1910 } 1909 }
1911 1910
1912 layerInfo->fBM = SkNEW(SkBitmap); // fBM is allocated so Replacemen tInfo can be POD 1911 SkBitmap bm;
1913 wrap_texture(layer->texture(), 1912 wrap_texture(layer->texture(),
1914 !layer->isAtlased() ? desc.fWidth : layer->texture()->w idth(), 1913 !layer->isAtlased() ? desc.fWidth : layer->texture()->w idth(),
1915 !layer->isAtlased() ? desc.fHeight : layer->texture()-> height(), 1914 !layer->isAtlased() ? desc.fHeight : layer->texture()-> height(),
1916 layerInfo->fBM); 1915 &bm);
1916 layerInfo->fImage = SkImage::NewTexture(bm);
1917 1917
1918 SkASSERT(info.fPaint); 1918 SkASSERT(info.fPaint);
1919 layerInfo->fPaint = info.fPaint; 1919 layerInfo->fPaint = info.fPaint;
1920 1920
1921 layerInfo->fSrcRect = SkIRect::MakeXYWH(layer->rect().fLeft, 1921 layerInfo->fSrcRect = SkIRect::MakeXYWH(layer->rect().fLeft,
1922 layer->rect().fTop, 1922 layer->rect().fTop,
1923 layer->rect().width(), 1923 layer->rect().width(),
1924 layer->rect().height()); 1924 layer->rect().height());
1925 1925
1926 if (needsRendering) { 1926 if (needsRendering) {
1927 if (layer->isAtlased()) { 1927 if (layer->isAtlased()) {
1928 *atlased.append() = layer; 1928 *atlased.append() = layer;
1929 } else { 1929 } else {
1930 *nonAtlased.append() = layer; 1930 *nonAtlased.append() = layer;
1931 } 1931 }
1932 } 1932 }
1933 } 1933 }
1934 } 1934 }
1935 1935
1936 GrLayerHoister::DrawLayers(picture, atlased, nonAtlased); 1936 GrLayerHoister::DrawLayers(picture, atlased, nonAtlased);
1937 1937
1938 // Render the entire picture using new layers 1938 // Render the entire picture using new layers
1939 SkPictureReplacementPlayback playback(picture, &replacements, NULL); 1939 GrRecordReplaceDraw(*picture->fRecord, mainCanvas, picture->fBBH.get(), &rep lacements, NULL);
1940
1941 playback.draw(mainCanvas, NULL);
1942 1940
1943 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), picture); 1941 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), picture);
1944 1942
1945 return true; 1943 return true;
1946 } 1944 }
1947 1945
1948 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1946 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1949 // We always return a transient cache, so it is freed after each 1947 // We always return a transient cache, so it is freed after each
1950 // filter traversal. 1948 // filter traversal.
1951 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1949 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1952 } 1950 }
OLDNEW
« no previous file with comments | « src/gpu/GrRecordReplaceDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698