| 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" |
| (...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 } | 1679 } |
| 1680 | 1680 |
| 1681 static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL
Caps& caps, | 1681 static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL
Caps& caps, |
| 1682 int width, int height, GrPixelConfig co
nfig, | 1682 int width, int height, GrPixelConfig co
nfig, |
| 1683 size_t rowBytes) { | 1683 size_t rowBytes) { |
| 1684 // If this render target is already TopLeft, we don't need to flip. | 1684 // If this render target is already TopLeft, we don't need to flip. |
| 1685 if (kTopLeft_GrSurfaceOrigin == renderTarget->origin()) { | 1685 if (kTopLeft_GrSurfaceOrigin == renderTarget->origin()) { |
| 1686 return false; | 1686 return false; |
| 1687 } | 1687 } |
| 1688 | 1688 |
| 1689 // If the read is really small or smaller than the min texture size, don't f
orce a draw. |
| 1690 int minSize = SkTMax(32, caps.minTextureSize()); |
| 1691 if (width < minSize || height < minSize) { |
| 1692 return false; |
| 1693 } |
| 1694 |
| 1689 // if GL can do the flip then we'll never pay for it. | 1695 // if GL can do the flip then we'll never pay for it. |
| 1690 if (caps.packFlipYSupport()) { | 1696 if (caps.packFlipYSupport()) { |
| 1691 return false; | 1697 return false; |
| 1692 } | 1698 } |
| 1693 | 1699 |
| 1694 // If we have to do memcpy to handle non-trim rowBytes then we | 1700 // If we have to do memcpy to handle non-trim rowBytes then we |
| 1695 // get the flip for free. Otherwise it costs. | 1701 // get the flip for free. Otherwise it costs. |
| 1696 // Note that we're assuming that 0 rowBytes has already been handled and tha
t the width has been | 1702 // Note that we're assuming that 0 rowBytes has already been handled and tha
t the width has been |
| 1697 // clipped. | 1703 // clipped. |
| 1698 return caps.packRowLengthSupport() || GrBytesPerPixel(config) * width == row
Bytes; | 1704 return caps.packRowLengthSupport() || GrBytesPerPixel(config) * width == row
Bytes; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1719 | 1725 |
| 1720 tempDrawInfo->fSwapRAndB = false; | 1726 tempDrawInfo->fSwapRAndB = false; |
| 1721 | 1727 |
| 1722 // These settings we will always want if a temp draw is performed. The confi
g is set below | 1728 // These settings we will always want if a temp draw is performed. The confi
g is set below |
| 1723 // depending on whether we want to do a R/B swap or not. | 1729 // depending on whether we want to do a R/B swap or not. |
| 1724 tempDrawInfo->fTempSurfaceDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 1730 tempDrawInfo->fTempSurfaceDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 1725 tempDrawInfo->fTempSurfaceDesc.fWidth = width; | 1731 tempDrawInfo->fTempSurfaceDesc.fWidth = width; |
| 1726 tempDrawInfo->fTempSurfaceDesc.fHeight = height; | 1732 tempDrawInfo->fTempSurfaceDesc.fHeight = height; |
| 1727 tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 0; | 1733 tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 0; |
| 1728 tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU
y-flip for TL. | 1734 tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU
y-flip for TL. |
| 1729 tempDrawInfo->fUseExactScratch = SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_
PARTIAL); | 1735 tempDrawInfo->fUseExactScratch = SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_
PARTIAL) && |
| 1736 width >= this->caps()->minTextureSize() && |
| 1737 height >= this->caps()->minTextureSize(); |
| 1730 | 1738 |
| 1731 // Start off assuming that any temp draw should be to the readConfig, then c
heck if that will | 1739 // Start off assuming that any temp draw should be to the readConfig, then c
heck if that will |
| 1732 // be inefficient. | 1740 // be inefficient. |
| 1733 GrPixelConfig srcConfig = srcSurface->config(); | 1741 GrPixelConfig srcConfig = srcSurface->config(); |
| 1734 tempDrawInfo->fTempSurfaceDesc.fConfig = readConfig; | 1742 tempDrawInfo->fTempSurfaceDesc.fConfig = readConfig; |
| 1735 | 1743 |
| 1736 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { | 1744 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { |
| 1737 tempDrawInfo->fTempSurfaceDesc.fConfig = kBGRA_8888_GrPixelConfig; | 1745 tempDrawInfo->fTempSurfaceDesc.fConfig = kBGRA_8888_GrPixelConfig; |
| 1738 } else if (kMesa_GrGLDriver == this->glContext().driver() && | 1746 } else if (kMesa_GrGLDriver == this->glContext().driver() && |
| 1739 GrBytesPerPixel(readConfig) == 4 && | 1747 GrBytesPerPixel(readConfig) == 4 && |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3160 this->setVertexArrayID(gpu, 0); | 3168 this->setVertexArrayID(gpu, 0); |
| 3161 } | 3169 } |
| 3162 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3170 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3163 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3171 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3164 fDefaultVertexArrayAttribState.resize(attrCount); | 3172 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3165 } | 3173 } |
| 3166 attribState = &fDefaultVertexArrayAttribState; | 3174 attribState = &fDefaultVertexArrayAttribState; |
| 3167 } | 3175 } |
| 3168 return attribState; | 3176 return attribState; |
| 3169 } | 3177 } |
| OLD | NEW |