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 (fPLSHasBeenUsed) { |
| 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. And since we use it every frame, there's nev
er a point at which |
| 2258 * it becomes safe to stop using this workaround once we start. |
| 2259 */ |
| 2260 this->disableScissor(); |
| 2261 // using PLS in the presence of MSAA results in GL_INVALID_OPERATION |
| 2262 this->flushHWAAState(nullptr, false); |
| 2263 SkASSERT(!fHWPLSEnabled); |
| 2264 SkASSERT(fMSAAEnabled != kYes_TriState); |
| 2265 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| 2266 this->stampRectUsingProgram(fPLSSetupProgram.fProgram, |
| 2267 SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f, 0.
01f), |
| 2268 fPLSSetupProgram.fPosXformUniform, |
| 2269 fPLSSetupProgram.fArrayBuffer); |
| 2270 GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| 2271 } |
| 2272 } |
| 2273 |
2148 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ | 2274 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ |
2149 | |
2150 SkASSERT(target); | 2275 SkASSERT(target); |
2151 | 2276 |
2152 uint32_t rtID = target->getUniqueID(); | 2277 uint32_t rtID = target->getUniqueID(); |
2153 if (fHWBoundRenderTargetUniqueID != rtID) { | 2278 if (fHWBoundRenderTargetUniqueID != rtID) { |
2154 fStats.incRenderTargetBinds(); | 2279 fStats.incRenderTargetBinds(); |
2155 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 2280 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
2156 #ifdef SK_DEBUG | 2281 #ifdef SK_DEBUG |
2157 // don't do this check in Chromium -- this is causing | 2282 // don't do this check in Chromium -- this is causing |
2158 // lots of repeated command buffer flushes when the compositor is | 2283 // lots of repeated command buffer flushes when the compositor is |
2159 // rendering with Ganesh, which is really slow; even too slow for | 2284 // 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 } | 2347 } |
2223 } | 2348 } |
2224 #endif | 2349 #endif |
2225 #endif | 2350 #endif |
2226 | 2351 |
2227 void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice
s) { | 2352 void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice
s) { |
2228 if (!this->flushGLState(args)) { | 2353 if (!this->flushGLState(args)) { |
2229 return; | 2354 return; |
2230 } | 2355 } |
2231 | 2356 |
| 2357 GrPixelLocalStorageState plsState = args.fPrimitiveProcessor->getPixelLocalS
torageState(); |
| 2358 if (!fHWPLSEnabled && plsState != |
| 2359 GrPixelLocalStorageState::kDisabled_GrPixelLocalStorageState) { |
| 2360 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| 2361 this->setupPixelLocalStorage(args); |
| 2362 fHWPLSEnabled = true; |
| 2363 } |
| 2364 if (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState)
{ |
| 2365 GrStencilSettings stencil; |
| 2366 stencil.setDisabled(); |
| 2367 this->flushStencil(stencil); |
| 2368 } |
| 2369 |
2232 size_t indexOffsetInBytes = 0; | 2370 size_t indexOffsetInBytes = 0; |
2233 this->setupGeometry(*args.fPrimitiveProcessor, vertices, &indexOffsetInBytes
); | 2371 this->setupGeometry(*args.fPrimitiveProcessor, vertices, &indexOffsetInBytes
); |
2234 | 2372 |
2235 SkASSERT((size_t)vertices.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GL
Mode)); | 2373 SkASSERT((size_t)vertices.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GL
Mode)); |
2236 | 2374 |
2237 if (vertices.isIndexed()) { | 2375 if (vertices.isIndexed()) { |
2238 GrGLvoid* indices = | 2376 GrGLvoid* indices = |
2239 reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) * | 2377 reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) * |
2240 vertices.startIndex()); | 2378 vertices.startIndex()); |
2241 // info.startVertex() was accounted for by setupGeometry. | 2379 // info.startVertex() was accounted for by setupGeometry. |
2242 GL_CALL(DrawElements(gPrimitiveType2GLMode[vertices.primitiveType()], | 2380 GL_CALL(DrawElements(gPrimitiveType2GLMode[vertices.primitiveType()], |
2243 vertices.indexCount(), | 2381 vertices.indexCount(), |
2244 GR_GL_UNSIGNED_SHORT, | 2382 GR_GL_UNSIGNED_SHORT, |
2245 indices)); | 2383 indices)); |
2246 } else { | 2384 } else { |
2247 // Pass 0 for parameter first. We have to adjust glVertexAttribPointer()
to account for | 2385 // 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 | 2386 // startVertex in the DrawElements case. So we always rely on setupGeome
try to have |
2249 // accounted for startVertex. | 2387 // accounted for startVertex. |
2250 GL_CALL(DrawArrays(gPrimitiveType2GLMode[vertices.primitiveType()], 0, | 2388 GL_CALL(DrawArrays(gPrimitiveType2GLMode[vertices.primitiveType()], 0, |
2251 vertices.vertexCount())); | 2389 vertices.vertexCount())); |
2252 } | 2390 } |
| 2391 |
| 2392 if (fHWPLSEnabled && plsState == GrPixelLocalStorageState::kFinish_GrPixelLo
calStorageState) { |
| 2393 // PLS draws always involve multiple draws, finishing up with a non-PLS |
| 2394 // draw that writes to the color buffer. That draw ends up here; we wait |
| 2395 // until after it is complete to actually disable PLS. |
| 2396 GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| 2397 fHWPLSEnabled = false; |
| 2398 this->disableScissor(); |
| 2399 } |
| 2400 |
2253 #if SWAP_PER_DRAW | 2401 #if SWAP_PER_DRAW |
2254 glFlush(); | 2402 glFlush(); |
2255 #if defined(SK_BUILD_FOR_MAC) | 2403 #if defined(SK_BUILD_FOR_MAC) |
2256 aglSwapBuffers(aglGetCurrentContext()); | 2404 aglSwapBuffers(aglGetCurrentContext()); |
2257 int set_a_break_pt_here = 9; | 2405 int set_a_break_pt_here = 9; |
2258 aglSwapBuffers(aglGetCurrentContext()); | 2406 aglSwapBuffers(aglGetCurrentContext()); |
2259 #elif defined(SK_BUILD_FOR_WIN32) | 2407 #elif defined(SK_BUILD_FOR_WIN32) |
2260 SwapBuf(); | 2408 SwapBuf(); |
2261 int set_a_break_pt_here = 9; | 2409 int set_a_break_pt_here = 9; |
2262 SwapBuf(); | 2410 SwapBuf(); |
2263 #endif | 2411 #endif |
2264 #endif | 2412 #endif |
2265 } | 2413 } |
2266 | 2414 |
| 2415 void GrGLGpu::stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGL
int posXformUniform, |
| 2416 GrGLuint arrayBuffer) { |
| 2417 GL_CALL(UseProgram(program)); |
| 2418 this->fHWGeometryState.setVertexArrayID(this, 0); |
| 2419 |
| 2420 GrGLAttribArrayState* attribs = |
| 2421 this->fHWGeometryState.bindArrayAndBufferToDraw(this, arrayBuffer); |
| 2422 attribs->set(this, 0, arrayBuffer, 2, GR_GL_FLOAT, false, 2 * sizeof(GrGLflo
at), 0); |
| 2423 attribs->disableUnusedArrays(this, 0x1); |
| 2424 |
| 2425 GL_CALL(Uniform4f(posXformUniform, bounds.width(), bounds.height(), bounds.l
eft(), |
| 2426 bounds.top())); |
| 2427 |
| 2428 GrXferProcessor::BlendInfo blendInfo; |
| 2429 blendInfo.reset(); |
| 2430 this->flushBlend(blendInfo, GrSwizzle()); |
| 2431 this->flushColorWrite(true); |
| 2432 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
| 2433 if (!fHWStencilSettings.isDisabled()) { |
| 2434 GL_CALL(Disable(GR_GL_STENCIL_TEST)); |
| 2435 } |
| 2436 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); |
| 2437 GL_CALL(UseProgram(fHWProgramID)); |
| 2438 if (!fHWStencilSettings.isDisabled()) { |
| 2439 GL_CALL(Enable(GR_GL_STENCIL_TEST)); |
| 2440 } |
| 2441 } |
| 2442 |
| 2443 void GrGLGpu::setupPixelLocalStorage(const DrawArgs& args) { |
| 2444 fPLSHasBeenUsed = true; |
| 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 = SkIntToScalar(rt->width()); |
| 2451 SkScalar height = SkIntToScalar(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 |