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