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

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 427823002: Remove gpu support for willUseHWAALines. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Nits Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLNameAllocator.h" 10 #include "GrGLNameAllocator.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 // We should set glPolygonMode(FRONT_AND_BACK,FILL) here, too. It is n't 274 // We should set glPolygonMode(FRONT_AND_BACK,FILL) here, too. It is n't
275 // currently part of our gl interface. There are probably others as 275 // currently part of our gl interface. There are probably others as
276 // well. 276 // well.
277 } 277 }
278 fHWWriteToColor = kUnknown_TriState; 278 fHWWriteToColor = kUnknown_TriState;
279 // we only ever use lines in hairline mode 279 // we only ever use lines in hairline mode
280 GL_CALL(LineWidth(1)); 280 GL_CALL(LineWidth(1));
281 } 281 }
282 282
283 if (resetBits & kAA_GrGLBackendState) { 283 if (resetBits & kMSAAEnable_GrGLBackendState) {
284 fHWAAState.invalidate(); 284 fMSAAEnabled = kUnknown_TriState;
285 } 285 }
286 286
287 fHWActiveTextureUnitIdx = -1; // invalid 287 fHWActiveTextureUnitIdx = -1; // invalid
288 288
289 if (resetBits & kTextureBinding_GrGLBackendState) { 289 if (resetBits & kTextureBinding_GrGLBackendState) {
290 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) { 290 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) {
291 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID; 291 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID;
292 } 292 }
293 } 293 }
294 294
(...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 // the target is not multisampled. Single pixel wide lines are rendered thicker than 1 pixel wide. 2157 // the target is not multisampled. Single pixel wide lines are rendered thicker than 1 pixel wide.
2158 #if 0 2158 #if 0
2159 // Replace RT_HAS_MSAA with this definition once this driver bug is no longe r a relevant concern 2159 // Replace RT_HAS_MSAA with this definition once this driver bug is no longe r a relevant concern
2160 #define RT_HAS_MSAA rt->isMultisampled() 2160 #define RT_HAS_MSAA rt->isMultisampled()
2161 #else 2161 #else
2162 #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == type) 2162 #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == type)
2163 #endif 2163 #endif
2164 2164
2165 const GrRenderTarget* rt = this->getDrawState().getRenderTarget(); 2165 const GrRenderTarget* rt = this->getDrawState().getRenderTarget();
2166 if (kGL_GrGLStandard == this->glStandard()) { 2166 if (kGL_GrGLStandard == this->glStandard()) {
2167 // ES doesn't support toggling GL_MULTISAMPLE and doesn't have 2167 if (RT_HAS_MSAA) {
2168 // smooth lines.
2169 // we prefer smooth lines over multisampled lines
2170 bool smoothLines = false;
2171
2172 if (kDrawLines_DrawType == type) {
2173 smoothLines = this->willUseHWAALines();
2174 if (smoothLines) {
2175 if (kYes_TriState != fHWAAState.fSmoothLineEnabled) {
2176 GL_CALL(Enable(GR_GL_LINE_SMOOTH));
2177 fHWAAState.fSmoothLineEnabled = kYes_TriState;
2178 // must disable msaa to use line smoothing
2179 if (RT_HAS_MSAA &&
2180 kNo_TriState != fHWAAState.fMSAAEnabled) {
2181 GL_CALL(Disable(GR_GL_MULTISAMPLE));
2182 fHWAAState.fMSAAEnabled = kNo_TriState;
2183 }
2184 }
2185 } else {
2186 if (kNo_TriState != fHWAAState.fSmoothLineEnabled) {
2187 GL_CALL(Disable(GR_GL_LINE_SMOOTH));
2188 fHWAAState.fSmoothLineEnabled = kNo_TriState;
2189 }
2190 }
2191 }
2192 if (!smoothLines && RT_HAS_MSAA) {
2193 // FIXME: GL_NV_pr doesn't seem to like MSAA disabled. The paths 2168 // FIXME: GL_NV_pr doesn't seem to like MSAA disabled. The paths
2194 // convex hulls of each segment appear to get filled. 2169 // convex hulls of each segment appear to get filled.
2195 bool enableMSAA = kStencilPath_DrawType == type || 2170 bool enableMSAA = kStencilPath_DrawType == type ||
2196 this->getDrawState().isHWAntialiasState(); 2171 this->getDrawState().isHWAntialiasState();
2197 if (enableMSAA) { 2172 if (enableMSAA) {
2198 if (kYes_TriState != fHWAAState.fMSAAEnabled) { 2173 if (kYes_TriState != fMSAAEnabled) {
2199 GL_CALL(Enable(GR_GL_MULTISAMPLE)); 2174 GL_CALL(Enable(GR_GL_MULTISAMPLE));
2200 fHWAAState.fMSAAEnabled = kYes_TriState; 2175 fMSAAEnabled = kYes_TriState;
2201 } 2176 }
2202 } else { 2177 } else {
2203 if (kNo_TriState != fHWAAState.fMSAAEnabled) { 2178 if (kNo_TriState != fMSAAEnabled) {
2204 GL_CALL(Disable(GR_GL_MULTISAMPLE)); 2179 GL_CALL(Disable(GR_GL_MULTISAMPLE));
2205 fHWAAState.fMSAAEnabled = kNo_TriState; 2180 fMSAAEnabled = kNo_TriState;
2206 } 2181 }
2207 } 2182 }
2208 } 2183 }
2209 } 2184 }
2210 } 2185 }
2211 2186
2212 void GrGpuGL::flushPathStencilSettings(SkPath::FillType fill) { 2187 void GrGpuGL::flushPathStencilSettings(SkPath::FillType fill) {
2213 GrStencilSettings pathStencilSettings; 2188 GrStencilSettings pathStencilSettings;
2214 this->getPathStencilSettingsForFillType(fill, &pathStencilSettings); 2189 this->getPathStencilSettingsForFillType(fill, &pathStencilSettings);
2215 if (fHWPathStencilSettings != pathStencilSettings) { 2190 if (fHWPathStencilSettings != pathStencilSettings) {
2216 // Just the func, ref, and mask is set here. The op and write mask are p arams to the call 2191 // Just the func, ref, and mask is set here. The op and write mask are p arams to the call
2217 // that draws the path to the SB (glStencilFillPath) 2192 // that draws the path to the SB (glStencilFillPath)
2218 GrGLenum func = 2193 GrGLenum func =
2219 gr_to_gl_stencil_func(pathStencilSettings.func(GrStencilSettings::kF ront_Face)); 2194 gr_to_gl_stencil_func(pathStencilSettings.func(GrStencilSettings::kF ront_Face));
2220 GL_CALL(PathStencilFunc(func, 2195 GL_CALL(PathStencilFunc(func,
2221 pathStencilSettings.funcRef(GrStencilSettings::k Front_Face), 2196 pathStencilSettings.funcRef(GrStencilSettings::k Front_Face),
2222 pathStencilSettings.funcMask(GrStencilSettings:: kFront_Face))); 2197 pathStencilSettings.funcMask(GrStencilSettings:: kFront_Face)));
2223 2198
2224 fHWPathStencilSettings = pathStencilSettings; 2199 fHWPathStencilSettings = pathStencilSettings;
2225 } 2200 }
2226 } 2201 }
2227 2202
2228 void GrGpuGL::flushBlend(bool isLines, 2203 void GrGpuGL::flushBlend(bool isLines,
2229 GrBlendCoeff srcCoeff, 2204 GrBlendCoeff srcCoeff,
2230 GrBlendCoeff dstCoeff) { 2205 GrBlendCoeff dstCoeff) {
2231 if (isLines && this->willUseHWAALines()) { 2206 // Any optimization to disable blending should have already been applied and
2207 // tweaked the coeffs to (1, 0).
2208 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo eff;
2209 if (blendOff) {
2210 if (kNo_TriState != fHWBlendState.fEnabled) {
2211 GL_CALL(Disable(GR_GL_BLEND));
2212 fHWBlendState.fEnabled = kNo_TriState;
2213 }
2214 } else {
2232 if (kYes_TriState != fHWBlendState.fEnabled) { 2215 if (kYes_TriState != fHWBlendState.fEnabled) {
2233 GL_CALL(Enable(GR_GL_BLEND)); 2216 GL_CALL(Enable(GR_GL_BLEND));
2234 fHWBlendState.fEnabled = kYes_TriState; 2217 fHWBlendState.fEnabled = kYes_TriState;
2235 } 2218 }
2236 if (kSA_GrBlendCoeff != fHWBlendState.fSrcCoeff || 2219 if (fHWBlendState.fSrcCoeff != srcCoeff ||
2237 kISA_GrBlendCoeff != fHWBlendState.fDstCoeff) { 2220 fHWBlendState.fDstCoeff != dstCoeff) {
2238 GL_CALL(BlendFunc(gXfermodeCoeff2Blend[kSA_GrBlendCoeff], 2221 GL_CALL(BlendFunc(gXfermodeCoeff2Blend[srcCoeff],
2239 gXfermodeCoeff2Blend[kISA_GrBlendCoeff])); 2222 gXfermodeCoeff2Blend[dstCoeff]));
2240 fHWBlendState.fSrcCoeff = kSA_GrBlendCoeff; 2223 fHWBlendState.fSrcCoeff = srcCoeff;
2241 fHWBlendState.fDstCoeff = kISA_GrBlendCoeff; 2224 fHWBlendState.fDstCoeff = dstCoeff;
2242 } 2225 }
2243 } else { 2226 GrColor blendConst = this->getDrawState().getBlendConstant();
2244 // any optimization to disable blending should 2227 if ((BlendCoeffReferencesConstant(srcCoeff) ||
2245 // have already been applied and tweaked the coeffs 2228 BlendCoeffReferencesConstant(dstCoeff)) &&
2246 // to (1, 0). 2229 (!fHWBlendState.fConstColorValid ||
2247 bool blendOff = kOne_GrBlendCoeff == srcCoeff && 2230 fHWBlendState.fConstColor != blendConst)) {
2248 kZero_GrBlendCoeff == dstCoeff; 2231 GrGLfloat c[4];
2249 if (blendOff) { 2232 GrColorToRGBAFloat(blendConst, c);
2250 if (kNo_TriState != fHWBlendState.fEnabled) { 2233 GL_CALL(BlendColor(c[0], c[1], c[2], c[3]));
2251 GL_CALL(Disable(GR_GL_BLEND)); 2234 fHWBlendState.fConstColor = blendConst;
2252 fHWBlendState.fEnabled = kNo_TriState; 2235 fHWBlendState.fConstColorValid = true;
2253 }
2254 } else {
2255 if (kYes_TriState != fHWBlendState.fEnabled) {
2256 GL_CALL(Enable(GR_GL_BLEND));
2257 fHWBlendState.fEnabled = kYes_TriState;
2258 }
2259 if (fHWBlendState.fSrcCoeff != srcCoeff ||
2260 fHWBlendState.fDstCoeff != dstCoeff) {
2261 GL_CALL(BlendFunc(gXfermodeCoeff2Blend[srcCoeff],
2262 gXfermodeCoeff2Blend[dstCoeff]));
2263 fHWBlendState.fSrcCoeff = srcCoeff;
2264 fHWBlendState.fDstCoeff = dstCoeff;
2265 }
2266 GrColor blendConst = this->getDrawState().getBlendConstant();
2267 if ((BlendCoeffReferencesConstant(srcCoeff) ||
2268 BlendCoeffReferencesConstant(dstCoeff)) &&
2269 (!fHWBlendState.fConstColorValid ||
2270 fHWBlendState.fConstColor != blendConst)) {
2271 GrGLfloat c[4];
2272 GrColorToRGBAFloat(blendConst, c);
2273 GL_CALL(BlendColor(c[0], c[1], c[2], c[3]));
2274 fHWBlendState.fConstColor = blendConst;
2275 fHWBlendState.fConstColorValid = true;
2276 }
2277 } 2236 }
2278 } 2237 }
2279 } 2238 }
2280 2239
2281 static inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) { 2240 static inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
2282 static const GrGLenum gWrapModes[] = { 2241 static const GrGLenum gWrapModes[] = {
2283 GR_GL_CLAMP_TO_EDGE, 2242 GR_GL_CLAMP_TO_EDGE,
2284 GR_GL_REPEAT, 2243 GR_GL_REPEAT,
2285 GR_GL_MIRRORED_REPEAT 2244 GR_GL_MIRRORED_REPEAT
2286 }; 2245 };
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
3018 this->setVertexArrayID(gpu, 0); 2977 this->setVertexArrayID(gpu, 0);
3019 } 2978 }
3020 int attrCount = gpu->glCaps().maxVertexAttributes(); 2979 int attrCount = gpu->glCaps().maxVertexAttributes();
3021 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2980 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3022 fDefaultVertexArrayAttribState.resize(attrCount); 2981 fDefaultVertexArrayAttribState.resize(attrCount);
3023 } 2982 }
3024 attribState = &fDefaultVertexArrayAttribState; 2983 attribState = &fDefaultVertexArrayAttribState;
3025 } 2984 }
3026 return attribState; 2985 return attribState;
3027 } 2986 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698