Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
| 10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
| 11 #include "GrGLStencilAttachment.h" | 11 #include "GrGLStencilAttachment.h" |
| 12 #include "GrGLTextureRenderTarget.h" | 12 #include "GrGLTextureRenderTarget.h" |
| 13 #include "GrGpuResourcePriv.h" | 13 #include "GrGpuResourcePriv.h" |
| 14 #include "GrPipeline.h" | 14 #include "GrPipeline.h" |
| 15 #include "GrPLSGeometryProcessor.h" | |
| 15 #include "GrRenderTargetPriv.h" | 16 #include "GrRenderTargetPriv.h" |
| 16 #include "GrSurfacePriv.h" | 17 #include "GrSurfacePriv.h" |
| 17 #include "GrTexturePriv.h" | 18 #include "GrTexturePriv.h" |
| 18 #include "GrTypes.h" | 19 #include "GrTypes.h" |
| 19 #include "GrVertices.h" | 20 #include "GrVertices.h" |
| 20 #include "builders/GrGLShaderStringBuilder.h" | 21 #include "builders/GrGLShaderStringBuilder.h" |
| 21 #include "glsl/GrGLSL.h" | 22 #include "glsl/GrGLSL.h" |
| 22 #include "glsl/GrGLSLCaps.h" | 23 #include "glsl/GrGLSLCaps.h" |
| 24 #include "glsl/GrGLSLPLSPathRendering.h" | |
| 23 #include "SkStrokeRec.h" | 25 #include "SkStrokeRec.h" |
| 24 #include "SkTemplates.h" | 26 #include "SkTemplates.h" |
| 25 | 27 |
| 26 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) | 28 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) |
| 27 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) | 29 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) |
| 28 | 30 |
| 29 #define SKIP_CACHE_CHECK true | 31 #define SKIP_CACHE_CHECK true |
| 30 | 32 |
| 31 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR | 33 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR |
| 32 #define CLEAR_ERROR_BEFORE_ALLOC(iface) GrGLClearErr(iface) | 34 #define CLEAR_ERROR_BEFORE_ALLOC(iface) GrGLClearErr(iface) |
| 33 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL_NOERRCHECK(iface, call) | 35 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL_NOERRCHECK(iface, call) |
| 34 #define CHECK_ALLOC_ERROR(iface) GR_GL_GET_ERROR(iface) | 36 #define CHECK_ALLOC_ERROR(iface) GR_GL_GET_ERROR(iface) |
| 35 #else | 37 #else |
| 36 #define CLEAR_ERROR_BEFORE_ALLOC(iface) | 38 #define CLEAR_ERROR_BEFORE_ALLOC(iface) |
| 37 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL(iface, call) | 39 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL(iface, call) |
| 38 #define CHECK_ALLOC_ERROR(iface) GR_GL_NO_ERROR | 40 #define CHECK_ALLOC_ERROR(iface) GR_GL_NO_ERROR |
| 39 #endif | 41 #endif |
| 40 | 42 |
| 41 | |
| 42 /////////////////////////////////////////////////////////////////////////////// | 43 /////////////////////////////////////////////////////////////////////////////// |
| 43 | 44 |
| 44 | 45 |
| 45 static const GrGLenum gXfermodeEquation2Blend[] = { | 46 static const GrGLenum gXfermodeEquation2Blend[] = { |
| 46 // Basic OpenGL blend equations. | 47 // Basic OpenGL blend equations. |
| 47 GR_GL_FUNC_ADD, | 48 GR_GL_FUNC_ADD, |
| 48 GR_GL_FUNC_SUBTRACT, | 49 GR_GL_FUNC_SUBTRACT, |
| 49 GR_GL_FUNC_REVERSE_SUBTRACT, | 50 GR_GL_FUNC_REVERSE_SUBTRACT, |
| 50 | 51 |
| 51 // GL_KHR_blend_equation_advanced. | 52 // GL_KHR_blend_equation_advanced. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 fTempSrcFBOID = 0; | 218 fTempSrcFBOID = 0; |
| 218 fTempDstFBOID = 0; | 219 fTempDstFBOID = 0; |
| 219 fStencilClearFBOID = 0; | 220 fStencilClearFBOID = 0; |
| 220 | 221 |
| 221 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 222 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
| 222 fPathRendering.reset(new GrGLPathRendering(this)); | 223 fPathRendering.reset(new GrGLPathRendering(this)); |
| 223 } | 224 } |
| 224 this->createCopyPrograms(); | 225 this->createCopyPrograms(); |
| 225 fWireRectProgram.fProgram = 0; | 226 fWireRectProgram.fProgram = 0; |
| 226 fWireRectArrayBuffer = 0; | 227 fWireRectArrayBuffer = 0; |
| 228 if (this->glCaps().shaderCaps()->plsPathRenderingSupport()) { | |
| 229 this->createPLSSetupProgram(); | |
| 230 } | |
| 231 else { | |
| 232 memset(&fPLSSetupProgram, 0, sizeof(fPLSSetupProgram)); | |
| 233 } | |
| 234 fHWPLSEnabled = false; | |
| 227 } | 235 } |
| 228 | 236 |
| 229 GrGLGpu::~GrGLGpu() { | 237 GrGLGpu::~GrGLGpu() { |
| 230 // Delete the path rendering explicitly, since it will need working gpu obje ct to release the | 238 // Delete the path rendering explicitly, since it will need working gpu obje ct to release the |
| 231 // resources the object itself holds. | 239 // resources the object itself holds. |
| 232 fPathRendering.reset(); | 240 fPathRendering.reset(); |
| 233 | 241 |
| 234 if (0 != fHWProgramID) { | 242 if (0 != fHWProgramID) { |
| 235 // detach the current program so there is no confusion on OpenGL's part | 243 // detach the current program so there is no confusion on OpenGL's part |
| 236 // that we want it to be deleted | 244 // that we want it to be deleted |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 258 } | 266 } |
| 259 | 267 |
| 260 if (0 != fWireRectProgram.fProgram) { | 268 if (0 != fWireRectProgram.fProgram) { |
| 261 GL_CALL(DeleteProgram(fWireRectProgram.fProgram)); | 269 GL_CALL(DeleteProgram(fWireRectProgram.fProgram)); |
| 262 } | 270 } |
| 263 | 271 |
| 264 if (0 != fWireRectArrayBuffer) { | 272 if (0 != fWireRectArrayBuffer) { |
| 265 GL_CALL(DeleteBuffers(1, &fWireRectArrayBuffer)); | 273 GL_CALL(DeleteBuffers(1, &fWireRectArrayBuffer)); |
| 266 } | 274 } |
| 267 | 275 |
| 276 if (0 != fPLSSetupProgram.fArrayBuffer) { | |
| 277 GL_CALL(DeleteBuffers(1, &fPLSSetupProgram.fArrayBuffer)); | |
| 278 } | |
| 279 | |
| 280 if (0 != fPLSSetupProgram.fProgram) { | |
| 281 GL_CALL(DeleteProgram(fPLSSetupProgram.fProgram)); | |
| 282 } | |
| 283 | |
| 268 delete fProgramCache; | 284 delete fProgramCache; |
| 269 } | 285 } |
| 270 | 286 |
| 287 void GrGLGpu::createPLSSetupProgram() { | |
| 288 const char* version = this->glCaps().glslCaps()->versionDeclString(); | |
| 289 | |
| 290 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute _TypeModifier); | |
| 291 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, | |
| 292 GrShaderVar::kUniform_TypeModifier); | |
| 293 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUnifo rm_TypeModifier); | |
| 294 GrGLSLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUni form_TypeModifier); | |
| 295 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVaryi ngOut_TypeModifier); | |
| 296 | |
| 297 SkString vshaderTxt(version); | |
| 298 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
| 299 vshaderTxt.append(";"); | |
| 300 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
| 301 vshaderTxt.append(";"); | |
| 302 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
| 303 vshaderTxt.append(";"); | |
| 304 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
| 305 vshaderTxt.append(";"); | |
| 306 | |
| 307 vshaderTxt.append( | |
| 308 "// PLS Setup Program VS\n" | |
| 309 "void main() {" | |
| 310 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" | |
| 311 " gl_Position.zw = vec2(0, 1);" | |
| 312 "}" | |
| 313 ); | |
| 314 | |
| 315 SkString fshaderTxt(version); | |
| 316 fshaderTxt.append("#extension "); | |
| 317 fshaderTxt.append(this->glCaps().glslCaps()->fbFetchExtensionString()); | |
| 318 fshaderTxt.append(" : require\n"); | |
| 319 fshaderTxt.append("#extension GL_EXT_shader_pixel_local_storage : require\n" ); | |
| 320 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | |
| 321 *this->glCaps().glslCaps(), | |
| 322 &fshaderTxt); | |
| 323 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); | |
| 324 vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
| 325 fshaderTxt.append(";"); | |
| 326 uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
| 327 fshaderTxt.append(";"); | |
| 328 | |
| 329 fshaderTxt.appendf( | |
| 330 "// PLS Setup Program FS\n" | |
| 331 PLS_PATH_DATA_DECL | |
| 332 "void main() {\n" | |
| 333 " " PLS_DSTCOLOR_NAME " = gl_LastFragColorARM;\n" | |
| 334 " pls.windings = ivec4(0, 0, 0, 0);\n" | |
| 335 "}" | |
| 336 ); | |
| 337 GL_CALL_RET(fPLSSetupProgram.fProgram, CreateProgram()); | |
| 338 const char* str; | |
| 339 GrGLint length; | |
| 340 | |
| 341 str = vshaderTxt.c_str(); | |
| 342 length = SkToInt(vshaderTxt.size()); | |
| 343 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fPLSSetupProgram. fProgram, | |
| 344 GR_GL_VERTEX_SHADER, &str, &le ngth, 1, &fStats); | |
| 345 | |
| 346 str = fshaderTxt.c_str(); | |
| 347 length = SkToInt(fshaderTxt.size()); | |
| 348 GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fPLSSetupProgram. fProgram, | |
| 349 GR_GL_FRAGMENT_SHADER, &str, & length, 1, &fStats); | |
| 350 | |
| 351 GL_CALL(LinkProgram(fPLSSetupProgram.fProgram)); | |
| 352 | |
| 353 GL_CALL_RET(fPLSSetupProgram.fPosXformUniform, GetUniformLocation(fPLSSetupP rogram.fProgram, | |
| 354 "u_posXform")) ; | |
| 355 | |
| 356 GL_CALL(BindAttribLocation(fPLSSetupProgram.fProgram, 0, "a_vertex")); | |
| 357 | |
| 358 GL_CALL(DeleteShader(vshader)); | |
| 359 GL_CALL(DeleteShader(fshader)); | |
| 360 | |
| 361 GL_CALL(GenBuffers(1, &fPLSSetupProgram.fArrayBuffer)); | |
| 362 fHWGeometryState.setVertexBufferID(this, fPLSSetupProgram.fArrayBuffer); | |
| 363 static const GrGLfloat vdata[] = { | |
| 364 0, 0, | |
| 365 0, 1, | |
| 366 1, 0, | |
| 367 1, 1 | |
| 368 }; | |
| 369 GL_ALLOC_CALL(this->glInterface(), | |
| 370 BufferData(GR_GL_ARRAY_BUFFER, | |
| 371 (GrGLsizeiptr) sizeof(vdata), | |
| 372 vdata, // data ptr | |
| 373 GR_GL_STATIC_DRAW)); | |
| 374 } | |
| 375 | |
| 271 void GrGLGpu::contextAbandoned() { | 376 void GrGLGpu::contextAbandoned() { |
| 272 INHERITED::contextAbandoned(); | 377 INHERITED::contextAbandoned(); |
| 273 fProgramCache->abandon(); | 378 fProgramCache->abandon(); |
| 274 fHWProgramID = 0; | 379 fHWProgramID = 0; |
| 275 fTempSrcFBOID = 0; | 380 fTempSrcFBOID = 0; |
| 276 fTempDstFBOID = 0; | 381 fTempDstFBOID = 0; |
| 277 fStencilClearFBOID = 0; | 382 fStencilClearFBOID = 0; |
| 278 fCopyProgramArrayBuffer = 0; | 383 fCopyProgramArrayBuffer = 0; |
| 279 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 384 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
| 280 fCopyPrograms[i].fProgram = 0; | 385 fCopyPrograms[i].fProgram = 0; |
| (...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2138 if (!flipY) { | 2243 if (!flipY) { |
| 2139 dst += rowBytes; | 2244 dst += rowBytes; |
| 2140 } else { | 2245 } else { |
| 2141 dst -= rowBytes; | 2246 dst -= rowBytes; |
| 2142 } | 2247 } |
| 2143 } | 2248 } |
| 2144 } | 2249 } |
| 2145 return true; | 2250 return true; |
| 2146 } | 2251 } |
| 2147 | 2252 |
| 2253 void GrGLGpu::performFlushWorkaround() { | |
| 2254 if (this->glCaps().shaderCaps()->plsPathRenderingSupport() && fMSAAEnabled = = kNo_TriState) { | |
|
bsalomon
2016/01/20 18:27:31
Why the fMSAAEnabled check here?
ethannicholas
2016/01/20 22:25:04
Enabling PLS in the presence of MSAA leads to GL_I
| |
| 2255 /* There is an ARM driver bug where if we use PLS, and then draw a frame which does not | |
| 2256 * use PLS, it leaves garbage all over the place. As a workaround, we us e PLS in a | |
| 2257 * trivial way every frame. | |
| 2258 */ | |
| 2259 if (kYes_TriState == fHWScissorSettings.fEnabled) { | |
|
bsalomon
2016/01/20 18:27:31
Probably better to just call this->disableScissor(
| |
| 2260 GL_CALL(Disable(GR_GL_SCISSOR_TEST)); | |
| 2261 } | |
| 2262 SkASSERT(!fHWPLSEnabled); | |
| 2263 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); | |
| 2264 this->stampRectUsingProgram(fPLSSetupProgram.fProgram, | |
| 2265 SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f, 0. 01f), | |
| 2266 fPLSSetupProgram.fPosXformUniform, | |
| 2267 fPLSSetupProgram.fArrayBuffer); | |
| 2268 GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); | |
| 2269 if (kYes_TriState == fHWScissorSettings.fEnabled) { | |
| 2270 GL_CALL(Enable(GR_GL_SCISSOR_TEST)); | |
| 2271 } | |
| 2272 } | |
| 2273 } | |
| 2274 | |
| 2148 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { | 2275 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { |
| 2149 | |
| 2150 SkASSERT(target); | 2276 SkASSERT(target); |
| 2151 | 2277 |
| 2152 uint32_t rtID = target->getUniqueID(); | 2278 uint32_t rtID = target->getUniqueID(); |
| 2153 if (fHWBoundRenderTargetUniqueID != rtID) { | 2279 if (fHWBoundRenderTargetUniqueID != rtID) { |
| 2154 fStats.incRenderTargetBinds(); | 2280 fStats.incRenderTargetBinds(); |
| 2155 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 2281 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
| 2156 #ifdef SK_DEBUG | 2282 #ifdef SK_DEBUG |
| 2157 // don't do this check in Chromium -- this is causing | 2283 // don't do this check in Chromium -- this is causing |
| 2158 // lots of repeated command buffer flushes when the compositor is | 2284 // lots of repeated command buffer flushes when the compositor is |
| 2159 // rendering with Ganesh, which is really slow; even too slow for | 2285 // rendering with Ganesh, which is really slow; even too slow for |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2222 } | 2348 } |
| 2223 } | 2349 } |
| 2224 #endif | 2350 #endif |
| 2225 #endif | 2351 #endif |
| 2226 | 2352 |
| 2227 void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice s) { | 2353 void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice s) { |
| 2228 if (!this->flushGLState(args)) { | 2354 if (!this->flushGLState(args)) { |
| 2229 return; | 2355 return; |
| 2230 } | 2356 } |
| 2231 | 2357 |
| 2358 GrPixelLocalStorageState plsState = args.fPrimitiveProcessor->getPixelLocalS torageState(); | |
| 2359 if (!fHWPLSEnabled && plsState != | |
| 2360 GrPixelLocalStorageState::kDisabled_GrPixelLocalStorageState) { | |
| 2361 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); | |
| 2362 this->setupPixelLocalStorage(args); | |
| 2363 fHWPLSEnabled = true; | |
| 2364 } | |
| 2365 if (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState) { | |
| 2366 GrStencilSettings stencil; | |
| 2367 stencil.setDisabled(); | |
| 2368 this->flushStencil(stencil); | |
| 2369 } | |
| 2370 | |
| 2232 size_t indexOffsetInBytes = 0; | 2371 size_t indexOffsetInBytes = 0; |
| 2233 this->setupGeometry(*args.fPrimitiveProcessor, vertices, &indexOffsetInBytes ); | 2372 this->setupGeometry(*args.fPrimitiveProcessor, vertices, &indexOffsetInBytes ); |
| 2234 | 2373 |
| 2235 SkASSERT((size_t)vertices.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GL Mode)); | 2374 SkASSERT((size_t)vertices.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GL Mode)); |
| 2236 | 2375 |
| 2237 if (vertices.isIndexed()) { | 2376 if (vertices.isIndexed()) { |
| 2238 GrGLvoid* indices = | 2377 GrGLvoid* indices = |
| 2239 reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) * | 2378 reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) * |
| 2240 vertices.startIndex()); | 2379 vertices.startIndex()); |
| 2241 // info.startVertex() was accounted for by setupGeometry. | 2380 // info.startVertex() was accounted for by setupGeometry. |
| 2242 GL_CALL(DrawElements(gPrimitiveType2GLMode[vertices.primitiveType()], | 2381 GL_CALL(DrawElements(gPrimitiveType2GLMode[vertices.primitiveType()], |
| 2243 vertices.indexCount(), | 2382 vertices.indexCount(), |
| 2244 GR_GL_UNSIGNED_SHORT, | 2383 GR_GL_UNSIGNED_SHORT, |
| 2245 indices)); | 2384 indices)); |
| 2246 } else { | 2385 } else { |
| 2247 // Pass 0 for parameter first. We have to adjust glVertexAttribPointer() to account for | 2386 // Pass 0 for parameter first. We have to adjust glVertexAttribPointer() to account for |
| 2248 // startVertex in the DrawElements case. So we always rely on setupGeome try to have | 2387 // startVertex in the DrawElements case. So we always rely on setupGeome try to have |
| 2249 // accounted for startVertex. | 2388 // accounted for startVertex. |
| 2250 GL_CALL(DrawArrays(gPrimitiveType2GLMode[vertices.primitiveType()], 0, | 2389 GL_CALL(DrawArrays(gPrimitiveType2GLMode[vertices.primitiveType()], 0, |
| 2251 vertices.vertexCount())); | 2390 vertices.vertexCount())); |
| 2252 } | 2391 } |
| 2392 | |
| 2393 if (fHWPLSEnabled && plsState == GrPixelLocalStorageState::kFinish_GrPixelLo calStorageState) { | |
| 2394 // PLS draws always involve multiple draws, finishing up with a non-PLS | |
| 2395 // draw that writes to the color buffer. That draw ends up here; we wait | |
| 2396 // until after it is complete to actually disable PLS. | |
| 2397 GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); | |
| 2398 fHWPLSEnabled = false; | |
| 2399 this->disableScissor(); | |
| 2400 } | |
| 2401 | |
| 2253 #if SWAP_PER_DRAW | 2402 #if SWAP_PER_DRAW |
| 2254 glFlush(); | 2403 glFlush(); |
| 2255 #if defined(SK_BUILD_FOR_MAC) | 2404 #if defined(SK_BUILD_FOR_MAC) |
| 2256 aglSwapBuffers(aglGetCurrentContext()); | 2405 aglSwapBuffers(aglGetCurrentContext()); |
| 2257 int set_a_break_pt_here = 9; | 2406 int set_a_break_pt_here = 9; |
| 2258 aglSwapBuffers(aglGetCurrentContext()); | 2407 aglSwapBuffers(aglGetCurrentContext()); |
| 2259 #elif defined(SK_BUILD_FOR_WIN32) | 2408 #elif defined(SK_BUILD_FOR_WIN32) |
| 2260 SwapBuf(); | 2409 SwapBuf(); |
| 2261 int set_a_break_pt_here = 9; | 2410 int set_a_break_pt_here = 9; |
| 2262 SwapBuf(); | 2411 SwapBuf(); |
| 2263 #endif | 2412 #endif |
| 2264 #endif | 2413 #endif |
| 2265 } | 2414 } |
| 2266 | 2415 |
| 2416 void GrGLGpu::stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGL int posXformUniform, | |
| 2417 GrGLuint arrayBuffer) { | |
| 2418 GL_CALL(UseProgram(program)); | |
| 2419 this->fHWGeometryState.setVertexArrayID(this, 0); | |
| 2420 | |
| 2421 GrGLAttribArrayState* attribs = | |
| 2422 this->fHWGeometryState.bindArrayAndBufferToDraw(this, arrayBuffer); | |
| 2423 attribs->set(this, 0, arrayBuffer, 2, GR_GL_FLOAT, false, 2 * sizeof(GrGLflo at), 0); | |
| 2424 attribs->disableUnusedArrays(this, 0x1); | |
| 2425 | |
| 2426 GL_CALL(Uniform4f(posXformUniform, bounds.width(), bounds.height(), bounds.l eft(), | |
| 2427 bounds.top())); | |
| 2428 | |
| 2429 GrXferProcessor::BlendInfo blendInfo; | |
| 2430 blendInfo.reset(); | |
| 2431 this->flushBlend(blendInfo, GrSwizzle()); | |
| 2432 this->flushColorWrite(true); | |
| 2433 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | |
| 2434 if (!fHWStencilSettings.isDisabled()) { | |
| 2435 GL_CALL(Disable(GR_GL_STENCIL_TEST)); | |
| 2436 } | |
| 2437 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); | |
| 2438 GL_CALL(UseProgram(fHWProgramID)); | |
| 2439 if (!fHWStencilSettings.isDisabled()) { | |
| 2440 GL_CALL(Enable(GR_GL_STENCIL_TEST)); | |
| 2441 } | |
| 2442 } | |
| 2443 | |
| 2444 void GrGLGpu::setupPixelLocalStorage(const DrawArgs& args) { | |
| 2445 const SkRect& bounds = | |
| 2446 static_cast<const GrPLSGeometryProcessor*>(args.fPrimitiveProcessor) ->getBounds(); | |
| 2447 // setup pixel local storage -- this means capturing and storing the current framebuffer color | |
| 2448 // and initializing the winding counts to zero | |
| 2449 GrRenderTarget* rt = args.fPipeline->getRenderTarget(); | |
| 2450 SkScalar width = rt->width(); | |
| 2451 SkScalar height = rt->height(); | |
| 2452 // dst rect edges in NDC (-1 to 1) | |
| 2453 // having some issues with rounding, just expand the bounds by 1 and trust t he scissor to keep | |
| 2454 // it contained properly | |
| 2455 GrGLfloat dx0 = 2.0f * (bounds.left() - 1) / width - 1.0f; | |
| 2456 GrGLfloat dx1 = 2.0f * (bounds.right() + 1) / width - 1.0f; | |
| 2457 GrGLfloat dy0 = -2.0f * (bounds.top() - 1) / height + 1.0f; | |
| 2458 GrGLfloat dy1 = -2.0f * (bounds.bottom() + 1) / height + 1.0f; | |
| 2459 SkRect deviceBounds = SkRect::MakeXYWH(dx0, dy0, dx1 - dx0, dy1 - dy0); | |
| 2460 | |
| 2461 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM)); | |
| 2462 this->stampRectUsingProgram(fPLSSetupProgram.fProgram, deviceBounds, | |
| 2463 fPLSSetupProgram.fPosXformUniform, fPLSSetupProg ram.fArrayBuffer); | |
| 2464 } | |
| 2465 | |
| 2267 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { | 2466 void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { |
| 2268 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); | 2467 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); |
| 2269 if (rt->needsResolve()) { | 2468 if (rt->needsResolve()) { |
| 2270 // Some extensions automatically resolves the texture when it is read. | 2469 // Some extensions automatically resolves the texture when it is read. |
| 2271 if (this->glCaps().usesMSAARenderBuffers()) { | 2470 if (this->glCaps().usesMSAARenderBuffers()) { |
| 2272 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); | 2471 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); |
| 2273 fStats.incRenderTargetBinds(); | 2472 fStats.incRenderTargetBinds(); |
| 2274 fStats.incRenderTargetBinds(); | 2473 fStats.incRenderTargetBinds(); |
| 2275 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); | 2474 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); |
| 2276 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ; | 2475 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ; |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3500 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 3699 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
| 3501 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 3700 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
| 3502 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 3701 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
| 3503 copyParams->fWidth = texture->width(); | 3702 copyParams->fWidth = texture->width(); |
| 3504 copyParams->fHeight = texture->height(); | 3703 copyParams->fHeight = texture->height(); |
| 3505 return true; | 3704 return true; |
| 3506 } | 3705 } |
| 3507 } | 3706 } |
| 3508 return false; | 3707 return false; |
| 3509 } | 3708 } |
| OLD | NEW |