| 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 "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
| 10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 this->notifyIndexBufferDelete(desc.fID); | 1352 this->notifyIndexBufferDelete(desc.fID); |
| 1353 return NULL; | 1353 return NULL; |
| 1354 } | 1354 } |
| 1355 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc
)); | 1355 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc
)); |
| 1356 return indexBuffer; | 1356 return indexBuffer; |
| 1357 } | 1357 } |
| 1358 return NULL; | 1358 return NULL; |
| 1359 } | 1359 } |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 void GrGpuGL::flushScissor(const ScissorState& scissorState, | 1362 void GrGpuGL::flushScissor(const GrClipMaskManager::ScissorState& scissorState, |
| 1363 const GrGLIRect& rtViewport, | 1363 const GrGLIRect& rtViewport, |
| 1364 GrSurfaceOrigin rtOrigin) { | 1364 GrSurfaceOrigin rtOrigin) { |
| 1365 if (scissorState.fEnabled) { | 1365 if (scissorState.fEnabled) { |
| 1366 GrGLIRect scissor; | 1366 GrGLIRect scissor; |
| 1367 scissor.setRelativeTo(rtViewport, | 1367 scissor.setRelativeTo(rtViewport, |
| 1368 scissorState.fRect.fLeft, | 1368 scissorState.fRect.fLeft, |
| 1369 scissorState.fRect.fTop, | 1369 scissorState.fRect.fTop, |
| 1370 scissorState.fRect.width(), | 1370 scissorState.fRect.width(), |
| 1371 scissorState.fRect.height(), | 1371 scissorState.fRect.height(), |
| 1372 rtOrigin); | 1372 rtOrigin); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 clippedRect = *rect; | 1413 clippedRect = *rect; |
| 1414 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height()); | 1414 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height()); |
| 1415 if (clippedRect.intersect(rtRect)) { | 1415 if (clippedRect.intersect(rtRect)) { |
| 1416 rect = &clippedRect; | 1416 rect = &clippedRect; |
| 1417 } else { | 1417 } else { |
| 1418 return; | 1418 return; |
| 1419 } | 1419 } |
| 1420 } | 1420 } |
| 1421 | 1421 |
| 1422 this->flushRenderTarget(glRT, rect); | 1422 this->flushRenderTarget(glRT, rect); |
| 1423 ScissorState scissorState; | 1423 GrClipMaskManager::ScissorState scissorState; |
| 1424 scissorState.fEnabled = SkToBool(rect); | 1424 scissorState.fEnabled = SkToBool(rect); |
| 1425 if (scissorState.fEnabled) { | 1425 if (scissorState.fEnabled) { |
| 1426 scissorState.fRect = *rect; | 1426 scissorState.fRect = *rect; |
| 1427 } | 1427 } |
| 1428 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); | 1428 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); |
| 1429 | 1429 |
| 1430 GrGLfloat r, g, b, a; | 1430 GrGLfloat r, g, b, a; |
| 1431 static const GrGLfloat scale255 = 1.f / 255.f; | 1431 static const GrGLfloat scale255 = 1.f / 255.f; |
| 1432 a = GrColorUnpackA(color) * scale255; | 1432 a = GrColorUnpackA(color) * scale255; |
| 1433 GrGLfloat scaleRGB = scale255; | 1433 GrGLfloat scaleRGB = scale255; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); | 1504 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); |
| 1505 | 1505 |
| 1506 this->disableScissor(); | 1506 this->disableScissor(); |
| 1507 | 1507 |
| 1508 GL_CALL(StencilMask(0xffffffff)); | 1508 GL_CALL(StencilMask(0xffffffff)); |
| 1509 GL_CALL(ClearStencil(0)); | 1509 GL_CALL(ClearStencil(0)); |
| 1510 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); | 1510 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); |
| 1511 fHWStencilSettings.invalidate(); | 1511 fHWStencilSettings.invalidate(); |
| 1512 } | 1512 } |
| 1513 | 1513 |
| 1514 void GrGpuGL::clearStencilClip(GrRenderTarget* target, const SkIRect& rect, bool
insideClip) { | 1514 void GrGpuGL::onClearStencilClip(GrRenderTarget* target, const SkIRect& rect, bo
ol insideClip) { |
| 1515 SkASSERT(target); | 1515 SkASSERT(target); |
| 1516 | 1516 |
| 1517 // this should only be called internally when we know we have a | 1517 // this should only be called internally when we know we have a |
| 1518 // stencil buffer. | 1518 // stencil buffer. |
| 1519 SkASSERT(target->getStencilBuffer()); | 1519 SkASSERT(target->getStencilBuffer()); |
| 1520 GrGLint stencilBitCount = target->getStencilBuffer()->bits(); | 1520 GrGLint stencilBitCount = target->getStencilBuffer()->bits(); |
| 1521 #if 0 | 1521 #if 0 |
| 1522 SkASSERT(stencilBitCount > 0); | 1522 SkASSERT(stencilBitCount > 0); |
| 1523 GrGLint clipStencilMask = (1 << (stencilBitCount - 1)); | 1523 GrGLint clipStencilMask = (1 << (stencilBitCount - 1)); |
| 1524 #else | 1524 #else |
| 1525 // we could just clear the clip bit but when we go through | 1525 // we could just clear the clip bit but when we go through |
| 1526 // ANGLE a partial stencil mask will cause clears to be | 1526 // ANGLE a partial stencil mask will cause clears to be |
| 1527 // turned into draws. Our contract on GrDrawTarget says that | 1527 // turned into draws. Our contract on GrDrawTarget says that |
| 1528 // changing the clip between stencil passes may or may not | 1528 // changing the clip between stencil passes may or may not |
| 1529 // zero the client's clip bits. So we just clear the whole thing. | 1529 // zero the client's clip bits. So we just clear the whole thing. |
| 1530 static const GrGLint clipStencilMask = ~0; | 1530 static const GrGLint clipStencilMask = ~0; |
| 1531 #endif | 1531 #endif |
| 1532 GrGLint value; | 1532 GrGLint value; |
| 1533 if (insideClip) { | 1533 if (insideClip) { |
| 1534 value = (1 << (stencilBitCount - 1)); | 1534 value = (1 << (stencilBitCount - 1)); |
| 1535 } else { | 1535 } else { |
| 1536 value = 0; | 1536 value = 0; |
| 1537 } | 1537 } |
| 1538 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); | 1538 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); |
| 1539 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); | 1539 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); |
| 1540 | 1540 |
| 1541 ScissorState scissorState; | 1541 GrClipMaskManager::ScissorState scissorState; |
| 1542 scissorState.fEnabled = true; | 1542 scissorState.fEnabled = true; |
| 1543 scissorState.fRect = rect; | 1543 scissorState.fRect = rect; |
| 1544 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); | 1544 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); |
| 1545 | 1545 |
| 1546 GL_CALL(StencilMask((uint32_t) clipStencilMask)); | 1546 GL_CALL(StencilMask((uint32_t) clipStencilMask)); |
| 1547 GL_CALL(ClearStencil(value)); | 1547 GL_CALL(ClearStencil(value)); |
| 1548 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); | 1548 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); |
| 1549 fHWStencilSettings.invalidate(); | 1549 fHWStencilSettings.invalidate(); |
| 1550 } | 1550 } |
| 1551 | 1551 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 // the bound DRAW FBO ID. | 1826 // the bound DRAW FBO ID. |
| 1827 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 1827 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
| 1828 const GrGLIRect& vp = rt->getViewport(); | 1828 const GrGLIRect& vp = rt->getViewport(); |
| 1829 const SkIRect dirtyRect = rt->getResolveRect(); | 1829 const SkIRect dirtyRect = rt->getResolveRect(); |
| 1830 GrGLIRect r; | 1830 GrGLIRect r; |
| 1831 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, | 1831 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, |
| 1832 dirtyRect.width(), dirtyRect.height(), target->origi
n()); | 1832 dirtyRect.width(), dirtyRect.height(), target->origi
n()); |
| 1833 | 1833 |
| 1834 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { | 1834 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { |
| 1835 // Apple's extension uses the scissor as the blit bounds. | 1835 // Apple's extension uses the scissor as the blit bounds. |
| 1836 ScissorState scissorState; | 1836 GrClipMaskManager::ScissorState scissorState; |
| 1837 scissorState.fEnabled = true; | 1837 scissorState.fEnabled = true; |
| 1838 scissorState.fRect = dirtyRect; | 1838 scissorState.fRect = dirtyRect; |
| 1839 this->flushScissor(scissorState, rt->getViewport(), rt->origin()
); | 1839 this->flushScissor(scissorState, rt->getViewport(), rt->origin()
); |
| 1840 GL_CALL(ResolveMultisampleFramebuffer()); | 1840 GL_CALL(ResolveMultisampleFramebuffer()); |
| 1841 } else { | 1841 } else { |
| 1842 int right = r.fLeft + r.fWidth; | 1842 int right = r.fLeft + r.fWidth; |
| 1843 int top = r.fBottom + r.fHeight; | 1843 int top = r.fBottom + r.fHeight; |
| 1844 | 1844 |
| 1845 // BlitFrameBuffer respects the scissor, so disable it. | 1845 // BlitFrameBuffer respects the scissor, so disable it. |
| 1846 this->disableScissor(); | 1846 this->disableScissor(); |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2610 this->setVertexArrayID(gpu, 0); | 2610 this->setVertexArrayID(gpu, 0); |
| 2611 } | 2611 } |
| 2612 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2612 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2613 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2613 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2614 fDefaultVertexArrayAttribState.resize(attrCount); | 2614 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2615 } | 2615 } |
| 2616 attribState = &fDefaultVertexArrayAttribState; | 2616 attribState = &fDefaultVertexArrayAttribState; |
| 2617 } | 2617 } |
| 2618 return attribState; | 2618 return attribState; |
| 2619 } | 2619 } |
| OLD | NEW |