Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrDrawContext.h" | 8 #include "GrDrawContext.h" |
| 9 #include "GrDrawingManager.h" | 9 #include "GrDrawingManager.h" |
| 10 #include "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 if (!pr && allowSW) { | 177 if (!pr && allowSW) { |
| 178 if (!fSoftwarePathRenderer) { | 178 if (!fSoftwarePathRenderer) { |
| 179 fSoftwarePathRenderer = new GrSoftwarePathRenderer(fContext->texture Provider()); | 179 fSoftwarePathRenderer = new GrSoftwarePathRenderer(fContext->texture Provider()); |
| 180 } | 180 } |
| 181 pr = fSoftwarePathRenderer; | 181 pr = fSoftwarePathRenderer; |
| 182 } | 182 } |
| 183 | 183 |
| 184 return pr; | 184 return pr; |
| 185 } | 185 } |
| 186 | 186 |
| 187 static bool checkConfigAndColorSpace(GrPixelConfig config, SkColorSpace* colorSp ace) { | |
|
Brian Osman
2016/08/23 19:54:46
I'm sad that I have this code in three places, now
| |
| 188 switch (config) { | |
| 189 case kRGBA_half_GrPixelConfig: | |
| 190 return colorSpace && SkColorSpace::kLinear_GammaNamed == colorSpace- >gammaNamed(); | |
| 191 case kSRGBA_8888_GrPixelConfig: | |
| 192 case kSBGRA_8888_GrPixelConfig: | |
| 193 return colorSpace && colorSpace->gammaCloseToSRGB(); | |
| 194 default: | |
| 195 return !colorSpace; | |
| 196 } | |
| 197 } | |
| 198 | |
| 187 sk_sp<GrDrawContext> GrDrawingManager::makeDrawContext(sk_sp<GrRenderTarget> rt, | 199 sk_sp<GrDrawContext> GrDrawingManager::makeDrawContext(sk_sp<GrRenderTarget> rt, |
| 188 sk_sp<SkColorSpace> color Space, | 200 sk_sp<SkColorSpace> color Space, |
| 189 const SkSurfaceProps* sur faceProps) { | 201 const SkSurfaceProps* sur faceProps) { |
| 190 if (this->wasAbandoned()) { | 202 if (this->wasAbandoned()) { |
| 191 return nullptr; | 203 return nullptr; |
| 192 } | 204 } |
| 193 | 205 |
| 206 if (!checkConfigAndColorSpace(rt->config(), colorSpace.get())) { | |
| 207 return nullptr; | |
| 208 } | |
| 194 | 209 |
| 195 bool useDIF = false; | 210 bool useDIF = false; |
| 196 if (surfaceProps) { | 211 if (surfaceProps) { |
| 197 useDIF = surfaceProps->isUseDeviceIndependentFonts(); | 212 useDIF = surfaceProps->isUseDeviceIndependentFonts(); |
| 198 } | 213 } |
| 199 | 214 |
| 200 if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() && | 215 if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() && |
| 201 rt->isStencilBufferMultisampled()) { | 216 rt->isStencilBufferMultisampled()) { |
| 202 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt achment(rt.get()); | 217 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt achment(rt.get()); |
| 203 if (sb) { | 218 if (sb) { |
| 204 return sk_sp<GrDrawContext>(new GrPathRenderingDrawContext( | 219 return sk_sp<GrDrawContext>(new GrPathRenderingDrawContext( |
| 205 fContext, this, std::mov e(rt), | 220 fContext, this, std::mov e(rt), |
| 206 std::move(colorSpace), s urfaceProps, | 221 std::move(colorSpace), s urfaceProps, |
| 207 fContext->getAuditTrail( ), fSingleOwner)); | 222 fContext->getAuditTrail( ), fSingleOwner)); |
| 208 } | 223 } |
| 209 } | 224 } |
| 210 | 225 |
| 211 return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt), | 226 return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt), |
| 212 std::move(colorSpace), surface Props, | 227 std::move(colorSpace), surface Props, |
| 213 fContext->getAuditTrail(), | 228 fContext->getAuditTrail(), |
| 214 fSingleOwner)); | 229 fSingleOwner)); |
| 215 } | 230 } |
| OLD | NEW |