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

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

Issue 678683005: Scissor rect on drawinfo (Closed) Base URL: https://skia.googlesource.com/skia.git@clip_to_target
Patch Set: feedback inc Created 6 years, 1 month 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
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 "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 this->notifyIndexBufferDelete(desc.fID); 1353 this->notifyIndexBufferDelete(desc.fID);
1354 return NULL; 1354 return NULL;
1355 } 1355 }
1356 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc )); 1356 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc ));
1357 return indexBuffer; 1357 return indexBuffer;
1358 } 1358 }
1359 return NULL; 1359 return NULL;
1360 } 1360 }
1361 } 1361 }
1362 1362
1363 void GrGpuGL::flushScissor(const GrGLIRect& rtViewport, GrSurfaceOrigin rtOrigin ) { 1363 void GrGpuGL::flushScissor(const DrawInfo::ScissorState& scissorState,
1364 if (fScissorState.fEnabled) { 1364 const GrGLIRect& rtViewport,
1365 GrSurfaceOrigin rtOrigin) {
1366 if (scissorState.fEnabled) {
1365 GrGLIRect scissor; 1367 GrGLIRect scissor;
1366 scissor.setRelativeTo(rtViewport, 1368 scissor.setRelativeTo(rtViewport,
1367 fScissorState.fRect.fLeft, 1369 scissorState.fRect.fLeft,
1368 fScissorState.fRect.fTop, 1370 scissorState.fRect.fTop,
1369 fScissorState.fRect.width(), 1371 scissorState.fRect.width(),
1370 fScissorState.fRect.height(), 1372 scissorState.fRect.height(),
1371 rtOrigin); 1373 rtOrigin);
1372 // if the scissor fully contains the viewport then we fall through and 1374 // if the scissor fully contains the viewport then we fall through and
1373 // disable the scissor test. 1375 // disable the scissor test.
1374 if (!scissor.contains(rtViewport)) { 1376 if (!scissor.contains(rtViewport)) {
1375 if (fHWScissorSettings.fRect != scissor) { 1377 if (fHWScissorSettings.fRect != scissor) {
1376 scissor.pushToGLScissor(this->glInterface()); 1378 scissor.pushToGLScissor(this->glInterface());
1377 fHWScissorSettings.fRect = scissor; 1379 fHWScissorSettings.fRect = scissor;
1378 } 1380 }
1379 if (kYes_TriState != fHWScissorSettings.fEnabled) { 1381 if (kYes_TriState != fHWScissorSettings.fEnabled) {
1380 GL_CALL(Enable(GR_GL_SCISSOR_TEST)); 1382 GL_CALL(Enable(GR_GL_SCISSOR_TEST));
(...skipping 25 matching lines...) Expand all
1406 clippedRect = *rect; 1408 clippedRect = *rect;
1407 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height()); 1409 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height());
1408 if (clippedRect.intersect(rtRect)) { 1410 if (clippedRect.intersect(rtRect)) {
1409 rect = &clippedRect; 1411 rect = &clippedRect;
1410 } else { 1412 } else {
1411 return; 1413 return;
1412 } 1414 }
1413 } 1415 }
1414 1416
1415 this->flushRenderTarget(glRT, rect); 1417 this->flushRenderTarget(glRT, rect);
1416 GrAutoTRestore<ScissorState> asr(&fScissorState); 1418 DrawInfo::ScissorState scissorState;
1417 fScissorState.fEnabled = SkToBool(rect); 1419 scissorState.fEnabled = SkToBool(rect);
1418 if (fScissorState.fEnabled) { 1420 if (scissorState.fEnabled) {
1419 fScissorState.fRect = *rect; 1421 scissorState.fRect = *rect;
1420 } 1422 }
1421 this->flushScissor(glRT->getViewport(), glRT->origin()); 1423 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
1422 1424
1423 GrGLfloat r, g, b, a; 1425 GrGLfloat r, g, b, a;
1424 static const GrGLfloat scale255 = 1.f / 255.f; 1426 static const GrGLfloat scale255 = 1.f / 255.f;
1425 a = GrColorUnpackA(color) * scale255; 1427 a = GrColorUnpackA(color) * scale255;
1426 GrGLfloat scaleRGB = scale255; 1428 GrGLfloat scaleRGB = scale255;
1427 r = GrColorUnpackR(color) * scaleRGB; 1429 r = GrColorUnpackR(color) * scaleRGB;
1428 g = GrColorUnpackG(color) * scaleRGB; 1430 g = GrColorUnpackG(color) * scaleRGB;
1429 b = GrColorUnpackB(color) * scaleRGB; 1431 b = GrColorUnpackB(color) * scaleRGB;
1430 1432
1431 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); 1433 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 } 1491 }
1490 1492
1491 1493
1492 void GrGpuGL::clearStencil(GrRenderTarget* target) { 1494 void GrGpuGL::clearStencil(GrRenderTarget* target) {
1493 if (NULL == target) { 1495 if (NULL == target) {
1494 return; 1496 return;
1495 } 1497 }
1496 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 1498 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
1497 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); 1499 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
1498 1500
1499 GrAutoTRestore<ScissorState> asr(&fScissorState); 1501 DrawInfo::ScissorState scissorState;
bsalomon 2014/10/27 19:41:24 This seems odd... should we have this->disableScis
1500 fScissorState.fEnabled = false; 1502 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
1501 this->flushScissor(glRT->getViewport(), glRT->origin());
1502 1503
1503 GL_CALL(StencilMask(0xffffffff)); 1504 GL_CALL(StencilMask(0xffffffff));
1504 GL_CALL(ClearStencil(0)); 1505 GL_CALL(ClearStencil(0));
1505 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 1506 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
1506 fHWStencilSettings.invalidate(); 1507 fHWStencilSettings.invalidate();
1507 } 1508 }
1508 1509
1509 void GrGpuGL::clearStencilClip(GrRenderTarget* target, const SkIRect& rect, bool insideClip) { 1510 void GrGpuGL::clearStencilClip(GrRenderTarget* target, const SkIRect& rect, bool insideClip) {
1510 SkASSERT(target); 1511 SkASSERT(target);
1511 1512
(...skipping 14 matching lines...) Expand all
1526 #endif 1527 #endif
1527 GrGLint value; 1528 GrGLint value;
1528 if (insideClip) { 1529 if (insideClip) {
1529 value = (1 << (stencilBitCount - 1)); 1530 value = (1 << (stencilBitCount - 1));
1530 } else { 1531 } else {
1531 value = 0; 1532 value = 0;
1532 } 1533 }
1533 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 1534 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
1534 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); 1535 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
1535 1536
1536 GrAutoTRestore<ScissorState> asr(&fScissorState); 1537 DrawInfo::ScissorState scissorState;
1537 fScissorState.fEnabled = true; 1538 scissorState.fEnabled = true;
1538 fScissorState.fRect = rect; 1539 scissorState.fRect = rect;
1539 this->flushScissor(glRT->getViewport(), glRT->origin()); 1540 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
1540 1541
1541 GL_CALL(StencilMask((uint32_t) clipStencilMask)); 1542 GL_CALL(StencilMask((uint32_t) clipStencilMask));
1542 GL_CALL(ClearStencil(value)); 1543 GL_CALL(ClearStencil(value));
1543 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 1544 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
1544 fHWStencilSettings.invalidate(); 1545 fHWStencilSettings.invalidate();
1545 } 1546 }
1546 1547
1547 bool GrGpuGL::readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, 1548 bool GrGpuGL::readPixelsWillPayForYFlip(GrRenderTarget* renderTarget,
1548 int left, int top, 1549 int left, int top,
1549 int width, int height, 1550 int width, int height,
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ; 1820 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ;
1820 // make sure we go through flushRenderTarget() since we've modified 1821 // make sure we go through flushRenderTarget() since we've modified
1821 // the bound DRAW FBO ID. 1822 // the bound DRAW FBO ID.
1822 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 1823 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1823 const GrGLIRect& vp = rt->getViewport(); 1824 const GrGLIRect& vp = rt->getViewport();
1824 const SkIRect dirtyRect = rt->getResolveRect(); 1825 const SkIRect dirtyRect = rt->getResolveRect();
1825 GrGLIRect r; 1826 GrGLIRect r;
1826 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, 1827 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop,
1827 dirtyRect.width(), dirtyRect.height(), target->origi n()); 1828 dirtyRect.width(), dirtyRect.height(), target->origi n());
1828 1829
1829 GrAutoTRestore<ScissorState> asr;
1830 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { 1830 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) {
1831 // Apple's extension uses the scissor as the blit bounds. 1831 // Apple's extension uses the scissor as the blit bounds.
1832 asr.reset(&fScissorState); 1832 DrawInfo::ScissorState scissorState;
1833 fScissorState.fEnabled = true; 1833 scissorState.fEnabled = true;
1834 fScissorState.fRect = dirtyRect; 1834 scissorState.fRect = dirtyRect;
1835 this->flushScissor(rt->getViewport(), rt->origin()); 1835 this->flushScissor(scissorState, rt->getViewport(), rt->origin() );
1836 GL_CALL(ResolveMultisampleFramebuffer()); 1836 GL_CALL(ResolveMultisampleFramebuffer());
1837 } else { 1837 } else {
1838 int right = r.fLeft + r.fWidth; 1838 int right = r.fLeft + r.fWidth;
1839 int top = r.fBottom + r.fHeight; 1839 int top = r.fBottom + r.fHeight;
1840 1840
1841 // BlitFrameBuffer respects the scissor, so disable it. 1841 // BlitFrameBuffer respects the scissor, so disable it.
1842 asr.reset(&fScissorState); 1842 DrawInfo::ScissorState scissorState;
1843 fScissorState.fEnabled = false; 1843 scissorState.fEnabled = false;
1844 this->flushScissor(rt->getViewport(), rt->origin()); 1844 this->flushScissor(scissorState, rt->getViewport(), rt->origin() );
1845 GL_CALL(BlitFramebuffer(r.fLeft, r.fBottom, right, top, 1845 GL_CALL(BlitFramebuffer(r.fLeft, r.fBottom, right, top,
1846 r.fLeft, r.fBottom, right, top, 1846 r.fLeft, r.fBottom, right, top,
1847 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); 1847 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST));
1848 } 1848 }
1849 } 1849 }
1850 rt->flagAsResolved(); 1850 rt->flagAsResolved();
1851 } 1851 }
1852 } 1852 }
1853 1853
1854 namespace { 1854 namespace {
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 srcRect.width(), 2501 srcRect.width(),
2502 srcRect.height(), 2502 srcRect.height(),
2503 src->origin()); 2503 src->origin());
2504 dstGLRect.setRelativeTo(dstVP, 2504 dstGLRect.setRelativeTo(dstVP,
2505 dstRect.fLeft, 2505 dstRect.fLeft,
2506 dstRect.fTop, 2506 dstRect.fTop,
2507 dstRect.width(), 2507 dstRect.width(),
2508 dstRect.height(), 2508 dstRect.height(),
2509 dst->origin()); 2509 dst->origin());
2510 2510
2511 GrAutoTRestore<ScissorState> asr;
2512 // BlitFrameBuffer respects the scissor, so disable it. 2511 // BlitFrameBuffer respects the scissor, so disable it.
2513 asr.reset(&fScissorState); 2512 DrawInfo::ScissorState scissorState;
2514 fScissorState.fEnabled = false; 2513 scissorState.fEnabled = false;
2515 this->flushScissor(dstGLRect, dst->origin()); 2514 this->flushScissor(scissorState, dstGLRect, dst->origin());
2516 2515
2517 GrGLint srcY0; 2516 GrGLint srcY0;
2518 GrGLint srcY1; 2517 GrGLint srcY1;
2519 // Does the blit need to y-mirror or not? 2518 // Does the blit need to y-mirror or not?
2520 if (src->origin() == dst->origin()) { 2519 if (src->origin() == dst->origin()) {
2521 srcY0 = srcGLRect.fBottom; 2520 srcY0 = srcGLRect.fBottom;
2522 srcY1 = srcGLRect.fBottom + srcGLRect.fHeight; 2521 srcY1 = srcGLRect.fBottom + srcGLRect.fHeight;
2523 } else { 2522 } else {
2524 srcY0 = srcGLRect.fBottom + srcGLRect.fHeight; 2523 srcY0 = srcGLRect.fBottom + srcGLRect.fHeight;
2525 srcY1 = srcGLRect.fBottom; 2524 srcY1 = srcGLRect.fBottom;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 this->setVertexArrayID(gpu, 0); 2609 this->setVertexArrayID(gpu, 0);
2611 } 2610 }
2612 int attrCount = gpu->glCaps().maxVertexAttributes(); 2611 int attrCount = gpu->glCaps().maxVertexAttributes();
2613 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2612 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2614 fDefaultVertexArrayAttribState.resize(attrCount); 2613 fDefaultVertexArrayAttribState.resize(attrCount);
2615 } 2614 }
2616 attribState = &fDefaultVertexArrayAttribState; 2615 attribState = &fDefaultVertexArrayAttribState;
2617 } 2616 }
2618 return attribState; 2617 return attribState;
2619 } 2618 }
OLDNEW
« src/gpu/GrGpu.cpp ('K') | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698