| 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 "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
| (...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc
)); | 1320 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc
)); |
| 1321 return indexBuffer; | 1321 return indexBuffer; |
| 1322 } | 1322 } |
| 1323 return NULL; | 1323 return NULL; |
| 1324 } | 1324 } |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 void GrGLGpu::flushScissor(const GrScissorState& scissorState, | 1327 void GrGLGpu::flushScissor(const GrScissorState& scissorState, |
| 1328 const GrGLIRect& rtViewport, | 1328 const GrGLIRect& rtViewport, |
| 1329 GrSurfaceOrigin rtOrigin) { | 1329 GrSurfaceOrigin rtOrigin) { |
| 1330 if (scissorState.fEnabled) { | 1330 if (scissorState.enabled()) { |
| 1331 GrGLIRect scissor; | 1331 GrGLIRect scissor; |
| 1332 scissor.setRelativeTo(rtViewport, | 1332 scissor.setRelativeTo(rtViewport, |
| 1333 scissorState.fRect.fLeft, | 1333 scissorState.rect().fLeft, |
| 1334 scissorState.fRect.fTop, | 1334 scissorState.rect().fTop, |
| 1335 scissorState.fRect.width(), | 1335 scissorState.rect().width(), |
| 1336 scissorState.fRect.height(), | 1336 scissorState.rect().height(), |
| 1337 rtOrigin); | 1337 rtOrigin); |
| 1338 // if the scissor fully contains the viewport then we fall through and | 1338 // if the scissor fully contains the viewport then we fall through and |
| 1339 // disable the scissor test. | 1339 // disable the scissor test. |
| 1340 if (!scissor.contains(rtViewport)) { | 1340 if (!scissor.contains(rtViewport)) { |
| 1341 if (fHWScissorSettings.fRect != scissor) { | 1341 if (fHWScissorSettings.fRect != scissor) { |
| 1342 scissor.pushToGLScissor(this->glInterface()); | 1342 scissor.pushToGLScissor(this->glInterface()); |
| 1343 fHWScissorSettings.fRect = scissor; | 1343 fHWScissorSettings.fRect = scissor; |
| 1344 } | 1344 } |
| 1345 if (kYes_TriState != fHWScissorSettings.fEnabled) { | 1345 if (kYes_TriState != fHWScissorSettings.fEnabled) { |
| 1346 GL_CALL(Enable(GR_GL_SCISSOR_TEST)); | 1346 GL_CALL(Enable(GR_GL_SCISSOR_TEST)); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height()); | 1482 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height()); |
| 1483 if (clippedRect.intersect(rtRect)) { | 1483 if (clippedRect.intersect(rtRect)) { |
| 1484 rect = &clippedRect; | 1484 rect = &clippedRect; |
| 1485 } else { | 1485 } else { |
| 1486 return; | 1486 return; |
| 1487 } | 1487 } |
| 1488 } | 1488 } |
| 1489 | 1489 |
| 1490 this->flushRenderTarget(glRT, rect); | 1490 this->flushRenderTarget(glRT, rect); |
| 1491 GrScissorState scissorState; | 1491 GrScissorState scissorState; |
| 1492 scissorState.fEnabled = SkToBool(rect); | 1492 if (rect) { |
| 1493 if (scissorState.fEnabled) { | 1493 scissorState.set(*rect); |
| 1494 scissorState.fRect = *rect; | |
| 1495 } | 1494 } |
| 1496 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); | 1495 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); |
| 1497 | 1496 |
| 1498 GrGLfloat r, g, b, a; | 1497 GrGLfloat r, g, b, a; |
| 1499 static const GrGLfloat scale255 = 1.f / 255.f; | 1498 static const GrGLfloat scale255 = 1.f / 255.f; |
| 1500 a = GrColorUnpackA(color) * scale255; | 1499 a = GrColorUnpackA(color) * scale255; |
| 1501 GrGLfloat scaleRGB = scale255; | 1500 GrGLfloat scaleRGB = scale255; |
| 1502 r = GrColorUnpackR(color) * scaleRGB; | 1501 r = GrColorUnpackR(color) * scaleRGB; |
| 1503 g = GrColorUnpackG(color) * scaleRGB; | 1502 g = GrColorUnpackG(color) * scaleRGB; |
| 1504 b = GrColorUnpackB(color) * scaleRGB; | 1503 b = GrColorUnpackB(color) * scaleRGB; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 GrGLint value; | 1594 GrGLint value; |
| 1596 if (insideClip) { | 1595 if (insideClip) { |
| 1597 value = (1 << (stencilBitCount - 1)); | 1596 value = (1 << (stencilBitCount - 1)); |
| 1598 } else { | 1597 } else { |
| 1599 value = 0; | 1598 value = 0; |
| 1600 } | 1599 } |
| 1601 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); | 1600 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); |
| 1602 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); | 1601 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); |
| 1603 | 1602 |
| 1604 GrScissorState scissorState; | 1603 GrScissorState scissorState; |
| 1605 scissorState.fEnabled = true; | 1604 scissorState.set(rect); |
| 1606 scissorState.fRect = rect; | |
| 1607 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); | 1605 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); |
| 1608 | 1606 |
| 1609 GL_CALL(StencilMask((uint32_t) clipStencilMask)); | 1607 GL_CALL(StencilMask((uint32_t) clipStencilMask)); |
| 1610 GL_CALL(ClearStencil(value)); | 1608 GL_CALL(ClearStencil(value)); |
| 1611 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); | 1609 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); |
| 1612 fHWStencilSettings.invalidate(); | 1610 fHWStencilSettings.invalidate(); |
| 1613 } | 1611 } |
| 1614 | 1612 |
| 1615 bool GrGLGpu::readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, | 1613 bool GrGLGpu::readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, |
| 1616 int left, int top, | 1614 int left, int top, |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1923 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); | 1921 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); |
| 1924 fStats.incRenderTargetBinds(); | 1922 fStats.incRenderTargetBinds(); |
| 1925 fStats.incRenderTargetBinds(); | 1923 fStats.incRenderTargetBinds(); |
| 1926 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); | 1924 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); |
| 1927 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()))
; | 1925 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()))
; |
| 1928 // make sure we go through flushRenderTarget() since we've modified | 1926 // make sure we go through flushRenderTarget() since we've modified |
| 1929 // the bound DRAW FBO ID. | 1927 // the bound DRAW FBO ID. |
| 1930 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 1928 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
| 1931 const GrGLIRect& vp = rt->getViewport(); | 1929 const GrGLIRect& vp = rt->getViewport(); |
| 1932 const SkIRect dirtyRect = rt->getResolveRect(); | 1930 const SkIRect dirtyRect = rt->getResolveRect(); |
| 1933 GrGLIRect r; | |
| 1934 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, | |
| 1935 dirtyRect.width(), dirtyRect.height(), target->origi
n()); | |
| 1936 | 1931 |
| 1937 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { | 1932 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { |
| 1938 // Apple's extension uses the scissor as the blit bounds. | 1933 // Apple's extension uses the scissor as the blit bounds. |
| 1939 GrScissorState scissorState; | 1934 GrScissorState scissorState; |
| 1940 scissorState.fEnabled = true; | 1935 scissorState.set(dirtyRect); |
| 1941 scissorState.fRect = dirtyRect; | 1936 this->flushScissor(scissorState, vp, rt->origin()); |
| 1942 this->flushScissor(scissorState, rt->getViewport(), rt->origin()
); | |
| 1943 GL_CALL(ResolveMultisampleFramebuffer()); | 1937 GL_CALL(ResolveMultisampleFramebuffer()); |
| 1944 } else { | 1938 } else { |
| 1939 GrGLIRect r; |
| 1940 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, |
| 1941 dirtyRect.width(), dirtyRect.height(), target->o
rigin()); |
| 1942 |
| 1945 int right = r.fLeft + r.fWidth; | 1943 int right = r.fLeft + r.fWidth; |
| 1946 int top = r.fBottom + r.fHeight; | 1944 int top = r.fBottom + r.fHeight; |
| 1947 | 1945 |
| 1948 // BlitFrameBuffer respects the scissor, so disable it. | 1946 // BlitFrameBuffer respects the scissor, so disable it. |
| 1949 this->disableScissor(); | 1947 this->disableScissor(); |
| 1950 GL_CALL(BlitFramebuffer(r.fLeft, r.fBottom, right, top, | 1948 GL_CALL(BlitFramebuffer(r.fLeft, r.fBottom, right, top, |
| 1951 r.fLeft, r.fBottom, right, top, | 1949 r.fLeft, r.fBottom, right, top, |
| 1952 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); | 1950 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); |
| 1953 } | 1951 } |
| 1954 } | 1952 } |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2765 this->setVertexArrayID(gpu, 0); | 2763 this->setVertexArrayID(gpu, 0); |
| 2766 } | 2764 } |
| 2767 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2765 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2768 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2766 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2769 fDefaultVertexArrayAttribState.resize(attrCount); | 2767 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2770 } | 2768 } |
| 2771 attribState = &fDefaultVertexArrayAttribState; | 2769 attribState = &fDefaultVertexArrayAttribState; |
| 2772 } | 2770 } |
| 2773 return attribState; | 2771 return attribState; |
| 2774 } | 2772 } |
| OLD | NEW |