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 | |
jvanverth@google.com | bfe2b9d | 2013-09-06 16:57:29 +0000 | [diff] [blame] | 11 | #include "GrAARectRenderer.h" |
joshualitt | 0823bfa | 2015-02-27 10:06:15 -0800 | [diff] [blame] | 12 | #include "GrBatch.h" |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 13 | #include "GrBatchFontCache.h" |
joshualitt | 0823bfa | 2015-02-27 10:06:15 -0800 | [diff] [blame] | 14 | #include "GrBatchTarget.h" |
joshualitt | e590266 | 2015-05-11 08:18:35 -0700 | [diff] [blame] | 15 | #include "GrBatchTest.h" |
bsalomon | eb1cb5c | 2015-05-22 08:01:09 -0700 | [diff] [blame] | 16 | #include "GrCaps.h" |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 17 | #include "GrContextOptions.h" |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 18 | #include "GrDefaultGeoProcFactory.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 19 | #include "GrDrawContext.h" |
bsalomon | 453cf40 | 2014-11-11 14:15:57 -0800 | [diff] [blame] | 20 | #include "GrGpuResource.h" |
bsalomon | 3582d3e | 2015-02-13 14:20:05 -0800 | [diff] [blame] | 21 | #include "GrGpuResourcePriv.h" |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 22 | #include "GrGpu.h" |
joshualitt | bb87b21 | 2015-05-19 14:28:04 -0700 | [diff] [blame] | 23 | #include "GrImmediateDrawTarget.h" |
commit-bot@chromium.org | dcb8ef9 | 2014-03-27 11:26:10 +0000 | [diff] [blame] | 24 | #include "GrIndexBuffer.h" |
commit-bot@chromium.org | 4784182 | 2014-03-27 14:19:17 +0000 | [diff] [blame] | 25 | #include "GrInOrderDrawBuffer.h" |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 26 | #include "GrLayerCache.h" |
commit-bot@chromium.org | 8131283 | 2013-03-22 18:34:09 +0000 | [diff] [blame] | 27 | #include "GrOvalRenderer.h" |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 28 | #include "GrPathRenderer.h" |
tomhudson@google.com | d22b6e4 | 2011-06-24 15:53:40 +0000 | [diff] [blame] | 29 | #include "GrPathUtils.h" |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 30 | #include "GrRenderTargetPriv.h" |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 31 | #include "GrResourceCache.h" |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 32 | #include "GrResourceProvider.h" |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 33 | #include "GrSoftwarePathRenderer.h" |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 34 | #include "GrStrokeInfo.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 35 | #include "GrSurfacePriv.h" |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 36 | #include "GrTextBlobCache.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 37 | #include "GrTexturePriv.h" |
egdaniel | bbcb38d | 2014-06-19 10:19:29 -0700 | [diff] [blame] | 38 | #include "GrTraceMarker.h" |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 39 | #include "GrTracing.h" |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 40 | #include "GrVertices.h" |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 41 | #include "SkDashPathPriv.h" |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 42 | #include "SkConfig8888.h" |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 43 | #include "SkGr.h" |
commit-bot@chromium.org | 4784182 | 2014-03-27 14:19:17 +0000 | [diff] [blame] | 44 | #include "SkRRect.h" |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 45 | #include "SkStrokeRec.h" |
commit-bot@chromium.org | dcb8ef9 | 2014-03-27 11:26:10 +0000 | [diff] [blame] | 46 | #include "SkTLazy.h" |
commit-bot@chromium.org | 4784182 | 2014-03-27 14:19:17 +0000 | [diff] [blame] | 47 | #include "SkTLS.h" |
commit-bot@chromium.org | 933e65d | 2014-03-20 20:00:24 +0000 | [diff] [blame] | 48 | #include "SkTraceEvent.h" |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 49 | |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 50 | #include "effects/GrConfigConversionEffect.h" |
| 51 | #include "effects/GrDashingEffect.h" |
| 52 | #include "effects/GrSingleTextureEffect.h" |
| 53 | |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 54 | #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 55 | #define RETURN_IF_ABANDONED if (fDrawingMgr.abandoned()) { return; } |
| 56 | #define RETURN_FALSE_IF_ABANDONED if (fDrawingMgr.abandoned()) { return false; } |
| 57 | #define RETURN_NULL_IF_ABANDONED if (fDrawingMgr.abandoned()) { return NULL; } |
bsalomon@google.com | bc4b654 | 2011-11-19 13:56:11 +0000 | [diff] [blame] | 58 | |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 59 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 60 | //////////////////////////////////////////////////////////////////////////////// |
| 61 | |
| 62 | void GrContext::DrawingMgr::init(GrContext* context) { |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame^] | 63 | fContext = context; |
| 64 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 65 | #ifdef IMMEDIATE_MODE |
| 66 | fDrawTarget = SkNEW_ARGS(GrImmediateDrawTarget, (context)); |
| 67 | #else |
| 68 | fDrawTarget = SkNEW_ARGS(GrInOrderDrawBuffer, (context)); |
| 69 | #endif |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame^] | 70 | } |
bsalomon | 781d582 | 2015-06-16 15:03:11 -0700 | [diff] [blame] | 71 | |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame^] | 72 | void GrContext::DrawingMgr::cleanup() { |
| 73 | SkSafeSetNull(fDrawTarget); |
| 74 | for (int i = 0; i < kNumPixelGeometries; ++i) { |
| 75 | SkSafeSetNull(fDrawContext[i][0]); |
| 76 | SkSafeSetNull(fDrawContext[i][1]); |
| 77 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | GrContext::DrawingMgr::~DrawingMgr() { |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame^] | 81 | this->cleanup(); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | void GrContext::DrawingMgr::abandon() { |
| 85 | SkSafeSetNull(fDrawTarget); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame^] | 86 | for (int i = 0; i < kNumPixelGeometries; ++i) { |
| 87 | for (int j = 0; j < kNumDFTOptions; ++j) { |
| 88 | if (fDrawContext[i][j]) { |
| 89 | SkSafeSetNull(fDrawContext[i][j]->fDrawTarget); |
| 90 | SkSafeSetNull(fDrawContext[i][j]); |
| 91 | } |
| 92 | } |
| 93 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | void GrContext::DrawingMgr::purgeResources() { |
| 97 | if (fDrawTarget) { |
| 98 | fDrawTarget->purgeResources(); |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 99 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 100 | } |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 101 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 102 | void GrContext::DrawingMgr::reset() { |
| 103 | if (fDrawTarget) { |
| 104 | fDrawTarget->reset(); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | void GrContext::DrawingMgr::flush() { |
| 109 | if (fDrawTarget) { |
| 110 | fDrawTarget->flush(); |
| 111 | } |
| 112 | } |
| 113 | |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame^] | 114 | GrDrawContext* GrContext::DrawingMgr::drawContext(const SkDeviceProperties* devProps, bool useDFT) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 115 | if (this->abandoned()) { |
| 116 | return NULL; |
| 117 | } |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame^] | 118 | |
| 119 | const SkDeviceProperties defProps; |
| 120 | if (!devProps) { |
| 121 | devProps = &defProps; |
| 122 | } |
| 123 | |
| 124 | SkASSERT(devProps->pixelGeometry() < kNumPixelGeometries); |
| 125 | if (!fDrawContext[devProps->pixelGeometry()][useDFT]) { |
| 126 | fDrawContext[devProps->pixelGeometry()][useDFT] = |
| 127 | SkNEW_ARGS(GrDrawContext, (fContext, fDrawTarget, *devProps, useDFT)); |
| 128 | } |
| 129 | |
| 130 | SkASSERT(fDrawContext[devProps->pixelGeometry()][useDFT]->fDevProps->pixelGeometry() == |
| 131 | devProps->pixelGeometry()); |
| 132 | SkASSERT(fDrawContext[devProps->pixelGeometry()][useDFT]->fDevProps->gamma() == |
| 133 | devProps->gamma()); |
| 134 | SkASSERT(fDrawContext[devProps->pixelGeometry()][useDFT]->fUseDFT == useDFT); |
| 135 | |
| 136 | return fDrawContext[devProps->pixelGeometry()][useDFT]; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | //////////////////////////////////////////////////////////////////////////////// |
| 140 | |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 141 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 142 | GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) { |
| 143 | GrContextOptions defaultOptions; |
| 144 | return Create(backend, backendContext, defaultOptions); |
| 145 | } |
bsalomon | f28cff7 | 2015-05-22 12:25:41 -0700 | [diff] [blame] | 146 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 147 | GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext, |
| 148 | const GrContextOptions& options) { |
| 149 | GrContext* context = SkNEW(GrContext); |
| 150 | |
| 151 | if (context->init(backend, backendContext, options)) { |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 152 | return context; |
| 153 | } else { |
| 154 | context->unref(); |
| 155 | return NULL; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 156 | } |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 157 | } |
| 158 | |
joshualitt | 0acd0d3 | 2015-05-07 08:23:19 -0700 | [diff] [blame] | 159 | static int32_t gNextID = 1; |
| 160 | static int32_t next_id() { |
| 161 | int32_t id; |
| 162 | do { |
| 163 | id = sk_atomic_inc(&gNextID); |
| 164 | } while (id == SK_InvalidGenID); |
| 165 | return id; |
| 166 | } |
| 167 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 168 | GrContext::GrContext() : fUniqueID(next_id()) { |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 169 | fGpu = NULL; |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 170 | fCaps = NULL; |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 171 | fResourceCache = NULL; |
| 172 | fResourceProvider = NULL; |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 173 | fPathRendererChain = NULL; |
| 174 | fSoftwarePathRenderer = NULL; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 175 | fBatchFontCache = NULL; |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 176 | fFlushToReduceCacheSize = false; |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 177 | } |
| 178 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 179 | bool GrContext::init(GrBackend backend, GrBackendContext backendContext, |
| 180 | const GrContextOptions& options) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 181 | SkASSERT(!fGpu); |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 182 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 183 | fGpu = GrGpu::Create(backend, backendContext, options, this); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 184 | if (!fGpu) { |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 185 | return false; |
| 186 | } |
bsalomon | 3343557 | 2014-11-05 14:47:41 -0800 | [diff] [blame] | 187 | this->initCommon(); |
| 188 | return true; |
| 189 | } |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 190 | |
bsalomon | 3343557 | 2014-11-05 14:47:41 -0800 | [diff] [blame] | 191 | void GrContext::initCommon() { |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 192 | fCaps = SkRef(fGpu->caps()); |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 193 | fResourceCache = SkNEW(GrResourceCache); |
| 194 | fResourceCache->setOverBudgetCallback(OverBudgetCB, this); |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 195 | fResourceProvider = SkNEW_ARGS(GrResourceProvider, (fGpu, fResourceCache)); |
commit-bot@chromium.org | 1836d33 | 2013-07-16 22:55:03 +0000 | [diff] [blame] | 196 | |
robertphillips | 4ec84da | 2014-06-24 13:10:43 -0700 | [diff] [blame] | 197 | fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this))); |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 198 | |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 199 | fDidTestPMConversions = false; |
| 200 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 201 | fDrawingMgr.init(this); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 202 | |
| 203 | // GrBatchFontCache will eventually replace GrFontCache |
joshualitt | 62db8ba | 2015-04-09 08:22:37 -0700 | [diff] [blame] | 204 | fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this)); |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 205 | |
joshualitt | 0db6dfa | 2015-04-10 07:01:30 -0700 | [diff] [blame] | 206 | fTextBlobCache.reset(SkNEW_ARGS(GrTextBlobCache, (TextBlobCacheOverBudgetCB, this))); |
bsalomon@google.com | c0af317 | 2012-06-15 14:10:09 +0000 | [diff] [blame] | 207 | } |
| 208 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 209 | GrContext::~GrContext() { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 210 | if (!fGpu) { |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 211 | SkASSERT(!fCaps); |
bsalomon@google.com | 733c062 | 2013-04-24 17:59:32 +0000 | [diff] [blame] | 212 | return; |
| 213 | } |
| 214 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 215 | this->flush(); |
robertphillips@google.com | 5acc0e3 | 2012-05-17 12:01:02 +0000 | [diff] [blame] | 216 | |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame^] | 217 | fDrawingMgr.cleanup(); |
| 218 | |
robertphillips@google.com | 950b1b0 | 2013-10-21 17:37:28 +0000 | [diff] [blame] | 219 | for (int i = 0; i < fCleanUpData.count(); ++i) { |
| 220 | (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo); |
| 221 | } |
| 222 | |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 223 | SkDELETE(fResourceProvider); |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 224 | SkDELETE(fResourceCache); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 225 | SkDELETE(fBatchFontCache); |
robertphillips@google.com | f6747b0 | 2012-06-12 00:32:28 +0000 | [diff] [blame] | 226 | |
bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +0000 | [diff] [blame] | 227 | fGpu->unref(); |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 228 | fCaps->unref(); |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 229 | SkSafeUnref(fPathRendererChain); |
| 230 | SkSafeUnref(fSoftwarePathRenderer); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 231 | } |
| 232 | |
bsalomon | 2354f84 | 2014-07-28 13:48:36 -0700 | [diff] [blame] | 233 | void GrContext::abandonContext() { |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 234 | fResourceProvider->abandon(); |
bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +0000 | [diff] [blame] | 235 | // abandon first to so destructors |
| 236 | // don't try to free the resources in the API. |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 237 | fResourceCache->abandonAll(); |
bsalomon | c8dc1f7 | 2014-08-21 13:02:13 -0700 | [diff] [blame] | 238 | |
robertphillips | e337130 | 2014-09-17 06:01:06 -0700 | [diff] [blame] | 239 | fGpu->contextAbandoned(); |
bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +0000 | [diff] [blame] | 240 | |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 241 | // a path renderer may be holding onto resources that |
| 242 | // are now unusable |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 243 | SkSafeSetNull(fPathRendererChain); |
| 244 | SkSafeSetNull(fSoftwarePathRenderer); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 245 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 246 | fDrawingMgr.abandon(); |
bsalomon@google.com | 205d460 | 2011-04-25 12:43:45 +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(); |
joshualitt | 26ffc00 | 2015-04-16 11:24:04 -0700 | [diff] [blame] | 250 | fTextBlobCache->freeAll(); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 251 | } |
| 252 | |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 253 | void GrContext::resetContext(uint32_t state) { |
| 254 | fGpu->markContextDirty(state); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | void GrContext::freeGpuResources() { |
| 258 | this->flush(); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 259 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 260 | fDrawingMgr.purgeResources(); |
robertphillips@google.com | ff17584 | 2012-05-14 19:31:39 +0000 | [diff] [blame] | 261 | |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 262 | fBatchFontCache->freeAll(); |
robertphillips@google.com | e930a07 | 2014-04-03 00:34:27 +0000 | [diff] [blame] | 263 | fLayerCache->freeAll(); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 264 | // a path renderer may be holding onto resources |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 265 | SkSafeSetNull(fPathRendererChain); |
| 266 | SkSafeSetNull(fSoftwarePathRenderer); |
bsalomon | 3033b9f | 2015-04-13 11:09:56 -0700 | [diff] [blame] | 267 | |
| 268 | fResourceCache->purgeAllUnlocked(); |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 269 | } |
| 270 | |
commit-bot@chromium.org | 95c2003 | 2014-05-09 14:29:32 +0000 | [diff] [blame] | 271 | void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const { |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 272 | if (resourceCount) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 273 | *resourceCount = fResourceCache->getBudgetedResourceCount(); |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 274 | } |
| 275 | if (resourceBytes) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 276 | *resourceBytes = fResourceCache->getBudgetedResourceBytes(); |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 277 | } |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 278 | } |
| 279 | |
bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 280 | //////////////////////////////////////////////////////////////////////////////// |
| 281 | |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 282 | void GrContext::OverBudgetCB(void* data) { |
bsalomon | 66a450f | 2014-11-13 13:19:10 -0800 | [diff] [blame] | 283 | SkASSERT(data); |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 284 | |
bsalomon | 66a450f | 2014-11-13 13:19:10 -0800 | [diff] [blame] | 285 | GrContext* context = reinterpret_cast<GrContext*>(data); |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 286 | |
| 287 | // Flush the InOrderDrawBuffer to possibly free up some textures |
| 288 | context->fFlushToReduceCacheSize = true; |
commit-bot@chromium.org | cae27fe | 2013-07-10 10:14:35 +0000 | [diff] [blame] | 289 | } |
| 290 | |
joshualitt | 0db6dfa | 2015-04-10 07:01:30 -0700 | [diff] [blame] | 291 | void GrContext::TextBlobCacheOverBudgetCB(void* data) { |
| 292 | SkASSERT(data); |
| 293 | |
| 294 | // Unlike the GrResourceCache, TextBlobs are drawn at the SkGpuDevice level, therefore they |
| 295 | // cannot use fFlushTorReduceCacheSize because it uses AutoCheckFlush. The solution is to move |
| 296 | // drawText calls to below the GrContext level, but this is not trivial because they call |
| 297 | // drawPath on SkGpuDevice |
| 298 | GrContext* context = reinterpret_cast<GrContext*>(data); |
| 299 | context->flush(); |
| 300 | } |
| 301 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 302 | //////////////////////////////////////////////////////////////////////////////// |
| 303 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 304 | void GrContext::flush(int flagsBitfield) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 305 | RETURN_IF_ABANDONED |
robertphillips@google.com | e7db8d6 | 2013-07-04 11:48:52 +0000 | [diff] [blame] | 306 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 307 | if (kDiscard_FlushBit & flagsBitfield) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 308 | fDrawingMgr.reset(); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 309 | } else { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 310 | fDrawingMgr.flush(); |
junov@google.com | 53a5584 | 2011-06-08 22:55:10 +0000 | [diff] [blame] | 311 | } |
bsalomon | 3f32432 | 2015-04-08 11:01:54 -0700 | [diff] [blame] | 312 | fResourceCache->notifyFlushOccurred(); |
bsalomon | f21dab9 | 2014-11-13 13:33:28 -0800 | [diff] [blame] | 313 | fFlushToReduceCacheSize = false; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 314 | } |
| 315 | |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 316 | bool sw_convert_to_premul(GrPixelConfig srcConfig, int width, int height, size_t inRowBytes, |
| 317 | const void* inPixels, size_t outRowBytes, void* outPixels) { |
| 318 | SkSrcPixelInfo srcPI; |
jvanverth | fa1e8a7 | 2014-12-22 08:31:49 -0800 | [diff] [blame] | 319 | if (!GrPixelConfig2ColorAndProfileType(srcConfig, &srcPI.fColorType, NULL)) { |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 320 | return false; |
| 321 | } |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 322 | srcPI.fAlphaType = kUnpremul_SkAlphaType; |
| 323 | srcPI.fPixels = inPixels; |
| 324 | srcPI.fRowBytes = inRowBytes; |
| 325 | |
| 326 | SkDstPixelInfo dstPI; |
| 327 | dstPI.fColorType = srcPI.fColorType; |
| 328 | dstPI.fAlphaType = kPremul_SkAlphaType; |
| 329 | dstPI.fPixels = outPixels; |
| 330 | dstPI.fRowBytes = outRowBytes; |
| 331 | |
| 332 | return srcPI.convertPixelsTo(&dstPI, width, height); |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 333 | } |
| 334 | |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 335 | bool GrContext::writeSurfacePixels(GrSurface* surface, |
| 336 | int left, int top, int width, int height, |
| 337 | GrPixelConfig srcConfig, const void* buffer, size_t rowBytes, |
| 338 | uint32_t pixelOpsFlags) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 339 | RETURN_FALSE_IF_ABANDONED |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 340 | { |
| 341 | GrTexture* texture = NULL; |
| 342 | if (!(kUnpremul_PixelOpsFlag & pixelOpsFlags) && (texture = surface->asTexture()) && |
| 343 | fGpu->canWriteTexturePixels(texture, srcConfig)) { |
| 344 | |
| 345 | if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && |
| 346 | surface->surfacePriv().hasPendingIO()) { |
| 347 | this->flush(); |
| 348 | } |
| 349 | return fGpu->writeTexturePixels(texture, left, top, width, height, |
| 350 | srcConfig, buffer, rowBytes); |
| 351 | // Don't need to check kFlushWrites_PixelOp here, we just did a direct write so the |
| 352 | // upload is already flushed. |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | // If we didn't do a direct texture write then we upload the pixels to a texture and draw. |
| 357 | GrRenderTarget* renderTarget = surface->asRenderTarget(); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 358 | if (!renderTarget) { |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 359 | return false; |
| 360 | } |
| 361 | |
| 362 | // We ignore the preferred config unless it is a R/B swap of the src config. In that case |
| 363 | // we will upload the original src data to a scratch texture but we will spoof it as the swapped |
| 364 | // config. This scratch will then have R and B swapped. We correct for this by swapping again |
| 365 | // when drawing the scratch to the dst using a conversion effect. |
| 366 | bool swapRAndB = false; |
| 367 | GrPixelConfig writeConfig = srcConfig; |
| 368 | if (GrPixelConfigSwapRAndB(srcConfig) == |
| 369 | fGpu->preferredWritePixelsConfig(srcConfig, renderTarget->config())) { |
| 370 | writeConfig = GrPixelConfigSwapRAndB(srcConfig); |
| 371 | swapRAndB = true; |
| 372 | } |
| 373 | |
bsalomon | f2703d8 | 2014-10-28 14:33:06 -0700 | [diff] [blame] | 374 | GrSurfaceDesc desc; |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 375 | desc.fWidth = width; |
| 376 | desc.fHeight = height; |
| 377 | desc.fConfig = writeConfig; |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 378 | SkAutoTUnref<GrTexture> texture(this->textureProvider()->refScratchTexture(desc, |
| 379 | GrTextureProvider::kApprox_ScratchTexMatch)); |
bsalomon | e305973 | 2014-10-14 11:47:22 -0700 | [diff] [blame] | 380 | if (!texture) { |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 381 | return false; |
| 382 | } |
| 383 | |
| 384 | SkAutoTUnref<const GrFragmentProcessor> fp; |
| 385 | SkMatrix textureMatrix; |
| 386 | textureMatrix.setIDiv(texture->width(), texture->height()); |
| 387 | |
| 388 | // allocate a tmp buffer and sw convert the pixels to premul |
| 389 | SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0); |
| 390 | |
| 391 | if (kUnpremul_PixelOpsFlag & pixelOpsFlags) { |
| 392 | if (!GrPixelConfigIs8888(srcConfig)) { |
| 393 | return false; |
| 394 | } |
| 395 | fp.reset(this->createUPMToPMEffect(texture, swapRAndB, textureMatrix)); |
| 396 | // handle the unpremul step on the CPU if we couldn't create an effect to do it. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 397 | if (!fp) { |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 398 | size_t tmpRowBytes = 4 * width; |
| 399 | tmpPixels.reset(width * height); |
| 400 | if (!sw_convert_to_premul(srcConfig, width, height, rowBytes, buffer, tmpRowBytes, |
| 401 | tmpPixels.get())) { |
| 402 | return false; |
| 403 | } |
| 404 | rowBytes = tmpRowBytes; |
| 405 | buffer = tmpPixels.get(); |
| 406 | } |
| 407 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 408 | if (!fp) { |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 409 | fp.reset(GrConfigConversionEffect::Create(texture, |
| 410 | swapRAndB, |
| 411 | GrConfigConversionEffect::kNone_PMConversion, |
| 412 | textureMatrix)); |
| 413 | } |
| 414 | |
| 415 | // Even if the client told us not to flush, we still flush here. The client may have known that |
| 416 | // writes to the original surface caused no data hazards, but they can't know that the scratch |
| 417 | // we just got is safe. |
| 418 | if (texture->surfacePriv().hasPendingIO()) { |
| 419 | this->flush(); |
| 420 | } |
| 421 | if (!fGpu->writeTexturePixels(texture, 0, 0, width, height, |
| 422 | writeConfig, buffer, rowBytes)) { |
| 423 | return false; |
| 424 | } |
| 425 | |
| 426 | SkMatrix matrix; |
| 427 | matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); |
| 428 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 429 | GrDrawContext* drawContext = this->drawContext(); |
| 430 | if (!drawContext) { |
| 431 | return false; |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 432 | } |
| 433 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 434 | GrPaint paint; |
| 435 | paint.addColorProcessor(fp); |
| 436 | |
| 437 | SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); |
| 438 | |
| 439 | drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, matrix, rect, NULL); |
| 440 | |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 441 | if (kFlushWrites_PixelOp & pixelOpsFlags) { |
| 442 | this->flushSurfaceWrites(surface); |
| 443 | } |
| 444 | |
| 445 | return true; |
| 446 | } |
bsalomon@google.com | a91e923 | 2012-02-23 15:39:54 +0000 | [diff] [blame] | 447 | |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 448 | // toggles between RGBA and BGRA |
| 449 | static SkColorType toggle_colortype32(SkColorType ct) { |
| 450 | if (kRGBA_8888_SkColorType == ct) { |
| 451 | return kBGRA_8888_SkColorType; |
| 452 | } else { |
| 453 | SkASSERT(kBGRA_8888_SkColorType == ct); |
| 454 | return kRGBA_8888_SkColorType; |
bsalomon@google.com | a91e923 | 2012-02-23 15:39:54 +0000 | [diff] [blame] | 455 | } |
| 456 | } |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 457 | |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 458 | bool GrContext::readRenderTargetPixels(GrRenderTarget* target, |
| 459 | int left, int top, int width, int height, |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 460 | GrPixelConfig dstConfig, void* buffer, size_t rowBytes, |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 461 | uint32_t flags) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 462 | RETURN_FALSE_IF_ABANDONED |
bsalomon@google.com | bc4b654 | 2011-11-19 13:56:11 +0000 | [diff] [blame] | 463 | ASSERT_OWNED_RESOURCE(target); |
bsalomon | 89c6298 | 2014-11-03 12:08:42 -0800 | [diff] [blame] | 464 | SkASSERT(target); |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 465 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 466 | if (!(kDontFlush_PixelOpsFlag & flags) && target->surfacePriv().hasPendingWrite()) { |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 467 | this->flush(); |
| 468 | } |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 469 | |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 470 | // Determine which conversions have to be applied: flipY, swapRAnd, and/or unpremul. |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 471 | |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 472 | // If fGpu->readPixels would incur a y-flip cost then we will read the pixels upside down. We'll |
| 473 | // either do the flipY by drawing into a scratch with a matrix or on the cpu after the read. |
| 474 | bool flipY = fGpu->readPixelsWillPayForYFlip(target, left, top, |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 475 | width, height, dstConfig, |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 476 | rowBytes); |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 477 | // We ignore the preferred config if it is different than our config unless it is an R/B swap. |
| 478 | // In that case we'll perform an R and B swap while drawing to a scratch texture of the swapped |
| 479 | // config. Then we will call readPixels on the scratch with the swapped config. The swaps during |
| 480 | // the draw cancels out the fact that we call readPixels with a config that is R/B swapped from |
| 481 | // dstConfig. |
| 482 | GrPixelConfig readConfig = dstConfig; |
| 483 | bool swapRAndB = false; |
commit-bot@chromium.org | 5d1d79a | 2013-05-24 18:52:52 +0000 | [diff] [blame] | 484 | if (GrPixelConfigSwapRAndB(dstConfig) == |
| 485 | fGpu->preferredReadPixelsConfig(dstConfig, target->config())) { |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 486 | readConfig = GrPixelConfigSwapRAndB(readConfig); |
| 487 | swapRAndB = true; |
| 488 | } |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 489 | |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 490 | bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags); |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 491 | |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 492 | if (unpremul && !GrPixelConfigIs8888(dstConfig)) { |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 493 | // The unpremul flag is only allowed for these two configs. |
bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 494 | return false; |
| 495 | } |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 496 | |
bsalomon | 191bcc0 | 2014-11-14 11:31:13 -0800 | [diff] [blame] | 497 | SkAutoTUnref<GrTexture> tempTexture; |
| 498 | |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 499 | // If the src is a texture and we would have to do conversions after read pixels, we instead |
| 500 | // do the conversions by drawing the src to a scratch texture. If we handle any of the |
| 501 | // conversions in the draw we set the corresponding bool to false so that we don't reapply it |
| 502 | // on the read back pixels. |
| 503 | GrTexture* src = target->asTexture(); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 504 | if (src && (swapRAndB || unpremul || flipY)) { |
bsalomon | 81beccc | 2014-10-13 12:32:55 -0700 | [diff] [blame] | 505 | // Make the scratch a render so we can read its pixels. |
bsalomon | f2703d8 | 2014-10-28 14:33:06 -0700 | [diff] [blame] | 506 | GrSurfaceDesc desc; |
| 507 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
robertphillips@google.com | 75b3c96 | 2012-06-07 12:08:45 +0000 | [diff] [blame] | 508 | desc.fWidth = width; |
| 509 | desc.fHeight = height; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 510 | desc.fConfig = readConfig; |
senorblanco@chromium.org | 3cb406b | 2013-02-05 19:50:46 +0000 | [diff] [blame] | 511 | desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
bsalomon@google.com | c4ff22a | 2011-11-10 21:56:21 +0000 | [diff] [blame] | 512 | |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 513 | // When a full read back is faster than a partial we could always make the scratch exactly |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 514 | // match the passed rect. However, if we see many different size rectangles we will trash |
| 515 | // our texture cache and pay the cost of creating and destroying many textures. So, we only |
| 516 | // request an exact match when the caller is reading an entire RT. |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 517 | GrTextureProvider::ScratchTexMatch match = GrTextureProvider::kApprox_ScratchTexMatch; |
bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 518 | if (0 == left && |
| 519 | 0 == top && |
| 520 | target->width() == width && |
| 521 | target->height() == height && |
| 522 | fGpu->fullReadPixelsIsFasterThanPartial()) { |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 523 | match = GrTextureProvider::kExact_ScratchTexMatch; |
bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 524 | } |
bsalomon | d309e7a | 2015-04-30 14:18:54 -0700 | [diff] [blame] | 525 | tempTexture.reset(this->textureProvider()->refScratchTexture(desc, match)); |
bsalomon | 191bcc0 | 2014-11-14 11:31:13 -0800 | [diff] [blame] | 526 | if (tempTexture) { |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 527 | // compute a matrix to perform the draw |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 528 | SkMatrix textureMatrix; |
senorblanco@chromium.org | 3cb406b | 2013-02-05 19:50:46 +0000 | [diff] [blame] | 529 | textureMatrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top); |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 530 | textureMatrix.postIDiv(src->width(), src->height()); |
| 531 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 532 | SkAutoTUnref<const GrFragmentProcessor> fp; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 533 | if (unpremul) { |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 534 | fp.reset(this->createPMToUPMEffect(src, swapRAndB, textureMatrix)); |
| 535 | if (fp) { |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 536 | unpremul = false; // we no longer need to do this on CPU after the read back. |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 537 | } |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 538 | } |
| 539 | // If we failed to create a PM->UPM effect and have no other conversions to perform then |
| 540 | // there is no longer any point to using the scratch. |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 541 | if (fp || flipY || swapRAndB) { |
| 542 | if (!fp) { |
| 543 | fp.reset(GrConfigConversionEffect::Create( |
| 544 | src, swapRAndB, GrConfigConversionEffect::kNone_PMConversion, |
| 545 | textureMatrix)); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 546 | } |
| 547 | swapRAndB = false; // we will handle the swap in the draw. |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 548 | |
robertphillips@google.com | 13f181f | 2013-03-02 12:02:08 +0000 | [diff] [blame] | 549 | // We protect the existing geometry here since it may not be |
| 550 | // clear to the caller that a draw operation (i.e., drawSimpleRect) |
| 551 | // can be invoked in this method |
joshualitt | 5c55fef | 2014-10-31 14:04:35 -0700 | [diff] [blame] | 552 | { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 553 | GrDrawContext* drawContext = this->drawContext(); |
| 554 | if (!drawContext) { |
| 555 | return false; |
| 556 | } |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 557 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 558 | GrPaint paint; |
| 559 | paint.addColorProcessor(fp); |
| 560 | |
joshualitt | 5c55fef | 2014-10-31 14:04:35 -0700 | [diff] [blame] | 561 | SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 562 | |
| 563 | drawContext->drawRect(tempTexture->asRenderTarget(), GrClip::WideOpen(), paint, |
| 564 | SkMatrix::I(), rect, NULL); |
| 565 | |
joshualitt | 5c55fef | 2014-10-31 14:04:35 -0700 | [diff] [blame] | 566 | // we want to read back from the scratch's origin |
| 567 | left = 0; |
| 568 | top = 0; |
bsalomon | 191bcc0 | 2014-11-14 11:31:13 -0800 | [diff] [blame] | 569 | target = tempTexture->asRenderTarget(); |
joshualitt | 5c55fef | 2014-10-31 14:04:35 -0700 | [diff] [blame] | 570 | } |
| 571 | this->flushSurfaceWrites(target); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 572 | } |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 573 | } |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 574 | } |
joshualitt | 5c55fef | 2014-10-31 14:04:35 -0700 | [diff] [blame] | 575 | |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 576 | if (!fGpu->readPixels(target, |
| 577 | left, top, width, height, |
senorblanco@chromium.org | 3cb406b | 2013-02-05 19:50:46 +0000 | [diff] [blame] | 578 | readConfig, buffer, rowBytes)) { |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 579 | return false; |
| 580 | } |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 581 | // Perform any conversions we weren't able to perform using a scratch texture. |
senorblanco@chromium.org | 3cb406b | 2013-02-05 19:50:46 +0000 | [diff] [blame] | 582 | if (unpremul || swapRAndB) { |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 583 | SkDstPixelInfo dstPI; |
jvanverth | fa1e8a7 | 2014-12-22 08:31:49 -0800 | [diff] [blame] | 584 | if (!GrPixelConfig2ColorAndProfileType(dstConfig, &dstPI.fColorType, NULL)) { |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 585 | return false; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 586 | } |
reed@google.com | 7111d46 | 2014-03-25 16:20:24 +0000 | [diff] [blame] | 587 | dstPI.fAlphaType = kUnpremul_SkAlphaType; |
| 588 | dstPI.fPixels = buffer; |
| 589 | dstPI.fRowBytes = rowBytes; |
| 590 | |
| 591 | SkSrcPixelInfo srcPI; |
| 592 | srcPI.fColorType = swapRAndB ? toggle_colortype32(dstPI.fColorType) : dstPI.fColorType; |
| 593 | srcPI.fAlphaType = kPremul_SkAlphaType; |
| 594 | srcPI.fPixels = buffer; |
| 595 | srcPI.fRowBytes = rowBytes; |
| 596 | |
| 597 | return srcPI.convertPixelsTo(&dstPI, width, height); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 598 | } |
| 599 | return true; |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 600 | } |
| 601 | |
bsalomon | 87a94eb | 2014-11-03 14:28:32 -0800 | [diff] [blame] | 602 | void GrContext::prepareSurfaceForExternalRead(GrSurface* surface) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 603 | RETURN_IF_ABANDONED |
bsalomon | 87a94eb | 2014-11-03 14:28:32 -0800 | [diff] [blame] | 604 | SkASSERT(surface); |
| 605 | ASSERT_OWNED_RESOURCE(surface); |
| 606 | if (surface->surfacePriv().hasPendingIO()) { |
| 607 | this->flush(); |
| 608 | } |
| 609 | GrRenderTarget* rt = surface->asRenderTarget(); |
| 610 | if (fGpu && rt) { |
| 611 | fGpu->resolveRenderTarget(rt); |
bsalomon | 41ebbdd | 2014-08-04 08:31:39 -0700 | [diff] [blame] | 612 | } |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 613 | } |
| 614 | |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 615 | void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, |
| 616 | const SkIPoint& dstPoint, uint32_t pixelOpsFlags) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 617 | RETURN_IF_ABANDONED |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 618 | if (!src || !dst) { |
senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 619 | return; |
| 620 | } |
bsalomon | e3d4bf2 | 2014-09-23 09:15:03 -0700 | [diff] [blame] | 621 | ASSERT_OWNED_RESOURCE(src); |
junov | 2bb5210 | 2014-09-29 10:18:59 -0700 | [diff] [blame] | 622 | ASSERT_OWNED_RESOURCE(dst); |
Brian Salomon | 34a9895 | 2014-09-24 11:41:24 -0400 | [diff] [blame] | 623 | |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 624 | // Since we're going to the draw target and not GPU, no need to check kNoFlush |
| 625 | // here. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 626 | if (!dst->asRenderTarget()) { |
junov | 96c118e | 2014-09-26 13:09:47 -0700 | [diff] [blame] | 627 | return; |
| 628 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 629 | |
| 630 | GrDrawContext* drawContext = this->drawContext(); |
| 631 | if (!drawContext) { |
| 632 | return; |
| 633 | } |
| 634 | |
| 635 | drawContext->copySurface(dst->asRenderTarget(), src, srcRect, dstPoint); |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 636 | |
| 637 | if (kFlushWrites_PixelOp & pixelOpsFlags) { |
| 638 | this->flush(); |
| 639 | } |
senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 640 | } |
| 641 | |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 642 | void GrContext::flushSurfaceWrites(GrSurface* surface) { |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 643 | RETURN_IF_ABANDONED |
bsalomon | f80bfed | 2014-10-07 05:56:02 -0700 | [diff] [blame] | 644 | if (surface->surfacePriv().hasPendingWrite()) { |
| 645 | this->flush(); |
| 646 | } |
| 647 | } |
| 648 | |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 649 | /* |
| 650 | * This method finds a path renderer that can draw the specified path on |
| 651 | * the provided target. |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 652 | * 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] | 653 | * can be individually allowed/disallowed via the "allowSW" boolean. |
| 654 | */ |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 655 | GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 656 | const GrPipelineBuilder* pipelineBuilder, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 657 | const SkMatrix& viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 658 | const SkPath& path, |
kkinnunen | 1899651 | 2015-04-26 23:18:49 -0700 | [diff] [blame] | 659 | const GrStrokeInfo& stroke, |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 660 | bool allowSW, |
| 661 | GrPathRendererChain::DrawType drawType, |
| 662 | GrPathRendererChain::StencilSupport* stencilSupport) { |
| 663 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 664 | if (!fPathRendererChain) { |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 665 | fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this)); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 666 | } |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 667 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 668 | GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 669 | pipelineBuilder, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 670 | viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 671 | path, |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 672 | stroke, |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 673 | drawType, |
| 674 | stencilSupport); |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 675 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 676 | if (!pr && allowSW) { |
| 677 | if (!fSoftwarePathRenderer) { |
tomhudson@google.com | c377baf | 2012-07-09 20:17:56 +0000 | [diff] [blame] | 678 | fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this)); |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 679 | } |
robertphillips@google.com | 72176b2 | 2012-05-23 13:19:12 +0000 | [diff] [blame] | 680 | pr = fSoftwarePathRenderer; |
| 681 | } |
| 682 | |
| 683 | return pr; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 684 | } |
| 685 | |
bsalomon@google.com | 27847de | 2011-02-22 20:59:41 +0000 | [diff] [blame] | 686 | //////////////////////////////////////////////////////////////////////////////// |
commit-bot@chromium.org | b471a32 | 2014-03-10 07:40:03 +0000 | [diff] [blame] | 687 | int GrContext::getRecommendedSampleCount(GrPixelConfig config, |
| 688 | SkScalar dpi) const { |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 689 | if (!this->caps()->isConfigRenderable(config, true)) { |
commit-bot@chromium.org | b471a32 | 2014-03-10 07:40:03 +0000 | [diff] [blame] | 690 | return 0; |
| 691 | } |
| 692 | int chosenSampleCount = 0; |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 693 | if (fGpu->caps()->shaderCaps()->pathRenderingSupport()) { |
commit-bot@chromium.org | b471a32 | 2014-03-10 07:40:03 +0000 | [diff] [blame] | 694 | if (dpi >= 250.0f) { |
| 695 | chosenSampleCount = 4; |
| 696 | } else { |
| 697 | chosenSampleCount = 16; |
| 698 | } |
| 699 | } |
| 700 | return chosenSampleCount <= fGpu->caps()->maxSampleCount() ? |
| 701 | chosenSampleCount : 0; |
| 702 | } |
| 703 | |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 704 | namespace { |
| 705 | void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { |
| 706 | GrConfigConversionEffect::PMConversion pmToUPM; |
| 707 | GrConfigConversionEffect::PMConversion upmToPM; |
| 708 | GrConfigConversionEffect::TestForPreservingPMConversions(ctx, &pmToUPM, &upmToPM); |
| 709 | *pmToUPMValue = pmToUPM; |
| 710 | *upmToPMValue = upmToPM; |
| 711 | } |
| 712 | } |
| 713 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 714 | const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrTexture* texture, |
| 715 | bool swapRAndB, |
| 716 | const SkMatrix& matrix) { |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 717 | if (!fDidTestPMConversions) { |
| 718 | test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion); |
bsalomon@google.com | d0f3f68 | 2012-08-28 13:08:14 +0000 | [diff] [blame] | 719 | fDidTestPMConversions = true; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 720 | } |
| 721 | GrConfigConversionEffect::PMConversion pmToUPM = |
| 722 | static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion); |
| 723 | if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) { |
bsalomon@google.com | adc6536 | 2013-01-28 14:26:09 +0000 | [diff] [blame] | 724 | return GrConfigConversionEffect::Create(texture, swapRAndB, pmToUPM, matrix); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 725 | } else { |
bsalomon@google.com | adc6536 | 2013-01-28 14:26:09 +0000 | [diff] [blame] | 726 | return NULL; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 727 | } |
| 728 | } |
| 729 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 730 | const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrTexture* texture, |
| 731 | bool swapRAndB, |
| 732 | const SkMatrix& matrix) { |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 733 | if (!fDidTestPMConversions) { |
| 734 | test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion); |
bsalomon@google.com | d0f3f68 | 2012-08-28 13:08:14 +0000 | [diff] [blame] | 735 | fDidTestPMConversions = true; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 736 | } |
| 737 | GrConfigConversionEffect::PMConversion upmToPM = |
| 738 | static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); |
| 739 | if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) { |
bsalomon@google.com | adc6536 | 2013-01-28 14:26:09 +0000 | [diff] [blame] | 740 | return GrConfigConversionEffect::Create(texture, swapRAndB, upmToPM, matrix); |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 741 | } else { |
bsalomon@google.com | adc6536 | 2013-01-28 14:26:09 +0000 | [diff] [blame] | 742 | return NULL; |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 743 | } |
| 744 | } |
| 745 | |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 746 | ////////////////////////////////////////////////////////////////////////////// |
| 747 | |
| 748 | void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes) const { |
| 749 | if (maxTextures) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 750 | *maxTextures = fResourceCache->getMaxResourceCount(); |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 751 | } |
| 752 | if (maxTextureBytes) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 753 | *maxTextureBytes = fResourceCache->getMaxResourceBytes(); |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 754 | } |
| 755 | } |
| 756 | |
| 757 | void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) { |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 758 | fResourceCache->setLimits(maxTextures, maxTextureBytes); |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 759 | } |
| 760 | |
bsalomon | 37f9a26 | 2015-02-02 13:00:10 -0800 | [diff] [blame] | 761 | ////////////////////////////////////////////////////////////////////////////// |
| 762 | |
egdaniel | bbcb38d | 2014-06-19 10:19:29 -0700 | [diff] [blame] | 763 | void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { |
| 764 | fGpu->addGpuTraceMarker(marker); |
egdaniel | bbcb38d | 2014-06-19 10:19:29 -0700 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
| 768 | fGpu->removeGpuTraceMarker(marker); |
egdaniel | bbcb38d | 2014-06-19 10:19:29 -0700 | [diff] [blame] | 769 | } |
joshualitt | e590266 | 2015-05-11 08:18:35 -0700 | [diff] [blame] | 770 | |