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 "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 GR_STATIC_ASSERT(kTotalGrBlendCoeffCount == | 111 GR_STATIC_ASSERT(kTotalGrBlendCoeffCount == |
112 SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); | 112 SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); |
113 } | 113 } |
114 | 114 |
115 /////////////////////////////////////////////////////////////////////////////// | 115 /////////////////////////////////////////////////////////////////////////////// |
116 | 116 |
117 static bool gPrintStartupSpew; | 117 static bool gPrintStartupSpew; |
118 | 118 |
119 GrGLGpu::GrGLGpu(const GrGLContext& ctx, GrContext* context) | 119 GrGLGpu::GrGLGpu(const GrGLContext& ctx, GrContext* context) |
120 : GrGpu(context) | 120 : GrGpu(context) |
121 , fGLContext(ctx) { | 121 , fGLContext(ctx) |
| 122 , fTempSrcFBO(this) |
| 123 , fTempDstFBO(this) { |
122 | 124 |
123 SkASSERT(ctx.isInitialized()); | 125 SkASSERT(ctx.isInitialized()); |
124 fCaps.reset(SkRef(ctx.caps())); | 126 fCaps.reset(SkRef(ctx.caps())); |
125 | 127 |
126 fHWBoundTextureUniqueIDs.reset(this->glCaps().maxFragmentTextureUnits()); | 128 fHWBoundTextureUniqueIDs.reset(this->glCaps().maxFragmentTextureUnits()); |
127 | 129 |
128 GrGLClearErr(fGLContext.interface()); | 130 GrGLClearErr(fGLContext.interface()); |
129 if (gPrintStartupSpew) { | 131 if (gPrintStartupSpew) { |
130 const GrGLubyte* vendor; | 132 const GrGLubyte* vendor; |
131 const GrGLubyte* renderer; | 133 const GrGLubyte* renderer; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 GL_CALL(UseProgram(0)); | 166 GL_CALL(UseProgram(0)); |
165 } | 167 } |
166 | 168 |
167 delete fProgramCache; | 169 delete fProgramCache; |
168 } | 170 } |
169 | 171 |
170 void GrGLGpu::contextAbandoned() { | 172 void GrGLGpu::contextAbandoned() { |
171 INHERITED::contextAbandoned(); | 173 INHERITED::contextAbandoned(); |
172 fProgramCache->abandon(); | 174 fProgramCache->abandon(); |
173 fHWProgramID = 0; | 175 fHWProgramID = 0; |
| 176 fTempSrcFBO.reset(); |
| 177 fTempDstFBO.reset(); |
174 if (this->glCaps().pathRenderingSupport()) { | 178 if (this->glCaps().pathRenderingSupport()) { |
175 this->glPathRendering()->abandonGpuResources(); | 179 this->glPathRendering()->abandonGpuResources(); |
176 } | 180 } |
177 } | 181 } |
178 | 182 |
179 /////////////////////////////////////////////////////////////////////////////// | 183 /////////////////////////////////////////////////////////////////////////////// |
180 GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig, | 184 GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig, |
181 GrPixelConfig surfaceConfig) co
nst { | 185 GrPixelConfig surfaceConfig) co
nst { |
182 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { | 186 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { |
183 return kBGRA_8888_GrPixelConfig; | 187 return kBGRA_8888_GrPixelConfig; |
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 } | 2449 } |
2446 // clear out the this field so that if a program does use this unit it will
rebind the correct | 2450 // clear out the this field so that if a program does use this unit it will
rebind the correct |
2447 // texture. | 2451 // texture. |
2448 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID; | 2452 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID; |
2449 } | 2453 } |
2450 | 2454 |
2451 namespace { | 2455 namespace { |
2452 // Determines whether glBlitFramebuffer could be used between src and dst. | 2456 // Determines whether glBlitFramebuffer could be used between src and dst. |
2453 inline bool can_blit_framebuffer(const GrSurface* dst, | 2457 inline bool can_blit_framebuffer(const GrSurface* dst, |
2454 const GrSurface* src, | 2458 const GrSurface* src, |
2455 const GrGLGpu* gpu, | 2459 const GrGLGpu* gpu) { |
2456 bool* wouldNeedTempFBO = NULL) { | |
2457 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && | 2460 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && |
2458 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && | 2461 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && |
2459 gpu->glCaps().usesMSAARenderBuffers()) { | 2462 gpu->glCaps().usesMSAARenderBuffers()) { |
2460 // ES3 doesn't allow framebuffer blits when the src has MSAA and the con
figs don't match | 2463 // ES3 doesn't allow framebuffer blits when the src has MSAA and the con
figs don't match |
2461 // or the rects are not the same (not just the same size but have the sa
me edges). | 2464 // or the rects are not the same (not just the same size but have the sa
me edges). |
2462 if (GrGLCaps::kES_3_0_MSFBOType == gpu->glCaps().msFBOType() && | 2465 if (GrGLCaps::kES_3_0_MSFBOType == gpu->glCaps().msFBOType() && |
2463 (src->desc().fSampleCnt > 0 || src->config() != dst->config())) { | 2466 (src->desc().fSampleCnt > 0 || src->config() != dst->config())) { |
2464 return false; | 2467 return false; |
2465 } | 2468 } |
2466 if (wouldNeedTempFBO) { | |
2467 *wouldNeedTempFBO = NULL == dst->asRenderTarget() || NULL == src->as
RenderTarget(); | |
2468 } | |
2469 return true; | 2469 return true; |
2470 } else { | 2470 } else { |
2471 return false; | 2471 return false; |
2472 } | 2472 } |
2473 } | 2473 } |
2474 | 2474 |
2475 inline bool can_copy_texsubimage(const GrSurface* dst, | 2475 inline bool can_copy_texsubimage(const GrSurface* dst, |
2476 const GrSurface* src, | 2476 const GrSurface* src, |
2477 const GrGLGpu* gpu, | 2477 const GrGLGpu* gpu) { |
2478 bool* wouldNeedTempFBO = NULL) { | |
2479 // Table 3.9 of the ES2 spec indicates the supported formats with CopyTexSub
Image | 2478 // Table 3.9 of the ES2 spec indicates the supported formats with CopyTexSub
Image |
2480 // and BGRA isn't in the spec. There doesn't appear to be any extension that
adds it. Perhaps | 2479 // and BGRA isn't in the spec. There doesn't appear to be any extension that
adds it. Perhaps |
2481 // many drivers would allow it to work, but ANGLE does not. | 2480 // many drivers would allow it to work, but ANGLE does not. |
2482 if (kGLES_GrGLStandard == gpu->glStandard() && gpu->glCaps().bgraIsInternalF
ormat() && | 2481 if (kGLES_GrGLStandard == gpu->glStandard() && gpu->glCaps().bgraIsInternalF
ormat() && |
2483 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig =
= src->config())) { | 2482 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig =
= src->config())) { |
2484 return false; | 2483 return false; |
2485 } | 2484 } |
2486 const GrGLRenderTarget* dstRT = static_cast<const GrGLRenderTarget*>(dst->as
RenderTarget()); | 2485 const GrGLRenderTarget* dstRT = static_cast<const GrGLRenderTarget*>(dst->as
RenderTarget()); |
2487 // If dst is multisampled (and uses an extension where there is a separate M
SAA renderbuffer) | 2486 // If dst is multisampled (and uses an extension where there is a separate M
SAA renderbuffer) |
2488 // then we don't want to copy to the texture but to the MSAA buffer. | 2487 // then we don't want to copy to the texture but to the MSAA buffer. |
2489 if (dstRT && dstRT->renderFBOID() != dstRT->textureFBOID()) { | 2488 if (dstRT && dstRT->renderFBOID() != dstRT->textureFBOID()) { |
2490 return false; | 2489 return false; |
2491 } | 2490 } |
2492 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as
RenderTarget()); | 2491 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as
RenderTarget()); |
2493 // If the src is multisampled (and uses an extension where there is a separa
te MSAA | 2492 // If the src is multisampled (and uses an extension where there is a separa
te MSAA |
2494 // renderbuffer) then it is an invalid operation to call CopyTexSubImage | 2493 // renderbuffer) then it is an invalid operation to call CopyTexSubImage |
2495 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { | 2494 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { |
2496 return false; | 2495 return false; |
2497 } | 2496 } |
2498 if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && | 2497 if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && |
2499 dst->asTexture() && | 2498 dst->asTexture() && |
2500 dst->origin() == src->origin() && | 2499 dst->origin() == src->origin() && |
2501 !GrPixelConfigIsCompressed(src->config())) { | 2500 !GrPixelConfigIsCompressed(src->config())) { |
2502 if (wouldNeedTempFBO) { | |
2503 *wouldNeedTempFBO = NULL == src->asRenderTarget(); | |
2504 } | |
2505 return true; | 2501 return true; |
2506 } else { | 2502 } else { |
2507 return false; | 2503 return false; |
2508 } | 2504 } |
2509 } | 2505 } |
2510 | 2506 |
2511 } | 2507 } |
2512 | 2508 |
2513 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha
t the copy rect is | 2509 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha
t the copy rect is |
2514 // relative to is output. | 2510 // relative to is output. |
2515 GrGLuint GrGLGpu::bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLI
Rect* viewport) { | 2511 GrGLuint GrGLGpu::bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLI
Rect* viewport, |
| 2512 TempFBOTarget tempFBOTarget) { |
2516 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge
t()); | 2513 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge
t()); |
2517 GrGLuint tempFBOID; | 2514 GrGLuint tempFBOID; |
2518 if (NULL == rt) { | 2515 if (NULL == rt) { |
2519 SkASSERT(surface->asTexture()); | 2516 SkASSERT(surface->asTexture()); |
2520 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur
eID(); | 2517 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur
eID(); |
2521 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, &tempFBOID)); | 2518 TempFBO* tempFBO = kSrc_TempFBOTarget == tempFBOTarget ? &fTempSrcFBO :
&fTempDstFBO; |
| 2519 |
| 2520 if (0 == tempFBO->fID) { |
| 2521 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, &tempFBO->fID)); |
| 2522 } |
| 2523 |
2522 fGPUStats.incRenderTargetBinds(); | 2524 fGPUStats.incRenderTargetBinds(); |
2523 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, tempFBOID)); | 2525 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, tempFBO->fID)
); |
2524 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget, | 2526 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget, |
2525 GR_GL_COLOR_ATTACHM
ENT0, | 2527 GR_GL_COLOR_ATTACHM
ENT0, |
2526 GR_GL_TEXTURE_2D, | 2528 GR_GL_TEXTURE_2D, |
2527 texID, | 2529 texID, |
2528 0)); | 2530 0)); |
2529 viewport->fLeft = 0; | 2531 viewport->fLeft = 0; |
2530 viewport->fBottom = 0; | 2532 viewport->fBottom = 0; |
2531 viewport->fWidth = surface->width(); | 2533 viewport->fWidth = surface->width(); |
2532 viewport->fHeight = surface->height(); | 2534 viewport->fHeight = surface->height(); |
2533 } else { | 2535 } else { |
2534 tempFBOID = 0; | 2536 tempFBOID = 0; |
2535 fGPUStats.incRenderTargetBinds(); | 2537 fGPUStats.incRenderTargetBinds(); |
2536 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO
ID())); | 2538 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO
ID())); |
2537 *viewport = rt->getViewport(); | 2539 *viewport = rt->getViewport(); |
2538 } | 2540 } |
2539 return tempFBOID; | 2541 return tempFBOID; |
2540 } | 2542 } |
2541 | 2543 |
| 2544 void GrGLGpu::unbindTextureFromFBO(GrGLenum fboTarget) { |
| 2545 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget, |
| 2546 GR_GL_COLOR_ATTACHMENT0
, |
| 2547 GR_GL_TEXTURE_2D, |
| 2548 0, |
| 2549 0)); |
| 2550 } |
| 2551 |
2542 bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc)
{ | 2552 bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc)
{ |
2543 // In here we look for opportunities to use CopyTexSubImage, or fbo blit. If
neither are | 2553 // In here we look for opportunities to use CopyTexSubImage, or fbo blit. If
neither are |
2544 // possible and we return false to fallback to creating a render target dst
for render-to- | 2554 // possible and we return false to fallback to creating a render target dst
for render-to- |
2545 // texture. This code prefers CopyTexSubImage to fbo blit and avoids trigger
ing temporary fbo | 2555 // texture. This code prefers CopyTexSubImage to fbo blit and avoids trigger
ing temporary fbo |
2546 // creation. It isn't clear that avoiding temporary fbo creation is actually
optimal. | 2556 // creation. It isn't clear that avoiding temporary fbo creation is actually
optimal. |
2547 | 2557 |
2548 // Check for format issues with glCopyTexSubImage2D | 2558 // Check for format issues with glCopyTexSubImage2D |
2549 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna
lFormat() && | 2559 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna
lFormat() && |
2550 kBGRA_8888_GrPixelConfig == src->config()) { | 2560 kBGRA_8888_GrPixelConfig == src->config()) { |
2551 // glCopyTexSubImage2D doesn't work with this config. If the bgra can be
used with fbo blit | 2561 // glCopyTexSubImage2D doesn't work with this config. If the bgra can be
used with fbo blit |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2583 } | 2593 } |
2584 | 2594 |
2585 bool GrGLGpu::copySurface(GrSurface* dst, | 2595 bool GrGLGpu::copySurface(GrSurface* dst, |
2586 GrSurface* src, | 2596 GrSurface* src, |
2587 const SkIRect& srcRect, | 2597 const SkIRect& srcRect, |
2588 const SkIPoint& dstPoint) { | 2598 const SkIPoint& dstPoint) { |
2589 bool copied = false; | 2599 bool copied = false; |
2590 if (can_copy_texsubimage(dst, src, this)) { | 2600 if (can_copy_texsubimage(dst, src, this)) { |
2591 GrGLuint srcFBO; | 2601 GrGLuint srcFBO; |
2592 GrGLIRect srcVP; | 2602 GrGLIRect srcVP; |
2593 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_FRAMEBUFFER, &srcVP); | 2603 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_FRAMEBUFFER, &srcVP, kSrc_Tem
pFBOTarget); |
2594 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); | 2604 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); |
2595 SkASSERT(dstTex); | 2605 SkASSERT(dstTex); |
2596 // We modified the bound FBO | 2606 // We modified the bound FBO |
2597 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 2607 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
2598 GrGLIRect srcGLRect; | 2608 GrGLIRect srcGLRect; |
2599 srcGLRect.setRelativeTo(srcVP, | 2609 srcGLRect.setRelativeTo(srcVP, |
2600 srcRect.fLeft, | 2610 srcRect.fLeft, |
2601 srcRect.fTop, | 2611 srcRect.fTop, |
2602 srcRect.width(), | 2612 srcRect.width(), |
2603 srcRect.height(), | 2613 srcRect.height(), |
2604 src->origin()); | 2614 src->origin()); |
2605 | 2615 |
2606 this->setScratchTextureUnit(); | 2616 this->setScratchTextureUnit(); |
2607 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); | 2617 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); |
2608 GrGLint dstY; | 2618 GrGLint dstY; |
2609 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { | 2619 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { |
2610 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight); | 2620 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight); |
2611 } else { | 2621 } else { |
2612 dstY = dstPoint.fY; | 2622 dstY = dstPoint.fY; |
2613 } | 2623 } |
2614 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0, | 2624 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0, |
2615 dstPoint.fX, dstY, | 2625 dstPoint.fX, dstY, |
2616 srcGLRect.fLeft, srcGLRect.fBottom, | 2626 srcGLRect.fLeft, srcGLRect.fBottom, |
2617 srcGLRect.fWidth, srcGLRect.fHeight)); | 2627 srcGLRect.fWidth, srcGLRect.fHeight)); |
2618 copied = true; | 2628 copied = true; |
2619 if (srcFBO) { | 2629 if (srcFBO) { |
2620 GL_CALL(DeleteFramebuffers(1, &srcFBO)); | 2630 this->unbindTextureFromFBO(GR_GL_FRAMEBUFFER); |
2621 } | 2631 } |
2622 } else if (can_blit_framebuffer(dst, src, this)) { | 2632 } else if (can_blit_framebuffer(dst, src, this)) { |
2623 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, | 2633 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, |
2624 srcRect.width(), srcRect.height()); | 2634 srcRect.width(), srcRect.height()); |
2625 bool selfOverlap = false; | 2635 bool selfOverlap = false; |
2626 if (dst == src) { | 2636 if (dst == src) { |
2627 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); | 2637 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); |
2628 } | 2638 } |
2629 | 2639 |
2630 if (!selfOverlap) { | 2640 if (!selfOverlap) { |
2631 GrGLuint dstFBO; | 2641 GrGLuint dstFBO; |
2632 GrGLuint srcFBO; | 2642 GrGLuint srcFBO; |
2633 GrGLIRect dstVP; | 2643 GrGLIRect dstVP; |
2634 GrGLIRect srcVP; | 2644 GrGLIRect srcVP; |
2635 dstFBO = this->bindSurfaceAsFBO(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP)
; | 2645 dstFBO = this->bindSurfaceAsFBO(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP, |
2636 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_READ_FRAMEBUFFER, &srcVP)
; | 2646 kDst_TempFBOTarget); |
| 2647 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_READ_FRAMEBUFFER, &srcVP, |
| 2648 kSrc_TempFBOTarget); |
2637 // We modified the bound FBO | 2649 // We modified the bound FBO |
2638 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 2650 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
2639 GrGLIRect srcGLRect; | 2651 GrGLIRect srcGLRect; |
2640 GrGLIRect dstGLRect; | 2652 GrGLIRect dstGLRect; |
2641 srcGLRect.setRelativeTo(srcVP, | 2653 srcGLRect.setRelativeTo(srcVP, |
2642 srcRect.fLeft, | 2654 srcRect.fLeft, |
2643 srcRect.fTop, | 2655 srcRect.fTop, |
2644 srcRect.width(), | 2656 srcRect.width(), |
2645 srcRect.height(), | 2657 srcRect.height(), |
2646 src->origin()); | 2658 src->origin()); |
(...skipping 20 matching lines...) Expand all Loading... |
2667 GL_CALL(BlitFramebuffer(srcGLRect.fLeft, | 2679 GL_CALL(BlitFramebuffer(srcGLRect.fLeft, |
2668 srcY0, | 2680 srcY0, |
2669 srcGLRect.fLeft + srcGLRect.fWidth, | 2681 srcGLRect.fLeft + srcGLRect.fWidth, |
2670 srcY1, | 2682 srcY1, |
2671 dstGLRect.fLeft, | 2683 dstGLRect.fLeft, |
2672 dstGLRect.fBottom, | 2684 dstGLRect.fBottom, |
2673 dstGLRect.fLeft + dstGLRect.fWidth, | 2685 dstGLRect.fLeft + dstGLRect.fWidth, |
2674 dstGLRect.fBottom + dstGLRect.fHeight, | 2686 dstGLRect.fBottom + dstGLRect.fHeight, |
2675 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); | 2687 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); |
2676 if (dstFBO) { | 2688 if (dstFBO) { |
2677 GL_CALL(DeleteFramebuffers(1, &dstFBO)); | 2689 this->unbindTextureFromFBO(GR_GL_DRAW_FRAMEBUFFER); |
2678 } | 2690 } |
2679 if (srcFBO) { | 2691 if (srcFBO) { |
2680 GL_CALL(DeleteFramebuffers(1, &srcFBO)); | 2692 this->unbindTextureFromFBO(GR_GL_READ_FRAMEBUFFER); |
2681 } | 2693 } |
2682 copied = true; | 2694 copied = true; |
2683 } | 2695 } |
2684 } | 2696 } |
2685 return copied; | 2697 return copied; |
2686 } | 2698 } |
2687 | 2699 |
2688 bool GrGLGpu::canCopySurface(const GrSurface* dst, | 2700 bool GrGLGpu::canCopySurface(const GrSurface* dst, |
2689 const GrSurface* src, | 2701 const GrSurface* src, |
2690 const SkIRect& srcRect, | 2702 const SkIRect& srcRect, |
2691 const SkIPoint& dstPoint) { | 2703 const SkIPoint& dstPoint) { |
2692 // This mirrors the logic in onCopySurface. We prefer our base makes the co
py if we need to | 2704 // This mirrors the logic in onCopySurface. |
2693 // create a temp fbo. TODO verify the assumption that temp fbos are expensiv
e; it may not be | 2705 if (can_copy_texsubimage(dst, src, this)) { |
2694 // true at all. | |
2695 bool wouldNeedTempFBO = false; | |
2696 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTem
pFBO) { | |
2697 return true; | 2706 return true; |
2698 } | 2707 } |
2699 if (can_blit_framebuffer(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTem
pFBO) { | 2708 if (can_blit_framebuffer(dst, src, this)) { |
2700 if (dst == src) { | 2709 if (dst == src) { |
2701 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, | 2710 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, |
2702 srcRect.width(), srcRect.height(
)); | 2711 srcRect.width(), srcRect.height(
)); |
2703 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) { | 2712 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) { |
2704 return true; | 2713 return true; |
2705 } | 2714 } |
2706 } else { | 2715 } else { |
2707 return true; | 2716 return true; |
2708 } | 2717 } |
2709 } | 2718 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2750 this->setVertexArrayID(gpu, 0); | 2759 this->setVertexArrayID(gpu, 0); |
2751 } | 2760 } |
2752 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2761 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2753 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2762 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2754 fDefaultVertexArrayAttribState.resize(attrCount); | 2763 fDefaultVertexArrayAttribState.resize(attrCount); |
2755 } | 2764 } |
2756 attribState = &fDefaultVertexArrayAttribState; | 2765 attribState = &fDefaultVertexArrayAttribState; |
2757 } | 2766 } |
2758 return attribState; | 2767 return attribState; |
2759 } | 2768 } |
OLD | NEW |