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 "GrOptDrawState.h" | 11 #include "GrOptDrawState.h" |
12 #include "GrSurfacePriv.h" | |
13 #include "GrTemplates.h" | 12 #include "GrTemplates.h" |
14 #include "GrTexturePriv.h" | |
15 #include "GrTypes.h" | 13 #include "GrTypes.h" |
16 #include "SkStrokeRec.h" | 14 #include "SkStrokeRec.h" |
17 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
18 | 16 |
19 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) | 17 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) |
20 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) | 18 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) |
21 | 19 |
22 #define SKIP_CACHE_CHECK true | 20 #define SKIP_CACHE_CHECK true |
23 | 21 |
24 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR | 22 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 SkASSERT(config == desc.fConfig); | 486 SkASSERT(config == desc.fConfig); |
489 success = this->uploadCompressedTexData(desc, buffer, false, | 487 success = this->uploadCompressedTexData(desc, buffer, false, |
490 left, top, width, height); | 488 left, top, width, height); |
491 } else { | 489 } else { |
492 success = this->uploadTexData(desc, false, | 490 success = this->uploadTexData(desc, false, |
493 left, top, width, height, | 491 left, top, width, height, |
494 config, buffer, rowBytes); | 492 config, buffer, rowBytes); |
495 } | 493 } |
496 | 494 |
497 if (success) { | 495 if (success) { |
498 texture->texturePriv().dirtyMipMaps(true); | 496 texture->impl()->dirtyMipMaps(true); |
499 return true; | 497 return true; |
500 } | 498 } |
501 | 499 |
502 return false; | 500 return false; |
503 } | 501 } |
504 | 502 |
505 namespace { | 503 namespace { |
506 bool adjust_pixel_ops_params(int surfaceWidth, | 504 bool adjust_pixel_ops_params(int surfaceWidth, |
507 int surfaceHeight, | 505 int surfaceHeight, |
508 size_t bpp, | 506 size_t bpp, |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1726 vp.pushToGLViewport(this->glInterface()); | 1724 vp.pushToGLViewport(this->glInterface()); |
1727 fHWViewport = vp; | 1725 fHWViewport = vp; |
1728 } | 1726 } |
1729 } | 1727 } |
1730 if (NULL == bound || !bound->isEmpty()) { | 1728 if (NULL == bound || !bound->isEmpty()) { |
1731 target->flagAsNeedingResolve(bound); | 1729 target->flagAsNeedingResolve(bound); |
1732 } | 1730 } |
1733 | 1731 |
1734 GrTexture *texture = target->asTexture(); | 1732 GrTexture *texture = target->asTexture(); |
1735 if (texture) { | 1733 if (texture) { |
1736 texture->texturePriv().dirtyMipMaps(true); | 1734 texture->impl()->dirtyMipMaps(true); |
1737 } | 1735 } |
1738 } | 1736 } |
1739 | 1737 |
1740 GrGLenum gPrimitiveType2GLMode[] = { | 1738 GrGLenum gPrimitiveType2GLMode[] = { |
1741 GR_GL_TRIANGLES, | 1739 GR_GL_TRIANGLES, |
1742 GR_GL_TRIANGLE_STRIP, | 1740 GR_GL_TRIANGLE_STRIP, |
1743 GR_GL_TRIANGLE_FAN, | 1741 GR_GL_TRIANGLE_FAN, |
1744 GR_GL_POINTS, | 1742 GR_GL_POINTS, |
1745 GR_GL_LINES, | 1743 GR_GL_LINES, |
1746 GR_GL_LINE_STRIP | 1744 GR_GL_LINE_STRIP |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 GR_GL_LINEAR | 2046 GR_GL_LINEAR |
2049 }; | 2047 }; |
2050 GrTextureParams::FilterMode filterMode = params.filterMode(); | 2048 GrTextureParams::FilterMode filterMode = params.filterMode(); |
2051 if (!this->caps()->mipMapSupport() && GrTextureParams::kMipMap_FilterMode ==
filterMode) { | 2049 if (!this->caps()->mipMapSupport() && GrTextureParams::kMipMap_FilterMode ==
filterMode) { |
2052 filterMode = GrTextureParams::kBilerp_FilterMode; | 2050 filterMode = GrTextureParams::kBilerp_FilterMode; |
2053 } | 2051 } |
2054 newTexParams.fMinFilter = glMinFilterModes[filterMode]; | 2052 newTexParams.fMinFilter = glMinFilterModes[filterMode]; |
2055 newTexParams.fMagFilter = glMagFilterModes[filterMode]; | 2053 newTexParams.fMagFilter = glMagFilterModes[filterMode]; |
2056 | 2054 |
2057 if (GrTextureParams::kMipMap_FilterMode == filterMode && | 2055 if (GrTextureParams::kMipMap_FilterMode == filterMode && |
2058 texture->texturePriv().mipMapsAreDirty() && !GrPixelConfigIsCompressed(t
exture->config())) { | 2056 texture->mipMapsAreDirty() && !GrPixelConfigIsCompressed(texture->config
())) { |
2059 GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D)); | 2057 GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D)); |
2060 texture->texturePriv().dirtyMipMaps(false); | 2058 texture->dirtyMipMaps(false); |
2061 } | 2059 } |
2062 | 2060 |
2063 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); | 2061 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); |
2064 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); | 2062 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); |
2065 memcpy(newTexParams.fSwizzleRGBA, | 2063 memcpy(newTexParams.fSwizzleRGBA, |
2066 GrGLShaderBuilder::GetTexParamSwizzle(texture->config(), this->glCaps
()), | 2064 GrGLShaderBuilder::GetTexParamSwizzle(texture->config(), this->glCaps
()), |
2067 sizeof(newTexParams.fSwizzleRGBA)); | 2065 sizeof(newTexParams.fSwizzleRGBA)); |
2068 if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) { | 2066 if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) { |
2069 this->setTextureUnit(unitIdx); | 2067 this->setTextureUnit(unitIdx); |
2070 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 2068 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 srcGLRect.fWidth, srcGLRect.fHeight)); | 2462 srcGLRect.fWidth, srcGLRect.fHeight)); |
2465 copied = true; | 2463 copied = true; |
2466 if (srcFBO) { | 2464 if (srcFBO) { |
2467 GL_CALL(DeleteFramebuffers(1, &srcFBO)); | 2465 GL_CALL(DeleteFramebuffers(1, &srcFBO)); |
2468 } | 2466 } |
2469 } else if (can_blit_framebuffer(dst, src, this, &wouldNeedTempFBO) && | 2467 } else if (can_blit_framebuffer(dst, src, this, &wouldNeedTempFBO) && |
2470 (!wouldNeedTempFBO || !inheritedCouldCopy)) { | 2468 (!wouldNeedTempFBO || !inheritedCouldCopy)) { |
2471 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, | 2469 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, |
2472 srcRect.width(), srcRect.height()); | 2470 srcRect.width(), srcRect.height()); |
2473 bool selfOverlap = false; | 2471 bool selfOverlap = false; |
2474 if (dst->surfacePriv().isSameAs(src)) { | 2472 if (dst->isSameAs(src)) { |
2475 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); | 2473 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); |
2476 } | 2474 } |
2477 | 2475 |
2478 if (!selfOverlap) { | 2476 if (!selfOverlap) { |
2479 GrGLuint dstFBO; | 2477 GrGLuint dstFBO; |
2480 GrGLuint srcFBO; | 2478 GrGLuint srcFBO; |
2481 GrGLIRect dstVP; | 2479 GrGLIRect dstVP; |
2482 GrGLIRect srcVP; | 2480 GrGLIRect srcVP; |
2483 dstFBO = this->bindSurfaceAsFBO(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP)
; | 2481 dstFBO = this->bindSurfaceAsFBO(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP)
; |
2484 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_READ_FRAMEBUFFER, &srcVP)
; | 2482 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_READ_FRAMEBUFFER, &srcVP)
; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 | 2540 |
2543 bool GrGpuGL::onCanCopySurface(GrSurface* dst, | 2541 bool GrGpuGL::onCanCopySurface(GrSurface* dst, |
2544 GrSurface* src, | 2542 GrSurface* src, |
2545 const SkIRect& srcRect, | 2543 const SkIRect& srcRect, |
2546 const SkIPoint& dstPoint) { | 2544 const SkIPoint& dstPoint) { |
2547 // This mirrors the logic in onCopySurface. | 2545 // This mirrors the logic in onCopySurface. |
2548 if (can_copy_texsubimage(dst, src, this)) { | 2546 if (can_copy_texsubimage(dst, src, this)) { |
2549 return true; | 2547 return true; |
2550 } | 2548 } |
2551 if (can_blit_framebuffer(dst, src, this)) { | 2549 if (can_blit_framebuffer(dst, src, this)) { |
2552 if (dst->surfacePriv().isSameAs(src)) { | 2550 if (dst->isSameAs(src)) { |
2553 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, | 2551 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, |
2554 srcRect.width(), srcRect.height(
)); | 2552 srcRect.width(), srcRect.height(
)); |
2555 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) { | 2553 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) { |
2556 return true; | 2554 return true; |
2557 } | 2555 } |
2558 } else { | 2556 } else { |
2559 return true; | 2557 return true; |
2560 } | 2558 } |
2561 } | 2559 } |
2562 return INHERITED::onCanCopySurface(dst, src, srcRect, dstPoint); | 2560 return INHERITED::onCanCopySurface(dst, src, srcRect, dstPoint); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2601 this->setVertexArrayID(gpu, 0); | 2599 this->setVertexArrayID(gpu, 0); |
2602 } | 2600 } |
2603 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2601 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2604 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2602 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2605 fDefaultVertexArrayAttribState.resize(attrCount); | 2603 fDefaultVertexArrayAttribState.resize(attrCount); |
2606 } | 2604 } |
2607 attribState = &fDefaultVertexArrayAttribState; | 2605 attribState = &fDefaultVertexArrayAttribState; |
2608 } | 2606 } |
2609 return attribState; | 2607 return attribState; |
2610 } | 2608 } |
OLD | NEW |