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

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: rebase on master 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
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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));
1381 fHWScissorSettings.fEnabled = kYes_TriState; 1383 fHWScissorSettings.fEnabled = kYes_TriState;
1382 } 1384 }
1383 return; 1385 return;
1384 } 1386 }
1385 } 1387 }
1388
1389 // See fall through note above
1390 this->disableScissor();
1391 }
1392
1393 void GrGpuGL::disableScissor() {
1386 if (kNo_TriState != fHWScissorSettings.fEnabled) { 1394 if (kNo_TriState != fHWScissorSettings.fEnabled) {
1387 GL_CALL(Disable(GR_GL_SCISSOR_TEST)); 1395 GL_CALL(Disable(GR_GL_SCISSOR_TEST));
1388 fHWScissorSettings.fEnabled = kNo_TriState; 1396 fHWScissorSettings.fEnabled = kNo_TriState;
1389 return; 1397 return;
1390 } 1398 }
1391 } 1399 }
1392 1400
1393 void GrGpuGL::onClear(GrRenderTarget* target, const SkIRect* rect, GrColor color , 1401 void GrGpuGL::onClear(GrRenderTarget* target, const SkIRect* rect, GrColor color ,
1394 bool canIgnoreRect) { 1402 bool canIgnoreRect) {
1395 // parent class should never let us get here with no RT 1403 // parent class should never let us get here with no RT
(...skipping 10 matching lines...) Expand all
1406 clippedRect = *rect; 1414 clippedRect = *rect;
1407 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height()); 1415 SkIRect rtRect = SkIRect::MakeWH(target->width(), target->height());
1408 if (clippedRect.intersect(rtRect)) { 1416 if (clippedRect.intersect(rtRect)) {
1409 rect = &clippedRect; 1417 rect = &clippedRect;
1410 } else { 1418 } else {
1411 return; 1419 return;
1412 } 1420 }
1413 } 1421 }
1414 1422
1415 this->flushRenderTarget(glRT, rect); 1423 this->flushRenderTarget(glRT, rect);
1416 GrAutoTRestore<ScissorState> asr(&fScissorState); 1424 ScissorState scissorState;
1417 fScissorState.fEnabled = SkToBool(rect); 1425 scissorState.fEnabled = SkToBool(rect);
1418 if (fScissorState.fEnabled) { 1426 if (scissorState.fEnabled) {
1419 fScissorState.fRect = *rect; 1427 scissorState.fRect = *rect;
1420 } 1428 }
1421 this->flushScissor(glRT->getViewport(), glRT->origin()); 1429 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
1422 1430
1423 GrGLfloat r, g, b, a; 1431 GrGLfloat r, g, b, a;
1424 static const GrGLfloat scale255 = 1.f / 255.f; 1432 static const GrGLfloat scale255 = 1.f / 255.f;
1425 a = GrColorUnpackA(color) * scale255; 1433 a = GrColorUnpackA(color) * scale255;
1426 GrGLfloat scaleRGB = scale255; 1434 GrGLfloat scaleRGB = scale255;
1427 r = GrColorUnpackR(color) * scaleRGB; 1435 r = GrColorUnpackR(color) * scaleRGB;
1428 g = GrColorUnpackG(color) * scaleRGB; 1436 g = GrColorUnpackG(color) * scaleRGB;
1429 b = GrColorUnpackB(color) * scaleRGB; 1437 b = GrColorUnpackB(color) * scaleRGB;
1430 1438
1431 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); 1439 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 } 1497 }
1490 1498
1491 1499
1492 void GrGpuGL::clearStencil(GrRenderTarget* target) { 1500 void GrGpuGL::clearStencil(GrRenderTarget* target) {
1493 if (NULL == target) { 1501 if (NULL == target) {
1494 return; 1502 return;
1495 } 1503 }
1496 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 1504 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
1497 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); 1505 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
1498 1506
1499 GrAutoTRestore<ScissorState> asr(&fScissorState); 1507 this->disableScissor();
1500 fScissorState.fEnabled = false;
1501 this->flushScissor(glRT->getViewport(), glRT->origin());
1502 1508
1503 GL_CALL(StencilMask(0xffffffff)); 1509 GL_CALL(StencilMask(0xffffffff));
1504 GL_CALL(ClearStencil(0)); 1510 GL_CALL(ClearStencil(0));
1505 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 1511 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
1506 fHWStencilSettings.invalidate(); 1512 fHWStencilSettings.invalidate();
1507 } 1513 }
1508 1514
1509 void GrGpuGL::clearStencilClip(GrRenderTarget* target, const SkIRect& rect, bool insideClip) { 1515 void GrGpuGL::clearStencilClip(GrRenderTarget* target, const SkIRect& rect, bool insideClip) {
1510 SkASSERT(target); 1516 SkASSERT(target);
1511 1517
(...skipping 14 matching lines...) Expand all
1526 #endif 1532 #endif
1527 GrGLint value; 1533 GrGLint value;
1528 if (insideClip) { 1534 if (insideClip) {
1529 value = (1 << (stencilBitCount - 1)); 1535 value = (1 << (stencilBitCount - 1));
1530 } else { 1536 } else {
1531 value = 0; 1537 value = 0;
1532 } 1538 }
1533 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 1539 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
1534 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); 1540 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
1535 1541
1536 GrAutoTRestore<ScissorState> asr(&fScissorState); 1542 ScissorState scissorState;
1537 fScissorState.fEnabled = true; 1543 scissorState.fEnabled = true;
1538 fScissorState.fRect = rect; 1544 scissorState.fRect = rect;
1539 this->flushScissor(glRT->getViewport(), glRT->origin()); 1545 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
1540 1546
1541 GL_CALL(StencilMask((uint32_t) clipStencilMask)); 1547 GL_CALL(StencilMask((uint32_t) clipStencilMask));
1542 GL_CALL(ClearStencil(value)); 1548 GL_CALL(ClearStencil(value));
1543 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 1549 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
1544 fHWStencilSettings.invalidate(); 1550 fHWStencilSettings.invalidate();
1545 } 1551 }
1546 1552
1547 bool GrGpuGL::readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, 1553 bool GrGpuGL::readPixelsWillPayForYFlip(GrRenderTarget* renderTarget,
1548 int left, int top, 1554 int left, int top,
1549 int width, int height, 1555 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())) ; 1825 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ;
1820 // make sure we go through flushRenderTarget() since we've modified 1826 // make sure we go through flushRenderTarget() since we've modified
1821 // the bound DRAW FBO ID. 1827 // the bound DRAW FBO ID.
1822 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 1828 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1823 const GrGLIRect& vp = rt->getViewport(); 1829 const GrGLIRect& vp = rt->getViewport();
1824 const SkIRect dirtyRect = rt->getResolveRect(); 1830 const SkIRect dirtyRect = rt->getResolveRect();
1825 GrGLIRect r; 1831 GrGLIRect r;
1826 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, 1832 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop,
1827 dirtyRect.width(), dirtyRect.height(), target->origi n()); 1833 dirtyRect.width(), dirtyRect.height(), target->origi n());
1828 1834
1829 GrAutoTRestore<ScissorState> asr;
1830 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { 1835 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) {
1831 // Apple's extension uses the scissor as the blit bounds. 1836 // Apple's extension uses the scissor as the blit bounds.
1832 asr.reset(&fScissorState); 1837 ScissorState scissorState;
1833 fScissorState.fEnabled = true; 1838 scissorState.fEnabled = true;
1834 fScissorState.fRect = dirtyRect; 1839 scissorState.fRect = dirtyRect;
1835 this->flushScissor(rt->getViewport(), rt->origin()); 1840 this->flushScissor(scissorState, rt->getViewport(), rt->origin() );
1836 GL_CALL(ResolveMultisampleFramebuffer()); 1841 GL_CALL(ResolveMultisampleFramebuffer());
1837 } else { 1842 } else {
1838 int right = r.fLeft + r.fWidth; 1843 int right = r.fLeft + r.fWidth;
1839 int top = r.fBottom + r.fHeight; 1844 int top = r.fBottom + r.fHeight;
1840 1845
1841 // BlitFrameBuffer respects the scissor, so disable it. 1846 // BlitFrameBuffer respects the scissor, so disable it.
1842 asr.reset(&fScissorState); 1847 this->disableScissor();
1843 fScissorState.fEnabled = false;
1844 this->flushScissor(rt->getViewport(), rt->origin());
1845 GL_CALL(BlitFramebuffer(r.fLeft, r.fBottom, right, top, 1848 GL_CALL(BlitFramebuffer(r.fLeft, r.fBottom, right, top,
1846 r.fLeft, r.fBottom, right, top, 1849 r.fLeft, r.fBottom, right, top,
1847 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); 1850 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST));
1848 } 1851 }
1849 } 1852 }
1850 rt->flagAsResolved(); 1853 rt->flagAsResolved();
1851 } 1854 }
1852 } 1855 }
1853 1856
1854 namespace { 1857 namespace {
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 srcRect.width(), 2504 srcRect.width(),
2502 srcRect.height(), 2505 srcRect.height(),
2503 src->origin()); 2506 src->origin());
2504 dstGLRect.setRelativeTo(dstVP, 2507 dstGLRect.setRelativeTo(dstVP,
2505 dstRect.fLeft, 2508 dstRect.fLeft,
2506 dstRect.fTop, 2509 dstRect.fTop,
2507 dstRect.width(), 2510 dstRect.width(),
2508 dstRect.height(), 2511 dstRect.height(),
2509 dst->origin()); 2512 dst->origin());
2510 2513
2511 GrAutoTRestore<ScissorState> asr;
2512 // BlitFrameBuffer respects the scissor, so disable it. 2514 // BlitFrameBuffer respects the scissor, so disable it.
2513 asr.reset(&fScissorState); 2515 this->disableScissor();
2514 fScissorState.fEnabled = false;
2515 this->flushScissor(dstGLRect, dst->origin());
2516 2516
2517 GrGLint srcY0; 2517 GrGLint srcY0;
2518 GrGLint srcY1; 2518 GrGLint srcY1;
2519 // Does the blit need to y-mirror or not? 2519 // Does the blit need to y-mirror or not?
2520 if (src->origin() == dst->origin()) { 2520 if (src->origin() == dst->origin()) {
2521 srcY0 = srcGLRect.fBottom; 2521 srcY0 = srcGLRect.fBottom;
2522 srcY1 = srcGLRect.fBottom + srcGLRect.fHeight; 2522 srcY1 = srcGLRect.fBottom + srcGLRect.fHeight;
2523 } else { 2523 } else {
2524 srcY0 = srcGLRect.fBottom + srcGLRect.fHeight; 2524 srcY0 = srcGLRect.fBottom + srcGLRect.fHeight;
2525 srcY1 = srcGLRect.fBottom; 2525 srcY1 = srcGLRect.fBottom;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « 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