epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
bsalomon@google.com | 1fadb20 | 2011-12-12 16:10:08 +0000 | [diff] [blame] | 9 | #include "GrContext.h" |
| 10 | |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 11 | #include "GrBatchFontCache.h" |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 12 | #include "GrBatchFlushState.h" |
joshualitt | e590266 | 2015-05-11 08:18:35 -0700 | [diff] [blame] | 13 | #include "GrBatchTest.h" |
bsalomon | eb1cb5c | 2015-05-22 08:01:09 -0700 | [diff] [blame] | 14 | #include "GrCaps.h" |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 15 | #include "GrContextOptions.h" |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 16 | #include "GrDefaultGeoProcFactory.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 17 | #include "GrDrawContext.h" |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 18 | #include "GrDrawTarget.h" |
bsalomon | 453cf40 | 2014-11-11 14:15:57 -0800 | [diff] [blame] | 19 | #include "GrGpuResource.h" |
bsalomon | 3582d3e | 2015-02-13 14:20:05 -0800 | [diff] [blame] | 20 | #include "GrGpuResourcePriv.h" |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 21 | #include "GrGpu.h" |
commit-bot@chromium.org | dcb8ef9 | 2014-03-27 11:26:10 +0000 | [diff] [blame] | 22 | #include "GrIndexBuffer.h" |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 23 | #include "GrLayerCache.h" |
commit-bot@chromium.org | 8131283 | 2013-03-22 18:34:09 +0000 | [diff] [blame] | 24 | #include "GrOvalRenderer.h" |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 25 | #include "GrPathRenderer.h" |
tomhudson@google.com | d22b6e4 | 2011-06-24 15:53:40 +0000 | [diff] [blame] | 26 | #include "GrPathUtils.h" |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 27 | #include "GrRenderTargetPriv.h" |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 28 | #include "GrResourceCache.h" |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 29 | #include "GrResourceProvider.h" |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 30 | #include "GrSoftwarePathRenderer.h" |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 31 | #include "GrStrokeInfo.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 32 | #include "GrSurfacePriv.h" |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 33 | #include "GrTextBlobCache.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 34 | #include "GrTexturePriv.h" |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 35 | #include "GrTracing.h" |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 36 | #include "GrVertices.h" |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 37 | #include "SkDashPathPriv.h" |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 38 | #include "SkConfig8888.h" |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 39 | #include "SkGr.h" |
commit-bot@chromium.org | 4784182 | 2014-03-27 14:19:17 +0000 | [diff] [blame] | 40 | #include "SkRRect.h" |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 41 | #include "SkStrokeRec.h" |
robertphillips | fcf7829 | 2015-06-19 11:49:52 -0700 | [diff] [blame] | 42 | #include "SkSurfacePriv.h" |
commit-bot@chromium.org | dcb8ef9 | 2014-03-27 11:26:10 +0000 | [diff] [blame] | 43 | #include "SkTLazy.h" |
commit-bot@chromium.org | 4784182 | 2014-03-27 14:19:17 +0000 | [diff] [blame] | 44 | #include "SkTLS.h" |
commit-bot@chromium.org | 933e65d | 2014-03-20 20:00:24 +0000 | [diff] [blame] | 45 | #include "SkTraceEvent.h" |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 46 | |
joshualitt | 7441782 | 2015-08-07 11:42:16 -0700 | [diff] [blame] | 47 | #include "batches/GrBatch.h" |
| 48 | |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 49 | #include "effects/GrConfigConversionEffect.h" |
| 50 | #include "effects/GrDashingEffect.h" |
| 51 | #include "effects/GrSingleTextureEffect.h" |
| 52 | |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 53 | #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 54 | #define RETURN_IF_ABANDONED if (fDrawingMgr.abandoned()) { return; } |
| 55 | #define RETURN_FALSE_IF_ABANDONED if (fDrawingMgr.abandoned()) { return false; } |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 56 | #define RETURN_NULL_IF_ABANDONED if (fDrawingMgr.abandoned()) { return nullptr; } |
bsalomon@google.com | bc4b654 | 2011-11-19 13:56:11 +0000 | [diff] [blame] | 57 | |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 58 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 59 | //////////////////////////////////////////////////////////////////////////////// |
| 60 | |
| 61 | void GrContext::DrawingMgr::init(GrContext* context) { |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 62 | fContext = context; |
bsalomon | b3b9aec | 2015-09-10 11:16:35 -0700 | [diff] [blame] | 63 | fDrawTarget = new GrDrawTarget(context->getGpu(), context->resourceProvider()); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 64 | } |
bsalomon | 781d582 | 2015-06-16 15:03:11 -0700 | [diff] [blame] | 65 | |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 66 | void GrContext::DrawingMgr::cleanup() { |
| 67 | SkSafeSetNull(fDrawTarget); |
| 68 | for (int i = 0; i < kNumPixelGeometries; ++i) { |
| 69 | SkSafeSetNull(fDrawContext[i][0]); |
| 70 | SkSafeSetNull(fDrawContext[i][1]); |
| 71 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | GrContext::DrawingMgr::~DrawingMgr() { |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 75 | this->cleanup(); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | void GrContext::DrawingMgr::abandon() { |
| 79 | SkSafeSetNull(fDrawTarget); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 80 | for (int i = 0; i < kNumPixelGeometries; ++i) { |
| 81 | for (int j = 0; j < kNumDFTOptions; ++j) { |
| 82 | if (fDrawContext[i][j]) { |
| 83 | SkSafeSetNull(fDrawContext[i][j]->fDrawTarget); |
| 84 | SkSafeSetNull(fDrawContext[i][j]); |
| 85 | } |
| 86 | } |
| 87 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | void GrContext::DrawingMgr::purgeResources() { |
| 91 | if (fDrawTarget) { |
| 92 | fDrawTarget->purgeResources(); |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 93 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 94 | } |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 95 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 96 | void GrContext::DrawingMgr::reset() { |
| 97 | if (fDrawTarget) { |
| 98 | fDrawTarget->reset(); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | void GrContext::DrawingMgr::flush() { |
| 103 | if (fDrawTarget) { |
| 104 | fDrawTarget->flush(); |
| 105 | } |
| 106 | } |
| 107 | |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame^] | 108 | GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceProps) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 109 | if (this->abandoned()) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 110 | return nullptr; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 111 | } |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 112 | |
robertphillips | fcf7829 | 2015-06-19 11:49:52 -0700 | [diff] [blame] | 113 | const SkSurfaceProps props(SkSurfacePropsCopyOrDefault(surfaceProps)); |
| 114 | |
| 115 | SkASSERT(props.pixelGeometry() < kNumPixelGeometries); |
bsalomon | afcd7cd | 2015-08-31 12:39:41 -0700 | [diff] [blame] | 116 | if (!fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()]) { |
| 117 | fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()] = |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 118 | new GrDrawContext(fContext, fDrawTarget, props); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 119 | } |
| 120 | |
robertphillips | c9a3706 | 2015-09-01 08:34:28 -0700 | [diff] [blame] | 121 | // For now, everyone gets a faux creation ref |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame^] | 122 | return SkRef(fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()]); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | //////////////////////////////////////////////////////////////////////////////// |
| 126 | |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 127 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 128 | GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) { |
| 129 | GrContextOptions defaultOptions; |
| 130 | return Create(backend, backendContext, defaultOptions); |
| 131 | } |
bsalomon | f28cff7 | 2015-05-22 12:25:41 -0700 | [diff] [blame] | 132 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 133 | GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext, |
| 134 | const GrContextOptions& options) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 135 | GrContext* context = new GrContext; |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 136 | |
| 137 | if (context->init(backend, backendContext, options)) { |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 138 | return context; |
| 139 | } else { |
| 140 | context->unref(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 141 | return nullptr; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 142 | } |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 143 | } |
| 144 | |
joshualitt | 0acd0d3 | 2015-05-07 08:23:19 -0700 | [diff] [blame] | 145 | static int32_t gNextID = 1; |
| 146 | static int32_t next_id() { |
| 147 | int32_t id; |
| 148 | do { |
| 149 | id = sk_atomic_inc(&gNextID); |
| 150 | } while (id == SK_InvalidGenID); |
| 151 | return id; |
| 152 | } |
| 153 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 154 | GrContext::GrContext() : fUniqueID(next_id()) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 155 | fGpu = nullptr; |
| 156 | fCaps = nullptr; |
| 157 | fResourceCache = nullptr; |
| 158 | fResourceProvider = nullptr; |
| 159 | fPathRendererChain = nullptr; |
| 160 | fSoftwarePathRenderer = nullptr; |
| 161 | fBatchFontCache = nullptr; |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 162 | fFlushToReduceCacheSize = false; |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 163 | } |
| 164 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 165 | bool GrContext::init(GrBackend backend, GrBackendContext backendContext, |
| 166 | const GrContextOptions& options) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 167 | SkASSERT(!fGpu); |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 168 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 169 | fGpu = GrGpu::Create(backend, backendContext, options, this); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 170 | if (!fGpu) { |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 171 | return false; |
| 172 | } |
bsalomon | 3343557 | 2014-11-05 14:47:41 -0800 | [diff] [blame] | 173 | this->initCommon(); |
| 174 | return true; |
| 175 | } |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 176 | |
bsalomon | 3343557 | 2014-11-05 14:47:41 -0800 | [diff] [blame] | 177 | void GrContext::initCommon() { |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 178 | fCaps = SkRef(fGpu->caps()); |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 179 | fResourceCache = new GrResourceCache(fCaps); |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 180 | fResourceCache->setOverBudgetCallback(OverBudgetCB, this); |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 181 | fResourceProvider = new GrResourceProvider(fGpu, fResourceCache); |
commit-bot@chromium.org | 1836d33 | 2013-07-16 22:55:03 +0000 | [diff] [blame] | 182 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 183 | fLayerCache.reset(new GrLayerCache(this)); |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 184 | |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 185 | fDidTestPMConversions = false; |
| 186 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 187 | fDrawingMgr.init(this); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 188 | |
| 189 | // GrBatchFontCache will eventually replace GrFontCache |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 190 | fBatchFontCache = new GrBatchFontCache(this); |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 191 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 192 | fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this)); |
bsalomon@google.com | c0af317 | 2012-06-15 14:10:09 +0000 | [diff] [blame] | 193 | } |
| 194 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 195 | GrContext::~GrContext() { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 196 | if (!fGpu) { |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 197 | SkASSERT(!fCaps); |
bsalomon@google.com | 733c062 | 2013-04-24 17:59:32 +0000 | [diff] [blame] | 198 | return; |
| 199 | } |
| 200 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 201 | this->flush(); |
robertphillips@google.com | 5acc0e3 | 2012-05-17 12:01:02 +0000 | [diff] [blame] | 202 | |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 203 | fDrawingMgr.cleanup(); |
| 204 | |
robertphillips@google.com | 950b1b0 | 2013-10-21 17:37:28 +0000 | [diff] [blame] | 205 | for (int i = 0; i < fCleanUpData.count(); ++i) { |
| 206 | (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo); |
| 207 | } |
| 208 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 209 | delete fResourceProvider; |
| 210 | delete fResourceCache; |
| 211 | delete fBatchFontCache; |
robertphillips@google.com | f6747b0 | 2012-06-12 00:32:28 +0000 | [diff] [blame] | 212 | |
bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +0000 | [diff] [blame] | 213 | fGpu->unref(); |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 214 | fCaps->unref(); |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 215 | SkSafeUnref(fPathRendererChain); |
| 216 | SkSafeUnref(fSoftwarePathRenderer); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 217 | } |
| 218 | |
bsalomon | 2354f84 | 2014-07-28 13:48:36 -0700 | [diff] [blame] | 219 | void GrContext::abandonContext() { |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 220 | fResourceProvider->abandon(); |
bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +0000 | [diff] [blame] | 221 | // abandon first to so destructors |
| 222 | // don't try to free the resources in the API. |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 223 | fResourceCache->abandonAll(); |
bsalomon | c8dc1f7 | 2014-08-21 13:02:13 -0700 | [diff] [blame] | 224 | |
robertphillips | e337130 | 2014-09-17 06:01:06 -0700 | [diff] [blame] | 225 | fGpu->contextAbandoned(); |
bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +0000 | [diff] [blame] | 226 | |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 227 | // a path renderer may be holding onto resources that |
| 228 | // are now unusable |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 229 | SkSafeSetNull(fPathRendererChain); |
| 230 | SkSafeSetNull(fSoftwarePathRenderer); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 231 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 232 | fDrawingMgr.abandon(); |
bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +0000 | [diff] [blame] | 233 | |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 234 | fBatchFontCache->freeAll(); |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 235 | fLayerCache->freeAll(); |
joshualitt | 26ffc00 | 2015-04-16 11:24:04 -0700 | [diff] [blame] | 236 | fTextBlobCache->freeAll(); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 237 | } |
| 238 | |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 239 | void GrContext::resetContext(uint32_t state) { |
| 240 | fGpu->markContextDirty(state); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | void GrContext::freeGpuResources() { |
| 244 | this->flush(); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 245 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 246 | fDrawingMgr.purgeResources(); |
robertphillips@google.com | ff17584 | 2012-05-14 19:31:39 +0000 | [diff] [blame] | 247 | |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 248 | fBatchFontCache->freeAll(); |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 249 | fLayerCache->freeAll(); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 250 | // a path renderer may be holding onto resources |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 251 | SkSafeSetNull(fPathRendererChain); |
| 252 | SkSafeSetNull(fSoftwarePathRenderer); |
bsalomon | 3033b9f | 2015-04-13 11:09:56 -0700 | [diff] [blame] | 253 | |
| 254 | fResourceCache->purgeAllUnlocked(); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 255 | } |
| 256 | |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 257 | void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const { |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 258 | if (resourceCount) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 259 | *resourceCount = fResourceCache->getBudgetedResourceCount(); |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 260 | } |
| 261 | if (resourceBytes) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 262 | *resourceBytes = fResourceCache->getBudgetedResourceBytes(); |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 263 | } |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 264 | } |
| 265 | |
bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 266 | //////////////////////////////////////////////////////////////////////////////// |
| 267 | |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 268 | void GrContext::OverBudgetCB(void* data) { |
bsalomon | 66a450f | 2014-11-13 13:19:10 -0800 | [diff] [blame] | 269 | SkASSERT(data); |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 270 | |
bsalomon | 66a450f | 2014-11-13 13:19:10 -0800 | [diff] [blame] | 271 | GrContext* context = reinterpret_cast<GrContext*>(data); |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 272 | |
joshualitt | b542bae | 2015-07-28 09:58:39 -0700 | [diff] [blame] | 273 | // Flush the GrBufferedDrawTarget to possibly free up some textures |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 274 | context->fFlushToReduceCacheSize = true; |
commit-bot@chromium.org | cae27fe | 2013-07-10 10:14:35 +0000 | [diff] [blame] | 275 | } |
| 276 | |
joshualitt | 0db6dfa | 2015-04-10 07:01:30 -0700 | [diff] [blame] | 277 | void GrContext::TextBlobCacheOverBudgetCB(void* data) { |
| 278 | SkASSERT(data); |
| 279 | |
| 280 | // Unlike the GrResourceCache, TextBlobs are drawn at the SkGpuDevice level, therefore they |
| 281 | // cannot use fFlushTorReduceCacheSize because it uses AutoCheckFlush. The solution is to move |
| 282 | // drawText calls to below the GrContext level, but this is not trivial because they call |
| 283 | // drawPath on SkGpuDevice |
| 284 | GrContext* context = reinterpret_cast<GrContext*>(data); |
| 285 | context->flush(); |
| 286 | } |
| 287 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 288 | //////////////////////////////////////////////////////////////////////////////// |
| 289 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 290 | void GrContext::flush(int flagsBitfield) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 291 | RETURN_IF_ABANDONED |
robertphillips@google.com | e7db8d6 | 2013-07-04 11:48:52 +0000 | [diff] [blame] | 292 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 293 | if (kDiscard_FlushBit & flagsBitfield) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 294 | fDrawingMgr.reset(); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 295 | } else { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 296 | fDrawingMgr.flush(); |
junov@google.com | 53a5584 | 2011-06-08 22:55:10 +0000 | [diff] [blame] | 297 | } |
bsalomon | 3f32432 | 2015-04-08 11:01:54 -0700 | [diff] [blame] | 298 | fResourceCache->notifyFlushOccurred(); |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 299 | fFlushToReduceCacheSize = false; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 300 | } |
| 301 | |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 302 | bool sw_convert_to_premul(GrPixelConfig srcConfig, int width, int height, size_t inRowBytes, |
| 303 | const void* inPixels, size_t outRowBytes, void* outPixels) { |
| 304 | SkSrcPixelInfo srcPI; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 305 | if (!GrPixelConfig2ColorAndProfileType(srcConfig, &srcPI.fColorType, nullptr)) { |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 306 | return false; |
| 307 | } |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 308 | srcPI.fAlphaType = kUnpremul_SkAlphaType; |
| 309 | srcPI.fPixels = inPixels; |
| 310 | srcPI.fRowBytes = inRowBytes; |
| 311 | |
| 312 | SkDstPixelInfo dstPI; |
| 313 | dstPI.fColorType = srcPI.fColorType; |
| 314 | dstPI.fAlphaType = kPremul_SkAlphaType; |
| 315 | dstPI.fPixels = outPixels; |
| 316 | dstPI.fRowBytes = outRowBytes; |
| 317 | |
| 318 | return srcPI.convertPixelsTo(&dstPI, width, height); |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 319 | } |
| 320 | |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 321 | bool GrContext::writeSurfacePixels(GrSurface* surface, |
| 322 | int left, int top, int width, int height, |
| 323 | GrPixelConfig srcConfig, const void* buffer, size_t rowBytes, |
| 324 | uint32_t pixelOpsFlags) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 325 | RETURN_FALSE_IF_ABANDONED |
bsalomon | 6c6f658 | 2015-09-10 08:12:46 -0700 | [diff] [blame] | 326 | ASSERT_OWNED_RESOURCE(surface); |
| 327 | SkASSERT(surface); |
| 328 | |
| 329 | this->testPMConversionsIfNecessary(pixelOpsFlags); |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 330 | |
bsalomon | e8d21e8 | 2015-07-16 08:23:13 -0700 | [diff] [blame] | 331 | // Trim the params here so that if we wind up making a temporary surface it can be as small as |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 332 | // necessary and because GrGpu::getWritePixelsInfo requires it. |
bsalomon | e8d21e8 | 2015-07-16 08:23:13 -0700 | [diff] [blame] | 333 | if (!GrSurfacePriv::AdjustWritePixelParams(surface->width(), surface->height(), |
| 334 | GrBytesPerPixel(srcConfig), &left, &top, &width, |
| 335 | &height, &buffer, &rowBytes)) { |
| 336 | return false; |
| 337 | } |
| 338 | |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 339 | bool applyPremulToSrc = false; |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 340 | if (kUnpremul_PixelOpsFlag & pixelOpsFlags) { |
| 341 | if (!GrPixelConfigIs8888(srcConfig)) { |
| 342 | return false; |
| 343 | } |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 344 | applyPremulToSrc = true; |
| 345 | } |
bsalomon | 636e802 | 2015-07-29 06:08:46 -0700 | [diff] [blame] | 346 | |
| 347 | GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference; |
| 348 | // Don't prefer to draw for the conversion (and thereby access a texture from the cache) when |
| 349 | // we've already determined that there isn't a roundtrip preserving conversion processor pair. |
| 350 | if (applyPremulToSrc && !this->didFailPMUPMConversionTest()) { |
| 351 | drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference; |
| 352 | } |
| 353 | |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 354 | GrGpu::WritePixelTempDrawInfo tempDrawInfo; |
| 355 | if (!fGpu->getWritePixelsInfo(surface, width, height, rowBytes, srcConfig, &drawPreference, |
| 356 | &tempDrawInfo)) { |
| 357 | return false; |
| 358 | } |
| 359 | |
| 360 | if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().hasPendingIO()) { |
| 361 | this->flush(); |
| 362 | } |
| 363 | |
| 364 | SkAutoTUnref<GrTexture> tempTexture; |
| 365 | if (GrGpu::kNoDraw_DrawPreference != drawPreference) { |
bsalomon | eae6200 | 2015-07-31 13:59:30 -0700 | [diff] [blame] | 366 | tempTexture.reset( |
| 367 | this->textureProvider()->createApproxTexture(tempDrawInfo.fTempSurfaceDesc)); |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 368 | if (!tempTexture && GrGpu::kRequireDraw_DrawPreference == drawPreference) { |
| 369 | return false; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | // temp buffer for doing sw premul conversion, if needed. |
| 374 | SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0); |
| 375 | if (tempTexture) { |
| 376 | SkAutoTUnref<const GrFragmentProcessor> fp; |
| 377 | SkMatrix textureMatrix; |
| 378 | textureMatrix.setIDiv(tempTexture->width(), tempTexture->height()); |
| 379 | GrPaint paint; |
| 380 | if (applyPremulToSrc) { |
| 381 | fp.reset(this->createUPMToPMEffect(paint.getProcessorDataManager(), tempTexture, |
| 382 | tempDrawInfo.fSwapRAndB, textureMatrix)); |
| 383 | // If premultiplying was the only reason for the draw, fall back to a straight write. |
| 384 | if (!fp) { |
| 385 | if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 386 | tempTexture.reset(nullptr); |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 387 | } |
| 388 | } else { |
| 389 | applyPremulToSrc = false; |
| 390 | } |
| 391 | } |
| 392 | if (tempTexture) { |
| 393 | if (!fp) { |
| 394 | fp.reset(GrConfigConversionEffect::Create( |
| 395 | paint.getProcessorDataManager(), tempTexture, tempDrawInfo.fSwapRAndB, |
| 396 | GrConfigConversionEffect::kNone_PMConversion, textureMatrix)); |
| 397 | if (!fp) { |
| 398 | return false; |
| 399 | } |
| 400 | } |
| 401 | GrRenderTarget* renderTarget = surface->asRenderTarget(); |
| 402 | SkASSERT(renderTarget); |
| 403 | if (tempTexture->surfacePriv().hasPendingIO()) { |
| 404 | this->flush(); |
| 405 | } |
| 406 | if (applyPremulToSrc) { |
| 407 | size_t tmpRowBytes = 4 * width; |
| 408 | tmpPixels.reset(width * height); |
| 409 | if (!sw_convert_to_premul(srcConfig, width, height, rowBytes, buffer, tmpRowBytes, |
| 410 | tmpPixels.get())) { |
| 411 | return false; |
| 412 | } |
| 413 | rowBytes = tmpRowBytes; |
| 414 | buffer = tmpPixels.get(); |
| 415 | applyPremulToSrc = false; |
| 416 | } |
bsalomon | 6cb3cbe | 2015-07-30 07:34:27 -0700 | [diff] [blame] | 417 | if (!fGpu->writePixels(tempTexture, 0, 0, width, height, |
| 418 | tempDrawInfo.fTempSurfaceDesc.fConfig, buffer, |
| 419 | rowBytes)) { |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 420 | return false; |
| 421 | } |
| 422 | SkMatrix matrix; |
| 423 | matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); |
robertphillips | c9a3706 | 2015-09-01 08:34:28 -0700 | [diff] [blame] | 424 | SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 425 | if (!drawContext) { |
| 426 | return false; |
| 427 | } |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 428 | paint.addColorFragmentProcessor(fp); |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 429 | SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 430 | drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, matrix, rect, nullptr); |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 431 | |
| 432 | if (kFlushWrites_PixelOp & pixelOpsFlags) { |
| 433 | this->flushSurfaceWrites(surface); |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | if (!tempTexture) { |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 438 | if (applyPremulToSrc) { |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 439 | size_t tmpRowBytes = 4 * width; |
| 440 | tmpPixels.reset(width * height); |
| 441 | if (!sw_convert_to_premul(srcConfig, width, height, rowBytes, buffer, tmpRowBytes, |
| 442 | tmpPixels.get())) { |
| 443 | return false; |
| 444 | } |
| 445 | rowBytes = tmpRowBytes; |
| 446 | buffer = tmpPixels.get(); |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 447 | applyPremulToSrc = false; |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 448 | } |
bsalomon | 6cb3cbe | 2015-07-30 07:34:27 -0700 | [diff] [blame] | 449 | return fGpu->writePixels(surface, left, top, width, height, srcConfig, buffer, rowBytes); |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 450 | } |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 451 | return true; |
| 452 | } |
bsalomon@google.com | a91e923 | 2012-02-23 15:39:54 +0000 | [diff] [blame] | 453 | |
bsalomon | e8d21e8 | 2015-07-16 08:23:13 -0700 | [diff] [blame] | 454 | bool GrContext::readSurfacePixels(GrSurface* src, |
| 455 | int left, int top, int width, int height, |
| 456 | GrPixelConfig dstConfig, void* buffer, size_t rowBytes, |
| 457 | uint32_t flags) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 458 | RETURN_FALSE_IF_ABANDONED |
bsalomon | e8d21e8 | 2015-07-16 08:23:13 -0700 | [diff] [blame] | 459 | ASSERT_OWNED_RESOURCE(src); |
| 460 | SkASSERT(src); |
bsalomon | 32ab260 | 2015-09-09 18:57:49 -0700 | [diff] [blame] | 461 | |
bsalomon | 6c6f658 | 2015-09-10 08:12:46 -0700 | [diff] [blame] | 462 | this->testPMConversionsIfNecessary(flags); |
| 463 | SkAutoMutexAcquire ama(fReadPixelsMutex); |
| 464 | |
bsalomon | e8d21e8 | 2015-07-16 08:23:13 -0700 | [diff] [blame] | 465 | // Adjust the params so that if we wind up using an intermediate surface we've already done |
| 466 | // all the trimming and the temporary can be the min size required. |
| 467 | if (!GrSurfacePriv::AdjustReadPixelParams(src->width(), src->height(), |
| 468 | GrBytesPerPixel(dstConfig), &left, |
| 469 | &top, &width, &height, &buffer, &rowBytes)) { |
| 470 | return false; |
| 471 | } |
| 472 | |
| 473 | if (!(kDontFlush_PixelOpsFlag & flags) && src->surfacePriv().hasPendingWrite()) { |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 474 | this->flush(); |
| 475 | } |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 476 | |
bsalomon | e8d21e8 | 2015-07-16 08:23:13 -0700 | [diff] [blame] | 477 | bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 478 | if (unpremul && !GrPixelConfigIs8888(dstConfig)) { |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 479 | // The unpremul flag is only allowed for 8888 configs. |
bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 480 | return false; |
| 481 | } |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 482 | |
bsalomon | 636e802 | 2015-07-29 06:08:46 -0700 | [diff] [blame] | 483 | GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference; |
| 484 | // Don't prefer to draw for the conversion (and thereby access a texture from the cache) when |
| 485 | // we've already determined that there isn't a roundtrip preserving conversion processor pair. |
| 486 | if (unpremul && !this->didFailPMUPMConversionTest()) { |
| 487 | drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference; |
| 488 | } |
| 489 | |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 490 | GrGpu::ReadPixelTempDrawInfo tempDrawInfo; |
| 491 | if (!fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig, &drawPreference, |
| 492 | &tempDrawInfo)) { |
| 493 | return false; |
| 494 | } |
bsalomon | 191bcc0 | 2014-11-14 11:31:13 -0800 | [diff] [blame] | 495 | |
bsalomon | 6cb3cbe | 2015-07-30 07:34:27 -0700 | [diff] [blame] | 496 | SkAutoTUnref<GrSurface> surfaceToRead(SkRef(src)); |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 497 | bool didTempDraw = false; |
| 498 | if (GrGpu::kNoDraw_DrawPreference != drawPreference) { |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 499 | if (tempDrawInfo.fUseExactScratch) { |
| 500 | // We only respect this when the entire src is being read. Otherwise we can trigger too |
| 501 | // many odd ball texture sizes and trash the cache. |
bsalomon | eae6200 | 2015-07-31 13:59:30 -0700 | [diff] [blame] | 502 | if (width != src->width() || height != src->height()) { |
| 503 | tempDrawInfo.fUseExactScratch = false; |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 504 | } |
bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 505 | } |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 506 | SkAutoTUnref<GrTexture> temp; |
bsalomon | eae6200 | 2015-07-31 13:59:30 -0700 | [diff] [blame] | 507 | if (tempDrawInfo.fUseExactScratch) { |
| 508 | temp.reset(this->textureProvider()->createTexture(tempDrawInfo.fTempSurfaceDesc, true)); |
| 509 | } else { |
| 510 | temp.reset(this->textureProvider()->createApproxTexture(tempDrawInfo.fTempSurfaceDesc)); |
| 511 | } |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 512 | if (temp) { |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 513 | SkMatrix textureMatrix; |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 514 | textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 515 | textureMatrix.postIDiv(src->width(), src->height()); |
joshualitt | 5f10b5c | 2015-07-09 10:24:35 -0700 | [diff] [blame] | 516 | GrPaint paint; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 517 | SkAutoTUnref<const GrFragmentProcessor> fp; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 518 | if (unpremul) { |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 519 | fp.reset(this->createPMToUPMEffect( |
| 520 | paint.getProcessorDataManager(), src->asTexture(), tempDrawInfo.fSwapRAndB, |
| 521 | textureMatrix)); |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 522 | if (fp) { |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 523 | unpremul = false; // we no longer need to do this on CPU after the read back. |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 524 | } else if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) { |
| 525 | // We only wanted to do the draw in order to perform the unpremul so don't |
| 526 | // bother. |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 527 | temp.reset(nullptr); |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 528 | } |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 529 | } |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 530 | if (!fp && temp) { |
| 531 | fp.reset(GrConfigConversionEffect::Create( |
| 532 | paint.getProcessorDataManager(), src->asTexture(), tempDrawInfo.fSwapRAndB, |
| 533 | GrConfigConversionEffect::kNone_PMConversion, textureMatrix)); |
| 534 | } |
| 535 | if (fp) { |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 536 | paint.addColorFragmentProcessor(fp); |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 537 | SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); |
robertphillips | c9a3706 | 2015-09-01 08:34:28 -0700 | [diff] [blame] | 538 | SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 539 | drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen(), paint, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 540 | SkMatrix::I(), rect, nullptr); |
bsalomon | 6cb3cbe | 2015-07-30 07:34:27 -0700 | [diff] [blame] | 541 | surfaceToRead.reset(SkRef(temp.get())); |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 542 | left = 0; |
| 543 | top = 0; |
| 544 | didTempDraw = true; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 545 | } |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 546 | } |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 547 | } |
joshualitt | 5c55fef | 2014-10-31 14:04:35 -0700 | [diff] [blame] | 548 | |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 549 | if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) { |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 550 | return false; |
| 551 | } |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 552 | GrPixelConfig configToRead = dstConfig; |
| 553 | if (didTempDraw) { |
bsalomon | 6cb3cbe | 2015-07-30 07:34:27 -0700 | [diff] [blame] | 554 | this->flushSurfaceWrites(surfaceToRead); |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 555 | // We swapped R and B while doing the temp draw. Swap back on the read. |
| 556 | if (tempDrawInfo.fSwapRAndB) { |
| 557 | configToRead = GrPixelConfigSwapRAndB(dstConfig); |
| 558 | } |
| 559 | } |
bsalomon | 6cb3cbe | 2015-07-30 07:34:27 -0700 | [diff] [blame] | 560 | if (!fGpu->readPixels(surfaceToRead, left, top, width, height, configToRead, buffer, |
| 561 | rowBytes)) { |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 562 | return false; |
| 563 | } |
| 564 | |
| 565 | // Perform umpremul conversion if we weren't able to perform it as a draw. |
| 566 | if (unpremul) { |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 567 | SkDstPixelInfo dstPI; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 568 | if (!GrPixelConfig2ColorAndProfileType(dstConfig, &dstPI.fColorType, nullptr)) { |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 569 | return false; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 570 | } |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 571 | dstPI.fAlphaType = kUnpremul_SkAlphaType; |
| 572 | dstPI.fPixels = buffer; |
| 573 | dstPI.fRowBytes = rowBytes; |
| 574 | |
| 575 | SkSrcPixelInfo srcPI; |
bsalomon | 3982602 | 2015-07-23 08:07:21 -0700 | [diff] [blame] | 576 | srcPI.fColorType = dstPI.fColorType; |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 577 | srcPI.fAlphaType = kPremul_SkAlphaType; |
| 578 | srcPI.fPixels = buffer; |
| 579 | srcPI.fRowBytes = rowBytes; |
| 580 | |
| 581 | return srcPI.convertPixelsTo(&dstPI, width, height); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 582 | } |
| 583 | return true; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 584 | } |
| 585 | |
bsalomon | c49e868 | 2015-06-30 11:37:35 -0700 | [diff] [blame] | 586 | void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 587 | RETURN_IF_ABANDONED |
bsalomon | 87a94eb | 2014-11-03 14:28:32 -0800 | [diff] [blame] | 588 | SkASSERT(surface); |
| 589 | ASSERT_OWNED_RESOURCE(surface); |
| 590 | if (surface->surfacePriv().hasPendingIO()) { |
| 591 | this->flush(); |
| 592 | } |
| 593 | GrRenderTarget* rt = surface->asRenderTarget(); |
| 594 | if (fGpu && rt) { |
| 595 | fGpu->resolveRenderTarget(rt); |
bsalomon | 41ebbdd | 2014-08-04 08:31:39 -0700 | [diff] [blame] | 596 | } |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 597 | } |
| 598 | |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 599 | void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, |
| 600 | const SkIPoint& dstPoint, uint32_t pixelOpsFlags) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 601 | RETURN_IF_ABANDONED |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 602 | if (!src || !dst) { |
senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 603 | return; |
| 604 | } |
bsalomon | e3d4bf2 | 2014-09-23 09:15:03 -0700 | [diff] [blame] | 605 | ASSERT_OWNED_RESOURCE(src); |
junov | 2bb5210 | 2014-09-29 10:18:59 -0700 | [diff] [blame] | 606 | ASSERT_OWNED_RESOURCE(dst); |
Brian Salomon | 34a9895 | 2014-09-24 11:41:24 -0400 | [diff] [blame] | 607 | |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 608 | // Since we're going to the draw target and not GPU, no need to check kNoFlush |
| 609 | // here. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 610 | if (!dst->asRenderTarget()) { |
junov | 96c118e | 2014-09-26 13:09:47 -0700 | [diff] [blame] | 611 | return; |
| 612 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 613 | |
robertphillips | c9a3706 | 2015-09-01 08:34:28 -0700 | [diff] [blame] | 614 | SkAutoTUnref<GrDrawContext> drawContext(this->drawContext()); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 615 | if (!drawContext) { |
| 616 | return; |
| 617 | } |
| 618 | |
| 619 | drawContext->copySurface(dst->asRenderTarget(), src, srcRect, dstPoint); |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 620 | |
| 621 | if (kFlushWrites_PixelOp & pixelOpsFlags) { |
| 622 | this->flush(); |
| 623 | } |
senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 624 | } |
| 625 | |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 626 | void GrContext::flushSurfaceWrites(GrSurface* surface) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 627 | RETURN_IF_ABANDONED |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 628 | if (surface->surfacePriv().hasPendingWrite()) { |
| 629 | this->flush(); |
| 630 | } |
| 631 | } |
| 632 | |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 633 | /* |
| 634 | * This method finds a path renderer that can draw the specified path on |
| 635 | * the provided target. |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 636 | * Due to its expense, the software path renderer has split out so it can |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 637 | * can be individually allowed/disallowed via the "allowSW" boolean. |
| 638 | */ |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 639 | GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 640 | const GrPipelineBuilder* pipelineBuilder, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 641 | const SkMatrix& viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 642 | const SkPath& path, |
kkinnunen | 1899651 | 2015-04-26 23:18:49 -0700 | [diff] [blame] | 643 | const GrStrokeInfo& stroke, |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 644 | bool allowSW, |
| 645 | GrPathRendererChain::DrawType drawType, |
| 646 | GrPathRendererChain::StencilSupport* stencilSupport) { |
| 647 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 648 | if (!fPathRendererChain) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 649 | fPathRendererChain = new GrPathRendererChain(this); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 650 | } |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 651 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 652 | GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 653 | pipelineBuilder, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 654 | viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 655 | path, |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 656 | stroke, |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 657 | drawType, |
| 658 | stencilSupport); |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 659 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 660 | if (!pr && allowSW) { |
| 661 | if (!fSoftwarePathRenderer) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 662 | fSoftwarePathRenderer = new GrSoftwarePathRenderer(this); |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 663 | } |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 664 | pr = fSoftwarePathRenderer; |
| 665 | } |
| 666 | |
| 667 | return pr; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 668 | } |
| 669 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 670 | //////////////////////////////////////////////////////////////////////////////// |
commit-bot@chromium.org | b471a32 | 2014-03-10 07:40:03 +0000 | [diff] [blame] | 671 | int GrContext::getRecommendedSampleCount(GrPixelConfig config, |
| 672 | SkScalar dpi) const { |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 673 | if (!this->caps()->isConfigRenderable(config, true)) { |
commit-bot@chromium.org | b471a32 | 2014-03-10 07:40:03 +0000 | [diff] [blame] | 674 | return 0; |
| 675 | } |
| 676 | int chosenSampleCount = 0; |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 677 | if (fGpu->caps()->shaderCaps()->pathRenderingSupport()) { |
commit-bot@chromium.org | b471a32 | 2014-03-10 07:40:03 +0000 | [diff] [blame] | 678 | if (dpi >= 250.0f) { |
| 679 | chosenSampleCount = 4; |
| 680 | } else { |
| 681 | chosenSampleCount = 16; |
| 682 | } |
| 683 | } |
| 684 | return chosenSampleCount <= fGpu->caps()->maxSampleCount() ? |
| 685 | chosenSampleCount : 0; |
| 686 | } |
| 687 | |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 688 | namespace { |
| 689 | void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { |
| 690 | GrConfigConversionEffect::PMConversion pmToUPM; |
| 691 | GrConfigConversionEffect::PMConversion upmToPM; |
| 692 | GrConfigConversionEffect::TestForPreservingPMConversions(ctx, &pmToUPM, &upmToPM); |
| 693 | *pmToUPMValue = pmToUPM; |
| 694 | *upmToPMValue = upmToPM; |
| 695 | } |
| 696 | } |
| 697 | |
bsalomon | 6c6f658 | 2015-09-10 08:12:46 -0700 | [diff] [blame] | 698 | void GrContext::testPMConversionsIfNecessary(uint32_t flags) { |
| 699 | if (SkToBool(kUnpremul_PixelOpsFlag & flags)) { |
| 700 | SkAutoMutexAcquire ama(fTestPMConversionsMutex); |
| 701 | if (!fDidTestPMConversions) { |
| 702 | test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion); |
| 703 | fDidTestPMConversions = true; |
| 704 | } |
| 705 | } |
| 706 | } |
| 707 | |
joshualitt | 5f10b5c | 2015-07-09 10:24:35 -0700 | [diff] [blame] | 708 | const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrProcessorDataManager* procDataManager, |
| 709 | GrTexture* texture, |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 710 | bool swapRAndB, |
bsalomon | 6c6f658 | 2015-09-10 08:12:46 -0700 | [diff] [blame] | 711 | const SkMatrix& matrix) const { |
| 712 | // We should have already called this->testPMConversionsIfNecessary(). |
| 713 | SkASSERT(fDidTestPMConversions); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 714 | GrConfigConversionEffect::PMConversion pmToUPM = |
| 715 | static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion); |
| 716 | if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) { |
joshualitt | 5f10b5c | 2015-07-09 10:24:35 -0700 | [diff] [blame] | 717 | return GrConfigConversionEffect::Create(procDataManager, texture, swapRAndB, pmToUPM, |
| 718 | matrix); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 719 | } else { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 720 | return nullptr; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 721 | } |
| 722 | } |
| 723 | |
joshualitt | 5f10b5c | 2015-07-09 10:24:35 -0700 | [diff] [blame] | 724 | const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrProcessorDataManager* procDataManager, |
| 725 | GrTexture* texture, |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 726 | bool swapRAndB, |
bsalomon | 6c6f658 | 2015-09-10 08:12:46 -0700 | [diff] [blame] | 727 | const SkMatrix& matrix) const { |
| 728 | // We should have already called this->testPMConversionsIfNecessary(). |
| 729 | SkASSERT(fDidTestPMConversions); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 730 | GrConfigConversionEffect::PMConversion upmToPM = |
| 731 | static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); |
| 732 | if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) { |
joshualitt | 5f10b5c | 2015-07-09 10:24:35 -0700 | [diff] [blame] | 733 | return GrConfigConversionEffect::Create(procDataManager, texture, swapRAndB, upmToPM, |
| 734 | matrix); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 735 | } else { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 736 | return nullptr; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 737 | } |
| 738 | } |
| 739 | |
bsalomon | 636e802 | 2015-07-29 06:08:46 -0700 | [diff] [blame] | 740 | bool GrContext::didFailPMUPMConversionTest() const { |
bsalomon | 6c6f658 | 2015-09-10 08:12:46 -0700 | [diff] [blame] | 741 | // We should have already called this->testPMConversionsIfNecessary(). |
| 742 | SkASSERT(fDidTestPMConversions); |
bsalomon | 636e802 | 2015-07-29 06:08:46 -0700 | [diff] [blame] | 743 | // The PM<->UPM tests fail or succeed together so we only need to check one. |
bsalomon | 6c6f658 | 2015-09-10 08:12:46 -0700 | [diff] [blame] | 744 | return GrConfigConversionEffect::kNone_PMConversion == fPMToUPMConversion; |
bsalomon | 636e802 | 2015-07-29 06:08:46 -0700 | [diff] [blame] | 745 | } |
| 746 | |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 747 | ////////////////////////////////////////////////////////////////////////////// |
| 748 | |
| 749 | void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes) const { |
| 750 | if (maxTextures) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 751 | *maxTextures = fResourceCache->getMaxResourceCount(); |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 752 | } |
| 753 | if (maxTextureBytes) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 754 | *maxTextureBytes = fResourceCache->getMaxResourceBytes(); |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 755 | } |
| 756 | } |
| 757 | |
| 758 | void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 759 | fResourceCache->setLimits(maxTextures, maxTextureBytes); |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 760 | } |
| 761 | |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame^] | 762 | ////////////////////////////////////////////////////////////////////////////// |
| 763 | |
| 764 | void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
| 765 | fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
| 766 | } |