OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 } | 1903 } |
1904 GrConfigConversionEffect::PMConversion upmToPM = | 1904 GrConfigConversionEffect::PMConversion upmToPM = |
1905 static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); | 1905 static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); |
1906 if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) { | 1906 if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) { |
1907 return GrConfigConversionEffect::Create(texture, swapRAndB, upmToPM, mat
rix); | 1907 return GrConfigConversionEffect::Create(texture, swapRAndB, upmToPM, mat
rix); |
1908 } else { | 1908 } else { |
1909 return NULL; | 1909 return NULL; |
1910 } | 1910 } |
1911 } | 1911 } |
1912 | 1912 |
1913 GrPath* GrContext::createPath(const SkPath& inPath, const SkStrokeRec& stroke) { | |
1914 SkASSERT(fGpu->caps()->pathRenderingSupport()); | |
1915 | |
1916 // TODO: now we add to fResourceCache. This should change to fResourceCache. | |
1917 GrResourceKey resourceKey = GrPath::ComputeKey(inPath, stroke); | |
1918 GrPath* path = static_cast<GrPath*>(fResourceCache->find(resourceKey)); | |
1919 if (path && path->isEqualTo(inPath, stroke)) { | |
1920 path->ref(); | |
1921 } else { | |
1922 path = fGpu->createPath(inPath, stroke); | |
1923 fResourceCache->purgeAsNeeded(1, path->gpuMemorySize()); | |
1924 fResourceCache->addResource(resourceKey, path); | |
1925 } | |
1926 return path; | |
1927 } | |
1928 | |
1929 void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrGpuResour
ce* resource) { | 1913 void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrGpuResour
ce* resource) { |
1930 fResourceCache->purgeAsNeeded(1, resource->gpuMemorySize()); | 1914 fResourceCache->purgeAsNeeded(1, resource->gpuMemorySize()); |
1931 fResourceCache->addResource(resourceKey, resource); | 1915 fResourceCache->addResource(resourceKey, resource); |
1932 } | 1916 } |
1933 | 1917 |
1934 GrGpuResource* GrContext::findAndRefCachedResource(const GrResourceKey& resource
Key) { | 1918 GrGpuResource* GrContext::findAndRefCachedResource(const GrResourceKey& resource
Key) { |
1935 GrGpuResource* resource = fResourceCache->find(resourceKey); | 1919 GrGpuResource* resource = fResourceCache->find(resourceKey); |
1936 SkSafeRef(resource); | 1920 SkSafeRef(resource); |
1937 return resource; | 1921 return resource; |
1938 } | 1922 } |
(...skipping 11 matching lines...) Expand all Loading... |
1950 fDrawBuffer->removeGpuTraceMarker(marker); | 1934 fDrawBuffer->removeGpuTraceMarker(marker); |
1951 } | 1935 } |
1952 } | 1936 } |
1953 | 1937 |
1954 /////////////////////////////////////////////////////////////////////////////// | 1938 /////////////////////////////////////////////////////////////////////////////// |
1955 #if GR_CACHE_STATS | 1939 #if GR_CACHE_STATS |
1956 void GrContext::printCacheStats() const { | 1940 void GrContext::printCacheStats() const { |
1957 fResourceCache->printStats(); | 1941 fResourceCache->printStats(); |
1958 } | 1942 } |
1959 #endif | 1943 #endif |
OLD | NEW |