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 #include "GrGLGpu.h" | 8 #include "GrGLGpu.h" |
9 #include "GrGLGLSL.h" | 9 #include "GrGLGLSL.h" |
10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
(...skipping 2420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 SkASSERT(fMSAAEnabled != kYes_TriState); | 2431 SkASSERT(fMSAAEnabled != kYes_TriState); |
2432 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); | 2432 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
2433 this->stampRectUsingProgram(fPLSSetupProgram.fProgram, | 2433 this->stampRectUsingProgram(fPLSSetupProgram.fProgram, |
2434 SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f, 0.
01f), | 2434 SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f, 0.
01f), |
2435 fPLSSetupProgram.fPosXformUniform, | 2435 fPLSSetupProgram.fPosXformUniform, |
2436 fPLSSetupProgram.fArrayBuffer); | 2436 fPLSSetupProgram.fArrayBuffer); |
2437 GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); | 2437 GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
2438 } | 2438 } |
2439 } | 2439 } |
2440 | 2440 |
2441 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ | 2441 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bounds)
{ |
2442 SkASSERT(target); | 2442 SkASSERT(target); |
2443 | 2443 |
2444 uint32_t rtID = target->getUniqueID(); | 2444 uint32_t rtID = target->getUniqueID(); |
2445 if (fHWBoundRenderTargetUniqueID != rtID) { | 2445 if (fHWBoundRenderTargetUniqueID != rtID) { |
2446 fStats.incRenderTargetBinds(); | 2446 fStats.incRenderTargetBinds(); |
2447 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 2447 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
2448 #ifdef SK_DEBUG | 2448 #ifdef SK_DEBUG |
2449 // don't do this check in Chromium -- this is causing | 2449 // don't do this check in Chromium -- this is causing |
2450 // lots of repeated command buffer flushes when the compositor is | 2450 // lots of repeated command buffer flushes when the compositor is |
2451 // rendering with Ganesh, which is really slow; even too slow for | 2451 // rendering with Ganesh, which is really slow; even too slow for |
2452 // Debug mode. | 2452 // Debug mode. |
2453 if (kChromium_GrGLDriver != this->glContext().driver()) { | 2453 if (kChromium_GrGLDriver != this->glContext().driver()) { |
2454 GrGLenum status; | 2454 GrGLenum status; |
2455 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 2455 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
2456 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { | 2456 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { |
2457 SkDebugf("GrGLGpu::flushRenderTarget glCheckFramebufferStatus %x
\n", status); | 2457 SkDebugf("GrGLGpu::flushRenderTarget glCheckFramebufferStatus %x
\n", status); |
2458 } | 2458 } |
2459 } | 2459 } |
2460 #endif | 2460 #endif |
2461 fHWBoundRenderTargetUniqueID = rtID; | 2461 fHWBoundRenderTargetUniqueID = rtID; |
2462 const GrGLIRect& vp = target->getViewport(); | 2462 this->flushViewport(target->getViewport()); |
2463 if (fHWViewport != vp) { | |
2464 vp.pushToGLViewport(this->glInterface()); | |
2465 fHWViewport = vp; | |
2466 } | |
2467 if (this->glCaps().srgbWriteControl()) { | 2463 if (this->glCaps().srgbWriteControl()) { |
2468 bool enableSRGBWrite = GrPixelConfigIsSRGB(target->config()); | 2464 bool enableSRGBWrite = GrPixelConfigIsSRGB(target->config()); |
2469 if (enableSRGBWrite && kYes_TriState != fHWSRGBFramebuffer) { | 2465 if (enableSRGBWrite && kYes_TriState != fHWSRGBFramebuffer) { |
2470 GL_CALL(Enable(GR_GL_FRAMEBUFFER_SRGB)); | 2466 GL_CALL(Enable(GR_GL_FRAMEBUFFER_SRGB)); |
2471 fHWSRGBFramebuffer = kYes_TriState; | 2467 fHWSRGBFramebuffer = kYes_TriState; |
2472 } else if (!enableSRGBWrite && kNo_TriState != fHWSRGBFramebuffer) { | 2468 } else if (!enableSRGBWrite && kNo_TriState != fHWSRGBFramebuffer) { |
2473 GL_CALL(Disable(GR_GL_FRAMEBUFFER_SRGB)); | 2469 GL_CALL(Disable(GR_GL_FRAMEBUFFER_SRGB)); |
2474 fHWSRGBFramebuffer = kNo_TriState; | 2470 fHWSRGBFramebuffer = kNo_TriState; |
2475 } | 2471 } |
2476 } | 2472 } |
2477 } | 2473 } |
| 2474 this->didWriteToSurface(target, bounds); |
| 2475 } |
2478 | 2476 |
| 2477 void GrGLGpu::flushViewport(const GrGLIRect& viewport) { |
| 2478 if (fHWViewport != viewport) { |
| 2479 viewport.pushToGLViewport(this->glInterface()); |
| 2480 fHWViewport = viewport; |
| 2481 } |
| 2482 } |
| 2483 |
| 2484 void GrGLGpu::didWriteToSurface(GrSurface* surface, const SkIRect* bounds) const
{ |
| 2485 SkASSERT(surface); |
2479 // Mark any MIP chain and resolve buffer as dirty if and only if there is a
non-empty bounds. | 2486 // Mark any MIP chain and resolve buffer as dirty if and only if there is a
non-empty bounds. |
2480 if (nullptr == bound || !bound->isEmpty()) { | 2487 if (nullptr == bounds || !bounds->isEmpty()) { |
2481 target->flagAsNeedingResolve(bound); | 2488 if (GrRenderTarget* target = surface->asRenderTarget()) { |
2482 if (GrTexture *texture = target->asTexture()) { | 2489 target->flagAsNeedingResolve(bounds); |
| 2490 } |
| 2491 if (GrTexture* texture = surface->asTexture()) { |
2483 texture->texturePriv().dirtyMipMaps(true); | 2492 texture->texturePriv().dirtyMipMaps(true); |
2484 } | 2493 } |
2485 } | 2494 } |
2486 } | 2495 } |
2487 | 2496 |
2488 GrGLenum gPrimitiveType2GLMode[] = { | 2497 GrGLenum gPrimitiveType2GLMode[] = { |
2489 GR_GL_TRIANGLES, | 2498 GR_GL_TRIANGLES, |
2490 GR_GL_TRIANGLE_STRIP, | 2499 GR_GL_TRIANGLE_STRIP, |
2491 GR_GL_TRIANGLE_FAN, | 2500 GR_GL_TRIANGLE_FAN, |
2492 GR_GL_POINTS, | 2501 GR_GL_POINTS, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 stencilSettings, | 2761 stencilSettings, |
2753 GR_GL_FRONT_AND_BACK, | 2762 GR_GL_FRONT_AND_BACK, |
2754 GrStencilSettings::kFront_Face); | 2763 GrStencilSettings::kFront_Face); |
2755 } | 2764 } |
2756 } | 2765 } |
2757 fHWStencilSettings = stencilSettings; | 2766 fHWStencilSettings = stencilSettings; |
2758 } | 2767 } |
2759 } | 2768 } |
2760 | 2769 |
2761 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
ed) { | 2770 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
ed) { |
| 2771 // rt is only optional if useHWAA is false. |
| 2772 SkASSERT(rt || !useHWAA); |
2762 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); | 2773 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
2763 | 2774 |
2764 if (this->glCaps().multisampleDisableSupport()) { | 2775 if (this->glCaps().multisampleDisableSupport()) { |
2765 if (useHWAA) { | 2776 if (useHWAA) { |
2766 if (kYes_TriState != fMSAAEnabled) { | 2777 if (kYes_TriState != fMSAAEnabled) { |
2767 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2778 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
2768 fMSAAEnabled = kYes_TriState; | 2779 fMSAAEnabled = kYes_TriState; |
2769 } | 2780 } |
2770 } else { | 2781 } else { |
2771 if (kNo_TriState != fMSAAEnabled) { | 2782 if (kNo_TriState != fMSAAEnabled) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3061 // clear out the this field so that if a program does use this unit it will
rebind the correct | 3072 // clear out the this field so that if a program does use this unit it will
rebind the correct |
3062 // texture. | 3073 // texture. |
3063 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID; | 3074 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID; |
3064 } | 3075 } |
3065 | 3076 |
3066 // Determines whether glBlitFramebuffer could be used between src and dst. | 3077 // Determines whether glBlitFramebuffer could be used between src and dst. |
3067 static inline bool can_blit_framebuffer(const GrSurface* dst, | 3078 static inline bool can_blit_framebuffer(const GrSurface* dst, |
3068 const GrSurface* src, | 3079 const GrSurface* src, |
3069 const GrGLGpu* gpu) { | 3080 const GrGLGpu* gpu) { |
3070 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && | 3081 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && |
3071 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && | 3082 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0)) { |
3072 gpu->glCaps().usesMSAARenderBuffers()) { | 3083 switch (gpu->glCaps().blitFramebufferSupport()) { |
| 3084 case GrGLCaps::kNone_BlitFramebufferSupport: |
| 3085 return false; |
| 3086 case GrGLCaps::kNoScalingNoMirroring_BlitFramebufferSupport: |
| 3087 // Our copy surface doesn't support scaling so just check for mi
rroring. |
| 3088 if (dst->origin() != src->origin()) { |
| 3089 return false; |
| 3090 } |
| 3091 break; |
| 3092 case GrGLCaps::kFull_BlitFramebufferSupport: |
| 3093 break; |
| 3094 } |
3073 // ES3 doesn't allow framebuffer blits when the src has MSAA and the con
figs don't match | 3095 // ES3 doesn't allow framebuffer blits when the src has MSAA and the con
figs don't match |
3074 // or the rects are not the same (not just the same size but have the sa
me edges). | 3096 // or the rects are not the same (not just the same size but have the sa
me edges). |
3075 if (GrGLCaps::kES_3_0_MSFBOType == gpu->glCaps().msFBOType() && | 3097 if (GrGLCaps::kES_3_0_MSFBOType == gpu->glCaps().msFBOType() && |
3076 (src->desc().fSampleCnt > 0 || src->config() != dst->config())) { | 3098 (src->desc().fSampleCnt > 0 || src->config() != dst->config())) { |
3077 return false; | 3099 return false; |
3078 } | 3100 } |
3079 const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTextu
re()); | 3101 const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTextu
re()); |
3080 if (dstTex && dstTex->target() != GR_GL_TEXTURE_2D) { | 3102 if (dstTex && dstTex->target() != GR_GL_TEXTURE_2D) { |
3081 return false; | 3103 return false; |
3082 } | 3104 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3133 } else { | 3155 } else { |
3134 return false; | 3156 return false; |
3135 } | 3157 } |
3136 } | 3158 } |
3137 | 3159 |
3138 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha
t the copy rect is | 3160 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha
t the copy rect is |
3139 // relative to is output. | 3161 // relative to is output. |
3140 void GrGLGpu::bindSurfaceFBOForCopy(GrSurface* surface, GrGLenum fboTarget, GrGL
IRect* viewport, | 3162 void GrGLGpu::bindSurfaceFBOForCopy(GrSurface* surface, GrGLenum fboTarget, GrGL
IRect* viewport, |
3141 TempFBOTarget tempFBOTarget) { | 3163 TempFBOTarget tempFBOTarget) { |
3142 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge
t()); | 3164 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge
t()); |
3143 if (nullptr == rt) { | 3165 if (!rt) { |
3144 SkASSERT(surface->asTexture()); | 3166 SkASSERT(surface->asTexture()); |
3145 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur
eID(); | 3167 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur
eID(); |
3146 GrGLenum target = static_cast<GrGLTexture*>(surface->asTexture())->targe
t(); | 3168 GrGLenum target = static_cast<GrGLTexture*>(surface->asTexture())->targe
t(); |
3147 GrGLuint* tempFBOID; | 3169 GrGLuint* tempFBOID; |
3148 tempFBOID = kSrc_TempFBOTarget == tempFBOTarget ? &fTempSrcFBOID : &fTem
pDstFBOID; | 3170 tempFBOID = kSrc_TempFBOTarget == tempFBOTarget ? &fTempSrcFBOID : &fTem
pDstFBOID; |
3149 | 3171 |
3150 if (0 == *tempFBOID) { | 3172 if (0 == *tempFBOID) { |
3151 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, tempFBOID)); | 3173 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, tempFBOID)); |
3152 } | 3174 } |
3153 | 3175 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3243 bool GrGLGpu::onCopySurface(GrSurface* dst, | 3265 bool GrGLGpu::onCopySurface(GrSurface* dst, |
3244 GrSurface* src, | 3266 GrSurface* src, |
3245 const SkIRect& srcRect, | 3267 const SkIRect& srcRect, |
3246 const SkIPoint& dstPoint) { | 3268 const SkIPoint& dstPoint) { |
3247 // None of our copy methods can handle a swizzle. TODO: Make copySurfaceAsDr
aw handle the | 3269 // None of our copy methods can handle a swizzle. TODO: Make copySurfaceAsDr
aw handle the |
3248 // swizzle. | 3270 // swizzle. |
3249 if (this->glCaps().glslCaps()->configOutputSwizzle(src->config()) != | 3271 if (this->glCaps().glslCaps()->configOutputSwizzle(src->config()) != |
3250 this->glCaps().glslCaps()->configOutputSwizzle(dst->config())) { | 3272 this->glCaps().glslCaps()->configOutputSwizzle(dst->config())) { |
3251 return false; | 3273 return false; |
3252 } | 3274 } |
3253 if (src->asTexture() && dst->asRenderTarget()) { | 3275 // Don't prefer copying as a draw if the dst doesn't already have a FBO obje
ct. |
| 3276 bool preferCopy = SkToBool(dst->asRenderTarget()); |
| 3277 if (preferCopy && src->asTexture()) { |
3254 this->copySurfaceAsDraw(dst, src, srcRect, dstPoint); | 3278 this->copySurfaceAsDraw(dst, src, srcRect, dstPoint); |
3255 return true; | 3279 return true; |
3256 } | 3280 } |
3257 | 3281 |
3258 if (can_copy_texsubimage(dst, src, this)) { | 3282 if (can_copy_texsubimage(dst, src, this)) { |
3259 this->copySurfaceAsCopyTexSubImage(dst, src, srcRect, dstPoint); | 3283 this->copySurfaceAsCopyTexSubImage(dst, src, srcRect, dstPoint); |
3260 return true; | 3284 return true; |
3261 } | 3285 } |
3262 | 3286 |
3263 if (can_blit_framebuffer(dst, src, this)) { | 3287 if (can_blit_framebuffer(dst, src, this)) { |
3264 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); | 3288 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); |
3265 } | 3289 } |
3266 | 3290 |
| 3291 if (!preferCopy && src->asTexture()) { |
| 3292 this->copySurfaceAsDraw(dst, src, srcRect, dstPoint); |
| 3293 return true; |
| 3294 } |
| 3295 |
3267 return false; | 3296 return false; |
3268 } | 3297 } |
3269 | 3298 |
3270 void GrGLGpu::createCopyPrograms() { | 3299 void GrGLGpu::createCopyPrograms() { |
3271 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 3300 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
3272 fCopyPrograms[i].fProgram = 0; | 3301 fCopyPrograms[i].fProgram = 0; |
3273 } | 3302 } |
3274 const char* version = this->glCaps().glslCaps()->versionDeclString(); | 3303 const char* version = this->glCaps().glslCaps()->versionDeclString(); |
3275 static const GrSLType kSamplerTypes[3] = { kSampler2D_GrSLType, kSamplerExte
rnal_GrSLType, | 3304 static const GrSLType kSamplerTypes[3] = { kSampler2D_GrSLType, kSamplerExte
rnal_GrSLType, |
3276 kSampler2DRect_GrSLType }; | 3305 kSampler2DRect_GrSLType }; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3553 GrSurface* src, | 3582 GrSurface* src, |
3554 const SkIRect& srcRect, | 3583 const SkIRect& srcRect, |
3555 const SkIPoint& dstPoint) { | 3584 const SkIPoint& dstPoint) { |
3556 int w = srcRect.width(); | 3585 int w = srcRect.width(); |
3557 int h = srcRect.height(); | 3586 int h = srcRect.height(); |
3558 | 3587 |
3559 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); | 3588 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); |
3560 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil
terMode); | 3589 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil
terMode); |
3561 this->bindTexture(0, params, srcTex); | 3590 this->bindTexture(0, params, srcTex); |
3562 | 3591 |
3563 GrGLRenderTarget* dstRT = static_cast<GrGLRenderTarget*>(dst->asRenderTarget
()); | 3592 GrGLIRect dstVP; |
| 3593 this->bindSurfaceFBOForCopy(dst, GR_GL_FRAMEBUFFER, &dstVP, kDst_TempFBOTarg
et); |
| 3594 this->flushViewport(dstVP); |
| 3595 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
| 3596 |
3564 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); | 3597 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); |
3565 this->flushRenderTarget(dstRT, &dstRect); | |
3566 | 3598 |
3567 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); | 3599 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); |
3568 | 3600 |
3569 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); | 3601 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); |
3570 fHWProgramID = fCopyPrograms[progIdx].fProgram; | 3602 fHWProgramID = fCopyPrograms[progIdx].fProgram; |
3571 | 3603 |
3572 fHWGeometryState.setVertexArrayID(this, 0); | 3604 fHWGeometryState.setVertexArrayID(this, 0); |
3573 | 3605 |
3574 GrGLAttribArrayState* attribs = | 3606 GrGLAttribArrayState* attribs = |
3575 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer)
; | 3607 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer)
; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3611 GL_CALL(Uniform4f(fCopyPrograms[progIdx].fPosXformUniform, dx1 - dx0, dy1 -
dy0, dx0, dy0)); | 3643 GL_CALL(Uniform4f(fCopyPrograms[progIdx].fPosXformUniform, dx1 - dx0, dy1 -
dy0, dx0, dy0)); |
3612 GL_CALL(Uniform4f(fCopyPrograms[progIdx].fTexCoordXformUniform, | 3644 GL_CALL(Uniform4f(fCopyPrograms[progIdx].fTexCoordXformUniform, |
3613 sx1 - sx0, sy1 - sy0, sx0, sy0)); | 3645 sx1 - sx0, sy1 - sy0, sx0, sy0)); |
3614 GL_CALL(Uniform1i(fCopyPrograms[progIdx].fTextureUniform, 0)); | 3646 GL_CALL(Uniform1i(fCopyPrograms[progIdx].fTextureUniform, 0)); |
3615 | 3647 |
3616 GrXferProcessor::BlendInfo blendInfo; | 3648 GrXferProcessor::BlendInfo blendInfo; |
3617 blendInfo.reset(); | 3649 blendInfo.reset(); |
3618 this->flushBlend(blendInfo, GrSwizzle::RGBA()); | 3650 this->flushBlend(blendInfo, GrSwizzle::RGBA()); |
3619 this->flushColorWrite(true); | 3651 this->flushColorWrite(true); |
3620 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 3652 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
3621 this->flushHWAAState(dstRT, false, false); | 3653 this->flushHWAAState(nullptr, false, false); |
3622 this->disableScissor(); | 3654 this->disableScissor(); |
3623 GrStencilSettings stencil; | 3655 GrStencilSettings stencil; |
3624 stencil.setDisabled(); | 3656 stencil.setDisabled(); |
3625 this->flushStencil(stencil); | 3657 this->flushStencil(stencil); |
3626 | 3658 |
3627 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); | 3659 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); |
| 3660 this->unbindTextureFBOForCopy(GR_GL_FRAMEBUFFER, dst); |
| 3661 this->didWriteToSurface(dst, &dstRect); |
| 3662 |
3628 } | 3663 } |
3629 | 3664 |
3630 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, | 3665 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, |
3631 GrSurface* src, | 3666 GrSurface* src, |
3632 const SkIRect& srcRect, | 3667 const SkIRect& srcRect, |
3633 const SkIPoint& dstPoint) { | 3668 const SkIPoint& dstPoint) { |
3634 SkASSERT(can_copy_texsubimage(dst, src, this)); | 3669 SkASSERT(can_copy_texsubimage(dst, src, this)); |
3635 GrGLIRect srcVP; | 3670 GrGLIRect srcVP; |
3636 this->bindSurfaceFBOForCopy(src, GR_GL_FRAMEBUFFER, &srcVP, kSrc_TempFBOTarg
et); | 3671 this->bindSurfaceFBOForCopy(src, GR_GL_FRAMEBUFFER, &srcVP, kSrc_TempFBOTarg
et); |
3637 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); | 3672 GrGLTexture* dstTex = static_cast<GrGLTexture *>(dst->asTexture()); |
3638 SkASSERT(dstTex); | 3673 SkASSERT(dstTex); |
3639 // We modified the bound FBO | 3674 // We modified the bound FBO |
3640 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 3675 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
3641 GrGLIRect srcGLRect; | 3676 GrGLIRect srcGLRect; |
3642 srcGLRect.setRelativeTo(srcVP, | 3677 srcGLRect.setRelativeTo(srcVP, |
3643 srcRect.fLeft, | 3678 srcRect.fLeft, |
3644 srcRect.fTop, | 3679 srcRect.fTop, |
3645 srcRect.width(), | 3680 srcRect.width(), |
3646 srcRect.height(), | 3681 srcRect.height(), |
3647 src->origin()); | 3682 src->origin()); |
3648 | 3683 |
3649 this->setScratchTextureUnit(); | 3684 this->setScratchTextureUnit(); |
3650 GL_CALL(BindTexture(dstTex->target(), dstTex->textureID())); | 3685 GL_CALL(BindTexture(dstTex->target(), dstTex->textureID())); |
3651 GrGLint dstY; | 3686 GrGLint dstY; |
3652 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { | 3687 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { |
3653 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight); | 3688 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight); |
3654 } else { | 3689 } else { |
3655 dstY = dstPoint.fY; | 3690 dstY = dstPoint.fY; |
3656 } | 3691 } |
3657 GL_CALL(CopyTexSubImage2D(dstTex->target(), 0, | 3692 GL_CALL(CopyTexSubImage2D(dstTex->target(), 0, |
3658 dstPoint.fX, dstY, | 3693 dstPoint.fX, dstY, |
3659 srcGLRect.fLeft, srcGLRect.fBottom, | 3694 srcGLRect.fLeft, srcGLRect.fBottom, |
3660 srcGLRect.fWidth, srcGLRect.fHeight)); | 3695 srcGLRect.fWidth, srcGLRect.fHeight)); |
3661 this->unbindTextureFBOForCopy(GR_GL_FRAMEBUFFER, src); | 3696 this->unbindTextureFBOForCopy(GR_GL_FRAMEBUFFER, src); |
| 3697 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, |
| 3698 srcRect.width(), srcRect.height()); |
| 3699 this->didWriteToSurface(dst, &dstRect); |
3662 } | 3700 } |
3663 | 3701 |
3664 bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst, | 3702 bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst, |
3665 GrSurface* src, | 3703 GrSurface* src, |
3666 const SkIRect& srcRect, | 3704 const SkIRect& srcRect, |
3667 const SkIPoint& dstPoint) { | 3705 const SkIPoint& dstPoint) { |
3668 SkASSERT(can_blit_framebuffer(dst, src, this)); | 3706 SkASSERT(can_blit_framebuffer(dst, src, this)); |
3669 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, | 3707 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, |
3670 srcRect.width(), srcRect.height()); | 3708 srcRect.width(), srcRect.height()); |
3671 if (dst == src) { | 3709 if (dst == src) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3712 srcY0, | 3750 srcY0, |
3713 srcGLRect.fLeft + srcGLRect.fWidth, | 3751 srcGLRect.fLeft + srcGLRect.fWidth, |
3714 srcY1, | 3752 srcY1, |
3715 dstGLRect.fLeft, | 3753 dstGLRect.fLeft, |
3716 dstGLRect.fBottom, | 3754 dstGLRect.fBottom, |
3717 dstGLRect.fLeft + dstGLRect.fWidth, | 3755 dstGLRect.fLeft + dstGLRect.fWidth, |
3718 dstGLRect.fBottom + dstGLRect.fHeight, | 3756 dstGLRect.fBottom + dstGLRect.fHeight, |
3719 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); | 3757 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); |
3720 this->unbindTextureFBOForCopy(GR_GL_DRAW_FRAMEBUFFER, dst); | 3758 this->unbindTextureFBOForCopy(GR_GL_DRAW_FRAMEBUFFER, dst); |
3721 this->unbindTextureFBOForCopy(GR_GL_READ_FRAMEBUFFER, src); | 3759 this->unbindTextureFBOForCopy(GR_GL_READ_FRAMEBUFFER, src); |
| 3760 this->didWriteToSurface(dst, &dstRect); |
3722 return true; | 3761 return true; |
3723 } | 3762 } |
3724 | 3763 |
3725 void GrGLGpu::xferBarrier(GrRenderTarget* rt, GrXferBarrierType type) { | 3764 void GrGLGpu::xferBarrier(GrRenderTarget* rt, GrXferBarrierType type) { |
3726 SkASSERT(type); | 3765 SkASSERT(type); |
3727 switch (type) { | 3766 switch (type) { |
3728 case kTexture_GrXferBarrierType: { | 3767 case kTexture_GrXferBarrierType: { |
3729 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt); | 3768 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt); |
3730 if (glrt->textureFBOID() != glrt->renderFBOID()) { | 3769 if (glrt->textureFBOID() != glrt->renderFBOID()) { |
3731 // The render target uses separate storage so no need for glText
ureBarrier. | 3770 // The render target uses separate storage so no need for glText
ureBarrier. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3891 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 3930 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
3892 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 3931 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
3893 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 3932 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
3894 copyParams->fWidth = texture->width(); | 3933 copyParams->fWidth = texture->width(); |
3895 copyParams->fHeight = texture->height(); | 3934 copyParams->fHeight = texture->height(); |
3896 return true; | 3935 return true; |
3897 } | 3936 } |
3898 } | 3937 } |
3899 return false; | 3938 return false; |
3900 } | 3939 } |
OLD | NEW |