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

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 893703003: Save and temp dst and src FBO on GrGLGpu and use the temp FBOs for copySurface if needed. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Nit Created 5 years, 10 months 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/GrGLGpu.h ('k') | no next file » | 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 "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 SkDebugf("\n"); 143 SkDebugf("\n");
144 SkDebugf(this->glCaps().dump().c_str()); 144 SkDebugf(this->glCaps().dump().c_str());
145 } 145 }
146 146
147 fProgramCache = SkNEW_ARGS(ProgramCache, (this)); 147 fProgramCache = SkNEW_ARGS(ProgramCache, (this));
148 148
149 SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVe rtexAttribs); 149 SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVe rtexAttribs);
150 150
151 fLastSuccessfulStencilFmtIdx = 0; 151 fLastSuccessfulStencilFmtIdx = 0;
152 fHWProgramID = 0; 152 fHWProgramID = 0;
153 fTempSrcFBOID = 0;
154 fTempDstFBOID = 0;
153 155
154 if (this->glCaps().pathRenderingSupport()) { 156 if (this->glCaps().pathRenderingSupport()) {
155 fPathRendering.reset(new GrGLPathRendering(this)); 157 fPathRendering.reset(new GrGLPathRendering(this));
156 } 158 }
157 } 159 }
158 160
159 GrGLGpu::~GrGLGpu() { 161 GrGLGpu::~GrGLGpu() {
160 if (0 != fHWProgramID) { 162 if (0 != fHWProgramID) {
161 // detach the current program so there is no confusion on OpenGL's part 163 // detach the current program so there is no confusion on OpenGL's part
162 // that we want it to be deleted 164 // that we want it to be deleted
163 SkASSERT(fHWProgramID == fCurrentProgram->programID()); 165 SkASSERT(fHWProgramID == fCurrentProgram->programID());
164 GL_CALL(UseProgram(0)); 166 GL_CALL(UseProgram(0));
165 } 167 }
166 168
169 if (0 != fTempSrcFBOID) {
170 GL_CALL(DeleteFramebuffers(1, &fTempSrcFBOID));
171 }
172 if (0 != fTempDstFBOID) {
173 GL_CALL(DeleteFramebuffers(1, &fTempDstFBOID));
174 }
175
167 delete fProgramCache; 176 delete fProgramCache;
168 } 177 }
169 178
170 void GrGLGpu::contextAbandoned() { 179 void GrGLGpu::contextAbandoned() {
171 INHERITED::contextAbandoned(); 180 INHERITED::contextAbandoned();
172 fProgramCache->abandon(); 181 fProgramCache->abandon();
173 fHWProgramID = 0; 182 fHWProgramID = 0;
183 fTempSrcFBOID = 0;
184 fTempDstFBOID = 0;
174 if (this->glCaps().pathRenderingSupport()) { 185 if (this->glCaps().pathRenderingSupport()) {
175 this->glPathRendering()->abandonGpuResources(); 186 this->glPathRendering()->abandonGpuResources();
176 } 187 }
177 } 188 }
178 189
179 /////////////////////////////////////////////////////////////////////////////// 190 ///////////////////////////////////////////////////////////////////////////////
180 GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig, 191 GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig,
181 GrPixelConfig surfaceConfig) co nst { 192 GrPixelConfig surfaceConfig) co nst {
182 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig ) { 193 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig ) {
183 return kBGRA_8888_GrPixelConfig; 194 return kBGRA_8888_GrPixelConfig;
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 } 2456 }
2446 // clear out the this field so that if a program does use this unit it will rebind the correct 2457 // clear out the this field so that if a program does use this unit it will rebind the correct
2447 // texture. 2458 // texture.
2448 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID; 2459 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID;
2449 } 2460 }
2450 2461
2451 namespace { 2462 namespace {
2452 // Determines whether glBlitFramebuffer could be used between src and dst. 2463 // Determines whether glBlitFramebuffer could be used between src and dst.
2453 inline bool can_blit_framebuffer(const GrSurface* dst, 2464 inline bool can_blit_framebuffer(const GrSurface* dst,
2454 const GrSurface* src, 2465 const GrSurface* src,
2455 const GrGLGpu* gpu, 2466 const GrGLGpu* gpu) {
2456 bool* wouldNeedTempFBO = NULL) {
2457 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt > 0) && 2467 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt > 0) &&
2458 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt > 0) && 2468 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt > 0) &&
2459 gpu->glCaps().usesMSAARenderBuffers()) { 2469 gpu->glCaps().usesMSAARenderBuffers()) {
2460 // ES3 doesn't allow framebuffer blits when the src has MSAA and the con figs don't match 2470 // 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). 2471 // 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() && 2472 if (GrGLCaps::kES_3_0_MSFBOType == gpu->glCaps().msFBOType() &&
2463 (src->desc().fSampleCnt > 0 || src->config() != dst->config())) { 2473 (src->desc().fSampleCnt > 0 || src->config() != dst->config())) {
2464 return false; 2474 return false;
2465 } 2475 }
2466 if (wouldNeedTempFBO) {
2467 *wouldNeedTempFBO = NULL == dst->asRenderTarget() || NULL == src->as RenderTarget();
2468 }
2469 return true; 2476 return true;
2470 } else { 2477 } else {
2471 return false; 2478 return false;
2472 } 2479 }
2473 } 2480 }
2474 2481
2475 inline bool can_copy_texsubimage(const GrSurface* dst, 2482 inline bool can_copy_texsubimage(const GrSurface* dst,
2476 const GrSurface* src, 2483 const GrSurface* src,
2477 const GrGLGpu* gpu, 2484 const GrGLGpu* gpu) {
2478 bool* wouldNeedTempFBO = NULL) {
2479 // Table 3.9 of the ES2 spec indicates the supported formats with CopyTexSub Image 2485 // 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 2486 // 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. 2487 // many drivers would allow it to work, but ANGLE does not.
2482 if (kGLES_GrGLStandard == gpu->glStandard() && gpu->glCaps().bgraIsInternalF ormat() && 2488 if (kGLES_GrGLStandard == gpu->glStandard() && gpu->glCaps().bgraIsInternalF ormat() &&
2483 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig = = src->config())) { 2489 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig = = src->config())) {
2484 return false; 2490 return false;
2485 } 2491 }
2486 const GrGLRenderTarget* dstRT = static_cast<const GrGLRenderTarget*>(dst->as RenderTarget()); 2492 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) 2493 // 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. 2494 // then we don't want to copy to the texture but to the MSAA buffer.
2489 if (dstRT && dstRT->renderFBOID() != dstRT->textureFBOID()) { 2495 if (dstRT && dstRT->renderFBOID() != dstRT->textureFBOID()) {
2490 return false; 2496 return false;
2491 } 2497 }
2492 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget()); 2498 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 2499 // 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 2500 // renderbuffer) then it is an invalid operation to call CopyTexSubImage
2495 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { 2501 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) {
2496 return false; 2502 return false;
2497 } 2503 }
2498 if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt > 0) && 2504 if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt > 0) &&
2499 dst->asTexture() && 2505 dst->asTexture() &&
2500 dst->origin() == src->origin() && 2506 dst->origin() == src->origin() &&
2501 !GrPixelConfigIsCompressed(src->config())) { 2507 !GrPixelConfigIsCompressed(src->config())) {
2502 if (wouldNeedTempFBO) {
2503 *wouldNeedTempFBO = NULL == src->asRenderTarget();
2504 }
2505 return true; 2508 return true;
2506 } else { 2509 } else {
2507 return false; 2510 return false;
2508 } 2511 }
2509 } 2512 }
2510 2513
2511 } 2514 }
2512 2515
2513 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha t the copy rect is 2516 // 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. 2517 // relative to is output.
2515 GrGLuint GrGLGpu::bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLI Rect* viewport) { 2518 GrGLuint GrGLGpu::bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLI Rect* viewport,
2519 TempFBOTarget tempFBOTarget) {
2516 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge t()); 2520 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge t());
2517 GrGLuint tempFBOID;
2518 if (NULL == rt) { 2521 if (NULL == rt) {
2519 SkASSERT(surface->asTexture()); 2522 SkASSERT(surface->asTexture());
2520 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur eID(); 2523 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur eID();
2521 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, &tempFBOID)); 2524 GrGLuint* tempFBOID;
2525 tempFBOID = kSrc_TempFBOTarget == tempFBOTarget ? &fTempSrcFBOID : &fTem pDstFBOID;
2526
2527 if (0 == *tempFBOID) {
2528 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, tempFBOID));
2529 }
2530
2522 fStats.incRenderTargetBinds(); 2531 fStats.incRenderTargetBinds();
2523 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, tempFBOID)); 2532 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, *tempFBOID));
2524 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget, 2533 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget,
2525 GR_GL_COLOR_ATTACHM ENT0, 2534 GR_GL_COLOR_ATTACHM ENT0,
2526 GR_GL_TEXTURE_2D, 2535 GR_GL_TEXTURE_2D,
2527 texID, 2536 texID,
2528 0)); 2537 0));
2529 viewport->fLeft = 0; 2538 viewport->fLeft = 0;
2530 viewport->fBottom = 0; 2539 viewport->fBottom = 0;
2531 viewport->fWidth = surface->width(); 2540 viewport->fWidth = surface->width();
2532 viewport->fHeight = surface->height(); 2541 viewport->fHeight = surface->height();
2542 return *tempFBOID;
2533 } else { 2543 } else {
2534 tempFBOID = 0; 2544 GrGLuint tempFBOID = 0;
2535 fStats.incRenderTargetBinds(); 2545 fStats.incRenderTargetBinds();
2536 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO ID())); 2546 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO ID()));
2537 *viewport = rt->getViewport(); 2547 *viewport = rt->getViewport();
2548 return tempFBOID;
2538 } 2549 }
2539 return tempFBOID; 2550 }
2551
2552 void GrGLGpu::unbindTextureFromFBO(GrGLenum fboTarget) {
2553 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget,
2554 GR_GL_COLOR_ATTACHMENT0 ,
2555 GR_GL_TEXTURE_2D,
2556 0,
2557 0));
2540 } 2558 }
2541 2559
2542 bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) { 2560 bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) {
2543 // In here we look for opportunities to use CopyTexSubImage, or fbo blit. If neither are 2561 // 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- 2562 // 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 2563 // 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. 2564 // creation. It isn't clear that avoiding temporary fbo creation is actually optimal.
2547 2565
2548 // Check for format issues with glCopyTexSubImage2D 2566 // Check for format issues with glCopyTexSubImage2D
2549 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna lFormat() && 2567 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna lFormat() &&
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2583 } 2601 }
2584 2602
2585 bool GrGLGpu::copySurface(GrSurface* dst, 2603 bool GrGLGpu::copySurface(GrSurface* dst,
2586 GrSurface* src, 2604 GrSurface* src,
2587 const SkIRect& srcRect, 2605 const SkIRect& srcRect,
2588 const SkIPoint& dstPoint) { 2606 const SkIPoint& dstPoint) {
2589 bool copied = false; 2607 bool copied = false;
2590 if (can_copy_texsubimage(dst, src, this)) { 2608 if (can_copy_texsubimage(dst, src, this)) {
2591 GrGLuint srcFBO; 2609 GrGLuint srcFBO;
2592 GrGLIRect srcVP; 2610 GrGLIRect srcVP;
2593 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_FRAMEBUFFER, &srcVP); 2611 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_FRAMEBUFFER, &srcVP, kSrc_Tem pFBOTarget);
2594 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); 2612 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture());
2595 SkASSERT(dstTex); 2613 SkASSERT(dstTex);
2596 // We modified the bound FBO 2614 // We modified the bound FBO
2597 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 2615 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
2598 GrGLIRect srcGLRect; 2616 GrGLIRect srcGLRect;
2599 srcGLRect.setRelativeTo(srcVP, 2617 srcGLRect.setRelativeTo(srcVP,
2600 srcRect.fLeft, 2618 srcRect.fLeft,
2601 srcRect.fTop, 2619 srcRect.fTop,
2602 srcRect.width(), 2620 srcRect.width(),
2603 srcRect.height(), 2621 srcRect.height(),
2604 src->origin()); 2622 src->origin());
2605 2623
2606 this->setScratchTextureUnit(); 2624 this->setScratchTextureUnit();
2607 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); 2625 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID()));
2608 GrGLint dstY; 2626 GrGLint dstY;
2609 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { 2627 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) {
2610 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight); 2628 dstY = dst->height() - (dstPoint.fY + srcGLRect.fHeight);
2611 } else { 2629 } else {
2612 dstY = dstPoint.fY; 2630 dstY = dstPoint.fY;
2613 } 2631 }
2614 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0, 2632 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0,
2615 dstPoint.fX, dstY, 2633 dstPoint.fX, dstY,
2616 srcGLRect.fLeft, srcGLRect.fBottom, 2634 srcGLRect.fLeft, srcGLRect.fBottom,
2617 srcGLRect.fWidth, srcGLRect.fHeight)); 2635 srcGLRect.fWidth, srcGLRect.fHeight));
2618 copied = true; 2636 copied = true;
2619 if (srcFBO) { 2637 if (srcFBO) {
2620 GL_CALL(DeleteFramebuffers(1, &srcFBO)); 2638 this->unbindTextureFromFBO(GR_GL_FRAMEBUFFER);
2621 } 2639 }
2622 } else if (can_blit_framebuffer(dst, src, this)) { 2640 } else if (can_blit_framebuffer(dst, src, this)) {
2623 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, 2641 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY,
2624 srcRect.width(), srcRect.height()); 2642 srcRect.width(), srcRect.height());
2625 bool selfOverlap = false; 2643 bool selfOverlap = false;
2626 if (dst == src) { 2644 if (dst == src) {
2627 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); 2645 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect);
2628 } 2646 }
2629 2647
2630 if (!selfOverlap) { 2648 if (!selfOverlap) {
2631 GrGLuint dstFBO; 2649 GrGLuint dstFBO;
2632 GrGLuint srcFBO; 2650 GrGLuint srcFBO;
2633 GrGLIRect dstVP; 2651 GrGLIRect dstVP;
2634 GrGLIRect srcVP; 2652 GrGLIRect srcVP;
2635 dstFBO = this->bindSurfaceAsFBO(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP) ; 2653 dstFBO = this->bindSurfaceAsFBO(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP,
2636 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_READ_FRAMEBUFFER, &srcVP) ; 2654 kDst_TempFBOTarget);
2655 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_READ_FRAMEBUFFER, &srcVP,
2656 kSrc_TempFBOTarget);
2637 // We modified the bound FBO 2657 // We modified the bound FBO
2638 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 2658 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
2639 GrGLIRect srcGLRect; 2659 GrGLIRect srcGLRect;
2640 GrGLIRect dstGLRect; 2660 GrGLIRect dstGLRect;
2641 srcGLRect.setRelativeTo(srcVP, 2661 srcGLRect.setRelativeTo(srcVP,
2642 srcRect.fLeft, 2662 srcRect.fLeft,
2643 srcRect.fTop, 2663 srcRect.fTop,
2644 srcRect.width(), 2664 srcRect.width(),
2645 srcRect.height(), 2665 srcRect.height(),
2646 src->origin()); 2666 src->origin());
(...skipping 20 matching lines...) Expand all
2667 GL_CALL(BlitFramebuffer(srcGLRect.fLeft, 2687 GL_CALL(BlitFramebuffer(srcGLRect.fLeft,
2668 srcY0, 2688 srcY0,
2669 srcGLRect.fLeft + srcGLRect.fWidth, 2689 srcGLRect.fLeft + srcGLRect.fWidth,
2670 srcY1, 2690 srcY1,
2671 dstGLRect.fLeft, 2691 dstGLRect.fLeft,
2672 dstGLRect.fBottom, 2692 dstGLRect.fBottom,
2673 dstGLRect.fLeft + dstGLRect.fWidth, 2693 dstGLRect.fLeft + dstGLRect.fWidth,
2674 dstGLRect.fBottom + dstGLRect.fHeight, 2694 dstGLRect.fBottom + dstGLRect.fHeight,
2675 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); 2695 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST));
2676 if (dstFBO) { 2696 if (dstFBO) {
2677 GL_CALL(DeleteFramebuffers(1, &dstFBO)); 2697 this->unbindTextureFromFBO(GR_GL_DRAW_FRAMEBUFFER);
2678 } 2698 }
2679 if (srcFBO) { 2699 if (srcFBO) {
2680 GL_CALL(DeleteFramebuffers(1, &srcFBO)); 2700 this->unbindTextureFromFBO(GR_GL_READ_FRAMEBUFFER);
2681 } 2701 }
2682 copied = true; 2702 copied = true;
2683 } 2703 }
2684 } 2704 }
2685 return copied; 2705 return copied;
2686 } 2706 }
2687 2707
2688 bool GrGLGpu::canCopySurface(const GrSurface* dst, 2708 bool GrGLGpu::canCopySurface(const GrSurface* dst,
2689 const GrSurface* src, 2709 const GrSurface* src,
2690 const SkIRect& srcRect, 2710 const SkIRect& srcRect,
2691 const SkIPoint& dstPoint) { 2711 const SkIPoint& dstPoint) {
2692 // This mirrors the logic in onCopySurface. We prefer our base makes the co py if we need to 2712 // 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 2713 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; 2714 return true;
2698 } 2715 }
2699 if (can_blit_framebuffer(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTem pFBO) { 2716 if (can_blit_framebuffer(dst, src, this)) {
2700 if (dst == src) { 2717 if (dst == src) {
2701 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, 2718 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY,
2702 srcRect.width(), srcRect.height( )); 2719 srcRect.width(), srcRect.height( ));
2703 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) { 2720 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) {
2704 return true; 2721 return true;
2705 } 2722 }
2706 } else { 2723 } else {
2707 return true; 2724 return true;
2708 } 2725 }
2709 } 2726 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2750 this->setVertexArrayID(gpu, 0); 2767 this->setVertexArrayID(gpu, 0);
2751 } 2768 }
2752 int attrCount = gpu->glCaps().maxVertexAttributes(); 2769 int attrCount = gpu->glCaps().maxVertexAttributes();
2753 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2770 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2754 fDefaultVertexArrayAttribState.resize(attrCount); 2771 fDefaultVertexArrayAttribState.resize(attrCount);
2755 } 2772 }
2756 attribState = &fDefaultVertexArrayAttribState; 2773 attribState = &fDefaultVertexArrayAttribState;
2757 } 2774 }
2758 return attribState; 2775 return attribState;
2759 } 2776 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698