| 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" |
| 11 #include "GrGLPath.h" | 11 #include "GrGLPath.h" |
| 12 #include "GrGLShaderBuilder.h" | 12 #include "GrGLShaderBuilder.h" |
| 13 #include "GrTemplates.h" | 13 #include "GrTemplates.h" |
| 14 #include "GrTypes.h" | 14 #include "GrTypes.h" |
| 15 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
| 16 | 16 |
| 17 static const GrGLuint GR_MAX_GLUINT = ~0U; | 17 static const GrGLuint GR_MAX_GLUINT = ~0U; |
| 18 static const GrGLint GR_INVAL_GLINT = ~0; | 18 static const GrGLint GR_INVAL_GLINT = ~0; |
| 19 | 19 |
| 20 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) | 20 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) |
| 21 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) | 21 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) |
| 22 | 22 |
| 23 // we use a spare texture unit to avoid | |
| 24 // mucking with the state of any of the stages. | |
| 25 static const int SPARE_TEX_UNIT = GrDrawState::kNumStages; | |
| 26 | 23 |
| 27 #define SKIP_CACHE_CHECK true | 24 #define SKIP_CACHE_CHECK true |
| 28 | 25 |
| 29 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR | 26 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR |
| 30 #define CLEAR_ERROR_BEFORE_ALLOC(iface) GrGLClearErr(iface) | 27 #define CLEAR_ERROR_BEFORE_ALLOC(iface) GrGLClearErr(iface) |
| 31 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL_NOERRCHECK(iface, call) | 28 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL_NOERRCHECK(iface, call) |
| 32 #define CHECK_ALLOC_ERROR(iface) GR_GL_GET_ERROR(iface) | 29 #define CHECK_ALLOC_ERROR(iface) GR_GL_GET_ERROR(iface) |
| 33 #else | 30 #else |
| 34 #define CLEAR_ERROR_BEFORE_ALLOC(iface) | 31 #define CLEAR_ERROR_BEFORE_ALLOC(iface) |
| 35 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL(iface, call) | 32 #define GL_ALLOC_CALL(iface, call) GR_GL_CALL(iface, call) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 108 |
| 112 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope | 109 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope |
| 113 GR_STATIC_ASSERT(kTotalGrBlendCoeffCount == | 110 GR_STATIC_ASSERT(kTotalGrBlendCoeffCount == |
| 114 GR_ARRAY_COUNT(gXfermodeCoeff2Blend)); | 111 GR_ARRAY_COUNT(gXfermodeCoeff2Blend)); |
| 115 } | 112 } |
| 116 | 113 |
| 117 /////////////////////////////////////////////////////////////////////////////// | 114 /////////////////////////////////////////////////////////////////////////////// |
| 118 | 115 |
| 119 static bool gPrintStartupSpew; | 116 static bool gPrintStartupSpew; |
| 120 | 117 |
| 121 static bool fbo_test(const GrGLInterface* gl, int w, int h) { | |
| 122 | |
| 123 GR_GL_CALL(gl, ActiveTexture(GR_GL_TEXTURE0 + SPARE_TEX_UNIT)); | |
| 124 | |
| 125 GrGLuint testFBO; | |
| 126 GR_GL_CALL(gl, GenFramebuffers(1, &testFBO)); | |
| 127 GR_GL_CALL(gl, BindFramebuffer(GR_GL_FRAMEBUFFER, testFBO)); | |
| 128 GrGLuint testRTTex; | |
| 129 GR_GL_CALL(gl, GenTextures(1, &testRTTex)); | |
| 130 GR_GL_CALL(gl, BindTexture(GR_GL_TEXTURE_2D, testRTTex)); | |
| 131 // some implementations require texture to be mip-map complete before | |
| 132 // FBO with level 0 bound as color attachment will be framebuffer complete. | |
| 133 GR_GL_CALL(gl, TexParameteri(GR_GL_TEXTURE_2D, | |
| 134 GR_GL_TEXTURE_MIN_FILTER, | |
| 135 GR_GL_NEAREST)); | |
| 136 GR_GL_CALL(gl, TexImage2D(GR_GL_TEXTURE_2D, 0, GR_GL_RGBA, w, h, | |
| 137 0, GR_GL_RGBA, GR_GL_UNSIGNED_BYTE, NULL)); | |
| 138 GR_GL_CALL(gl, BindTexture(GR_GL_TEXTURE_2D, 0)); | |
| 139 GR_GL_CALL(gl, FramebufferTexture2D(GR_GL_FRAMEBUFFER, | |
| 140 GR_GL_COLOR_ATTACHMENT0, | |
| 141 GR_GL_TEXTURE_2D, testRTTex, 0)); | |
| 142 GrGLenum status; | |
| 143 GR_GL_CALL_RET(gl, status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | |
| 144 GR_GL_CALL(gl, DeleteFramebuffers(1, &testFBO)); | |
| 145 GR_GL_CALL(gl, DeleteTextures(1, &testRTTex)); | |
| 146 | |
| 147 return status == GR_GL_FRAMEBUFFER_COMPLETE; | |
| 148 } | |
| 149 | |
| 150 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) | 118 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) |
| 151 : GrGpu(context) | 119 : GrGpu(context) |
| 152 , fGLContext(ctx) { | 120 , fGLContext(ctx) { |
| 153 | 121 |
| 154 GrAssert(ctx.isInitialized()); | 122 GrAssert(ctx.isInitialized()); |
| 155 | 123 |
| 156 fCaps.reset(SkRef(ctx.info().caps())); | 124 fCaps.reset(SkRef(ctx.info().caps())); |
| 157 | 125 |
| 126 fHWBoundTextures.reset(ctx.info().caps()->maxFragmentTextureUnits()); |
| 127 |
| 158 fillInConfigRenderableTable(); | 128 fillInConfigRenderableTable(); |
| 159 | 129 |
| 160 | 130 |
| 161 GrGLClearErr(fGLContext.interface()); | 131 GrGLClearErr(fGLContext.interface()); |
| 162 | 132 |
| 163 if (gPrintStartupSpew) { | 133 if (gPrintStartupSpew) { |
| 164 const GrGLubyte* vendor; | 134 const GrGLubyte* vendor; |
| 165 const GrGLubyte* renderer; | 135 const GrGLubyte* renderer; |
| 166 const GrGLubyte* version; | 136 const GrGLubyte* version; |
| 167 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); | 137 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); |
| 168 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); | 138 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); |
| 169 GL_CALL_RET(version, GetString(GR_GL_VERSION)); | 139 GL_CALL_RET(version, GetString(GR_GL_VERSION)); |
| 170 GrPrintf("------------------------- create GrGpuGL %p --------------\n", | 140 GrPrintf("------------------------- create GrGpuGL %p --------------\n", |
| 171 this); | 141 this); |
| 172 GrPrintf("------ VENDOR %s\n", vendor); | 142 GrPrintf("------ VENDOR %s\n", vendor); |
| 173 GrPrintf("------ RENDERER %s\n", renderer); | 143 GrPrintf("------ RENDERER %s\n", renderer); |
| 174 GrPrintf("------ VERSION %s\n", version); | 144 GrPrintf("------ VERSION %s\n", version); |
| 175 GrPrintf("------ EXTENSIONS\n"); | 145 GrPrintf("------ EXTENSIONS\n"); |
| 176 ctx.info().extensions().print(); | 146 ctx.info().extensions().print(); |
| 177 GrPrintf("\n"); | 147 GrPrintf("\n"); |
| 178 ctx.info().caps()->print(); | 148 ctx.info().caps()->print(); |
| 179 } | 149 } |
| 180 | 150 |
| 181 fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext())); | 151 fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext())); |
| 182 | 152 |
| 183 GrAssert(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr
ibCnt); | 153 GrAssert(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr
ibCnt); |
| 184 | 154 |
| 185 fLastSuccessfulStencilFmtIdx = 0; | 155 fLastSuccessfulStencilFmtIdx = 0; |
| 186 if (false) { // avoid bit rot, suppress warning | |
| 187 fbo_test(this->glInterface(), 0, 0); | |
| 188 } | |
| 189 } | 156 } |
| 190 | 157 |
| 191 GrGpuGL::~GrGpuGL() { | 158 GrGpuGL::~GrGpuGL() { |
| 192 if (0 != fHWProgramID) { | 159 if (0 != fHWProgramID) { |
| 193 // detach the current program so there is no confusion on OpenGL's part | 160 // detach the current program so there is no confusion on OpenGL's part |
| 194 // that we want it to be deleted | 161 // that we want it to be deleted |
| 195 GrAssert(fHWProgramID == fCurrentProgram->programID()); | 162 GrAssert(fHWProgramID == fCurrentProgram->programID()); |
| 196 GL_CALL(UseProgram(0)); | 163 GL_CALL(UseProgram(0)); |
| 197 } | 164 } |
| 198 | 165 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 fHWWriteToColor = kUnknown_TriState; | 321 fHWWriteToColor = kUnknown_TriState; |
| 355 | 322 |
| 356 // we only ever use lines in hairline mode | 323 // we only ever use lines in hairline mode |
| 357 GL_CALL(LineWidth(1)); | 324 GL_CALL(LineWidth(1)); |
| 358 | 325 |
| 359 // invalid | 326 // invalid |
| 360 fHWActiveTextureUnitIdx = -1; | 327 fHWActiveTextureUnitIdx = -1; |
| 361 | 328 |
| 362 fHWBlendState.invalidate(); | 329 fHWBlendState.invalidate(); |
| 363 | 330 |
| 364 for (int s = 0; s < GrDrawState::kNumStages; ++s) { | 331 for (int s = 0; s < fHWBoundTextures.count(); ++s) { |
| 365 fHWBoundTextures[s] = NULL; | 332 fHWBoundTextures[s] = NULL; |
| 366 } | 333 } |
| 367 | 334 |
| 368 fHWScissorSettings.invalidate(); | 335 fHWScissorSettings.invalidate(); |
| 369 | 336 |
| 370 fHWViewport.invalidate(); | 337 fHWViewport.invalidate(); |
| 371 | 338 |
| 372 fHWStencilSettings.invalidate(); | 339 fHWStencilSettings.invalidate(); |
| 373 fHWStencilTestEnabled = kUnknown_TriState; | 340 fHWStencilTestEnabled = kUnknown_TriState; |
| 374 | 341 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 return NULL; | 433 return NULL; |
| 467 } | 434 } |
| 468 texture = SkNEW_ARGS(GrGLTexture, (this, glTexDesc, glRTDesc)); | 435 texture = SkNEW_ARGS(GrGLTexture, (this, glTexDesc, glRTDesc)); |
| 469 } else { | 436 } else { |
| 470 texture = SkNEW_ARGS(GrGLTexture, (this, glTexDesc)); | 437 texture = SkNEW_ARGS(GrGLTexture, (this, glTexDesc)); |
| 471 } | 438 } |
| 472 if (NULL == texture) { | 439 if (NULL == texture) { |
| 473 return NULL; | 440 return NULL; |
| 474 } | 441 } |
| 475 | 442 |
| 476 this->setSpareTextureUnit(); | |
| 477 return texture; | 443 return texture; |
| 478 } | 444 } |
| 479 | 445 |
| 480 GrRenderTarget* GrGpuGL::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& desc) { | 446 GrRenderTarget* GrGpuGL::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& desc) { |
| 481 GrGLRenderTarget::Desc glDesc; | 447 GrGLRenderTarget::Desc glDesc; |
| 482 glDesc.fConfig = desc.fConfig; | 448 glDesc.fConfig = desc.fConfig; |
| 483 glDesc.fRTFBOID = static_cast<GrGLuint>(desc.fRenderTargetHandle); | 449 glDesc.fRTFBOID = static_cast<GrGLuint>(desc.fRenderTargetHandle); |
| 484 glDesc.fMSColorRenderbufferID = 0; | 450 glDesc.fMSColorRenderbufferID = 0; |
| 485 glDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; | 451 glDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; |
| 486 glDesc.fSampleCnt = desc.fSampleCnt; | 452 glDesc.fSampleCnt = desc.fSampleCnt; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 486 |
| 521 bool GrGpuGL::onWriteTexturePixels(GrTexture* texture, | 487 bool GrGpuGL::onWriteTexturePixels(GrTexture* texture, |
| 522 int left, int top, int width, int height, | 488 int left, int top, int width, int height, |
| 523 GrPixelConfig config, const void* buffer, | 489 GrPixelConfig config, const void* buffer, |
| 524 size_t rowBytes) { | 490 size_t rowBytes) { |
| 525 if (NULL == buffer) { | 491 if (NULL == buffer) { |
| 526 return false; | 492 return false; |
| 527 } | 493 } |
| 528 GrGLTexture* glTex = static_cast<GrGLTexture*>(texture); | 494 GrGLTexture* glTex = static_cast<GrGLTexture*>(texture); |
| 529 | 495 |
| 530 this->setSpareTextureUnit(); | 496 this->setScratchTextureUnit(); |
| 531 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTex->textureID())); | 497 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTex->textureID())); |
| 532 GrGLTexture::Desc desc; | 498 GrGLTexture::Desc desc; |
| 533 desc.fFlags = glTex->desc().fFlags; | 499 desc.fFlags = glTex->desc().fFlags; |
| 534 desc.fWidth = glTex->width(); | 500 desc.fWidth = glTex->width(); |
| 535 desc.fHeight = glTex->height(); | 501 desc.fHeight = glTex->height(); |
| 536 desc.fConfig = glTex->config(); | 502 desc.fConfig = glTex->config(); |
| 537 desc.fSampleCnt = glTex->desc().fSampleCnt; | 503 desc.fSampleCnt = glTex->desc().fSampleCnt; |
| 538 desc.fTextureID = glTex->textureID(); | 504 desc.fTextureID = glTex->textureID(); |
| 539 desc.fOrigin = glTex->origin(); | 505 desc.fOrigin = glTex->origin(); |
| 540 | 506 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 if (renderTarget && this->glCaps().textureUsageSupport()) { | 911 if (renderTarget && this->glCaps().textureUsageSupport()) { |
| 946 // provides a hint about how this texture will be used | 912 // provides a hint about how this texture will be used |
| 947 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 913 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 948 GR_GL_TEXTURE_USAGE, | 914 GR_GL_TEXTURE_USAGE, |
| 949 GR_GL_FRAMEBUFFER_ATTACHMENT)); | 915 GR_GL_FRAMEBUFFER_ATTACHMENT)); |
| 950 } | 916 } |
| 951 if (!glTexDesc.fTextureID) { | 917 if (!glTexDesc.fTextureID) { |
| 952 return return_null_texture(); | 918 return return_null_texture(); |
| 953 } | 919 } |
| 954 | 920 |
| 955 this->setSpareTextureUnit(); | 921 this->setScratchTextureUnit(); |
| 956 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); | 922 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); |
| 957 | 923 |
| 958 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some | 924 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some |
| 959 // drivers have a bug where an FBO won't be complete if it includes a | 925 // drivers have a bug where an FBO won't be complete if it includes a |
| 960 // texture that is not mipmap complete (considering the filter in use). | 926 // texture that is not mipmap complete (considering the filter in use). |
| 961 GrGLTexture::TexParams initialTexParams; | 927 GrGLTexture::TexParams initialTexParams; |
| 962 // we only set a subset here so invalidate first | 928 // we only set a subset here so invalidate first |
| 963 initialTexParams.invalidate(); | 929 initialTexParams.invalidate(); |
| 964 initialTexParams.fFilter = GR_GL_NEAREST; | 930 initialTexParams.fFilter = GR_GL_NEAREST; |
| 965 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; | 931 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 } | 2061 } |
| 2096 | 2062 |
| 2097 void GrGpuGL::notifyRenderTargetDelete(GrRenderTarget* renderTarget) { | 2063 void GrGpuGL::notifyRenderTargetDelete(GrRenderTarget* renderTarget) { |
| 2098 GrAssert(NULL != renderTarget); | 2064 GrAssert(NULL != renderTarget); |
| 2099 if (fHWBoundRenderTarget == renderTarget) { | 2065 if (fHWBoundRenderTarget == renderTarget) { |
| 2100 fHWBoundRenderTarget = NULL; | 2066 fHWBoundRenderTarget = NULL; |
| 2101 } | 2067 } |
| 2102 } | 2068 } |
| 2103 | 2069 |
| 2104 void GrGpuGL::notifyTextureDelete(GrGLTexture* texture) { | 2070 void GrGpuGL::notifyTextureDelete(GrGLTexture* texture) { |
| 2105 for (int s = 0; s < GrDrawState::kNumStages; ++s) { | 2071 for (int s = 0; s < fHWBoundTextures.count(); ++s) { |
| 2106 if (fHWBoundTextures[s] == texture) { | 2072 if (fHWBoundTextures[s] == texture) { |
| 2107 // deleting bound texture does implied bind to 0 | 2073 // deleting bound texture does implied bind to 0 |
| 2108 fHWBoundTextures[s] = NULL; | 2074 fHWBoundTextures[s] = NULL; |
| 2109 } | 2075 } |
| 2110 } | 2076 } |
| 2111 } | 2077 } |
| 2112 | 2078 |
| 2113 bool GrGpuGL::configToGLFormats(GrPixelConfig config, | 2079 bool GrGpuGL::configToGLFormats(GrPixelConfig config, |
| 2114 bool getSizedInternalFormat, | 2080 bool getSizedInternalFormat, |
| 2115 GrGLenum* internalFormat, | 2081 GrGLenum* internalFormat, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2215 *externalType = GR_GL_UNSIGNED_BYTE; | 2181 *externalType = GR_GL_UNSIGNED_BYTE; |
| 2216 } | 2182 } |
| 2217 break; | 2183 break; |
| 2218 default: | 2184 default: |
| 2219 return false; | 2185 return false; |
| 2220 } | 2186 } |
| 2221 return true; | 2187 return true; |
| 2222 } | 2188 } |
| 2223 | 2189 |
| 2224 void GrGpuGL::setTextureUnit(int unit) { | 2190 void GrGpuGL::setTextureUnit(int unit) { |
| 2225 GrAssert(unit >= 0 && unit < GrDrawState::kNumStages); | 2191 GrAssert(unit >= 0 && unit < fHWBoundTextures.count()); |
| 2226 if (fHWActiveTextureUnitIdx != unit) { | 2192 if (unit != fHWActiveTextureUnitIdx) { |
| 2227 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); | 2193 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); |
| 2228 fHWActiveTextureUnitIdx = unit; | 2194 fHWActiveTextureUnitIdx = unit; |
| 2229 } | 2195 } |
| 2230 } | 2196 } |
| 2231 | 2197 |
| 2232 void GrGpuGL::setSpareTextureUnit() { | 2198 void GrGpuGL::setScratchTextureUnit() { |
| 2233 if (fHWActiveTextureUnitIdx != (GR_GL_TEXTURE0 + SPARE_TEX_UNIT)) { | 2199 // Bind the last texture unit since it is the least likely to be used by GrG
LProgram. |
| 2234 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + SPARE_TEX_UNIT)); | 2200 int lastUnitIdx = fHWBoundTextures.count() - 1; |
| 2235 fHWActiveTextureUnitIdx = SPARE_TEX_UNIT; | 2201 if (lastUnitIdx != fHWActiveTextureUnitIdx) { |
| 2202 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx)); |
| 2203 fHWActiveTextureUnitIdx = lastUnitIdx; |
| 2236 } | 2204 } |
| 2205 // clear out the this field so that if a program does use this unit it will
rebind the correct |
| 2206 // texture. |
| 2207 fHWBoundTextures[lastUnitIdx] = NULL; |
| 2237 } | 2208 } |
| 2238 | 2209 |
| 2239 namespace { | 2210 namespace { |
| 2240 // Determines whether glBlitFramebuffer could be used between src and dst. | 2211 // Determines whether glBlitFramebuffer could be used between src and dst. |
| 2241 inline bool can_blit_framebuffer(const GrSurface* dst, | 2212 inline bool can_blit_framebuffer(const GrSurface* dst, |
| 2242 const GrSurface* src, | 2213 const GrSurface* src, |
| 2243 const GrGpuGL* gpu, | 2214 const GrGpuGL* gpu, |
| 2244 bool* wouldNeedTempFBO = NULL) { | 2215 bool* wouldNeedTempFBO = NULL) { |
| 2245 if (gpu->isConfigRenderable(dst->config()) && | 2216 if (gpu->isConfigRenderable(dst->config()) && |
| 2246 gpu->isConfigRenderable(src->config()) && | 2217 gpu->isConfigRenderable(src->config()) && |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2363 // We modified the bound FBO | 2334 // We modified the bound FBO |
| 2364 fHWBoundRenderTarget = NULL; | 2335 fHWBoundRenderTarget = NULL; |
| 2365 GrGLIRect srcGLRect; | 2336 GrGLIRect srcGLRect; |
| 2366 srcGLRect.setRelativeTo(srcVP, | 2337 srcGLRect.setRelativeTo(srcVP, |
| 2367 srcRect.fLeft, | 2338 srcRect.fLeft, |
| 2368 srcRect.fTop, | 2339 srcRect.fTop, |
| 2369 srcRect.width(), | 2340 srcRect.width(), |
| 2370 srcRect.height(), | 2341 srcRect.height(), |
| 2371 src->origin()); | 2342 src->origin()); |
| 2372 | 2343 |
| 2373 this->setSpareTextureUnit(); | 2344 this->setScratchTextureUnit(); |
| 2374 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); | 2345 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); |
| 2375 GrGLint dstY; | 2346 GrGLint dstY; |
| 2376 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { | 2347 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { |
| 2377 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight); | 2348 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight); |
| 2378 } else { | 2349 } else { |
| 2379 dstY = dstPoint.fY; | 2350 dstY = dstPoint.fY; |
| 2380 } | 2351 } |
| 2381 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0, | 2352 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0, |
| 2382 dstPoint.fX, dstY, | 2353 dstPoint.fX, dstY, |
| 2383 srcGLRect.fLeft, srcGLRect.fBottom, | 2354 srcGLRect.fLeft, srcGLRect.fBottom, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2510 this->setVertexArrayID(gpu, 0); | 2481 this->setVertexArrayID(gpu, 0); |
| 2511 } | 2482 } |
| 2512 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2483 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2513 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2484 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2514 fDefaultVertexArrayAttribState.resize(attrCount); | 2485 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2515 } | 2486 } |
| 2516 attribState = &fDefaultVertexArrayAttribState; | 2487 attribState = &fDefaultVertexArrayAttribState; |
| 2517 } | 2488 } |
| 2518 return attribState; | 2489 return attribState; |
| 2519 } | 2490 } |
| OLD | NEW |