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" |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTex->textureID())); | 519 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTex->textureID())); |
520 GrGLTexture::Desc desc; | 520 GrGLTexture::Desc desc; |
521 desc.fFlags = glTex->desc().fFlags; | 521 desc.fFlags = glTex->desc().fFlags; |
522 desc.fWidth = glTex->width(); | 522 desc.fWidth = glTex->width(); |
523 desc.fHeight = glTex->height(); | 523 desc.fHeight = glTex->height(); |
524 desc.fConfig = glTex->config(); | 524 desc.fConfig = glTex->config(); |
525 desc.fSampleCnt = glTex->desc().fSampleCnt; | 525 desc.fSampleCnt = glTex->desc().fSampleCnt; |
526 desc.fTextureID = glTex->textureID(); | 526 desc.fTextureID = glTex->textureID(); |
527 desc.fOrigin = glTex->origin(); | 527 desc.fOrigin = glTex->origin(); |
528 | 528 |
529 return this->uploadTexData(desc, false, | 529 if (this->uploadTexData(desc, false, |
530 left, top, width, height, | 530 left, top, width, height, |
531 config, buffer, rowBytes); | 531 config, buffer, rowBytes)) { |
| 532 texture->dirtyMipMaps(true); |
| 533 return true; |
| 534 } else { |
| 535 return false; |
| 536 } |
532 } | 537 } |
533 | 538 |
534 namespace { | 539 namespace { |
535 bool adjust_pixel_ops_params(int surfaceWidth, | 540 bool adjust_pixel_ops_params(int surfaceWidth, |
536 int surfaceHeight, | 541 int surfaceHeight, |
537 size_t bpp, | 542 size_t bpp, |
538 int* left, int* top, int* width, int* height, | 543 int* left, int* top, int* width, int* height, |
539 const void** data, | 544 const void** data, |
540 size_t* rowBytes) { | 545 size_t* rowBytes) { |
541 if (!*rowBytes) { | 546 if (!*rowBytes) { |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 fHWBoundRenderTarget = rt; | 1545 fHWBoundRenderTarget = rt; |
1541 const GrGLIRect& vp = rt->getViewport(); | 1546 const GrGLIRect& vp = rt->getViewport(); |
1542 if (fHWViewport != vp) { | 1547 if (fHWViewport != vp) { |
1543 vp.pushToGLViewport(this->glInterface()); | 1548 vp.pushToGLViewport(this->glInterface()); |
1544 fHWViewport = vp; | 1549 fHWViewport = vp; |
1545 } | 1550 } |
1546 } | 1551 } |
1547 if (NULL == bound || !bound->isEmpty()) { | 1552 if (NULL == bound || !bound->isEmpty()) { |
1548 rt->flagAsNeedingResolve(bound); | 1553 rt->flagAsNeedingResolve(bound); |
1549 } | 1554 } |
| 1555 |
| 1556 GrTexture *texture = rt->asTexture(); |
| 1557 if (texture) { |
| 1558 texture->dirtyMipMaps(true); |
| 1559 } |
1550 } | 1560 } |
1551 | 1561 |
1552 GrGLenum gPrimitiveType2GLMode[] = { | 1562 GrGLenum gPrimitiveType2GLMode[] = { |
1553 GR_GL_TRIANGLES, | 1563 GR_GL_TRIANGLES, |
1554 GR_GL_TRIANGLE_STRIP, | 1564 GR_GL_TRIANGLE_STRIP, |
1555 GR_GL_TRIANGLE_FAN, | 1565 GR_GL_TRIANGLE_FAN, |
1556 GR_GL_POINTS, | 1566 GR_GL_POINTS, |
1557 GR_GL_LINES, | 1567 GR_GL_LINES, |
1558 GR_GL_LINE_STRIP | 1568 GR_GL_LINE_STRIP |
1559 }; | 1569 }; |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 this->setTextureUnit(unitIdx); | 2009 this->setTextureUnit(unitIdx); |
2000 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID())); | 2010 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID())); |
2001 fHWBoundTextures[unitIdx] = texture; | 2011 fHWBoundTextures[unitIdx] = texture; |
2002 } | 2012 } |
2003 | 2013 |
2004 ResetTimestamp timestamp; | 2014 ResetTimestamp timestamp; |
2005 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); | 2015 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); |
2006 bool setAll = timestamp < this->getResetTimestamp(); | 2016 bool setAll = timestamp < this->getResetTimestamp(); |
2007 GrGLTexture::TexParams newTexParams; | 2017 GrGLTexture::TexParams newTexParams; |
2008 | 2018 |
2009 newTexParams.fFilter = (params.filterMode() == GrTextureParams::kNone_Filter
Mode) ? GR_GL_NEAREST : GR_GL_LINEAR; | 2019 static GrGLenum glFilterModes[] = { |
| 2020 GR_GL_NEAREST, |
| 2021 GR_GL_LINEAR, |
| 2022 GR_GL_LINEAR_MIPMAP_LINEAR |
| 2023 }; |
| 2024 newTexParams.fFilter = glFilterModes[params.filterMode()]; |
| 2025 |
| 2026 #ifndef SKIA_IGNORE_GPU_MIPMAPS |
| 2027 if (params.filterMode() == GrTextureParams::kMipMap_FilterMode && |
| 2028 texture->mipMapsAreDirty()) { |
| 2029 // GL_CALL(Hint(GR_GL_GENERATE_MIPMAP_HINT,GR_GL_NICEST)); |
| 2030 GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D)); |
| 2031 texture->dirtyMipMaps(false); |
| 2032 } |
| 2033 #endif |
2010 | 2034 |
2011 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); | 2035 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); |
2012 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); | 2036 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); |
2013 memcpy(newTexParams.fSwizzleRGBA, | 2037 memcpy(newTexParams.fSwizzleRGBA, |
2014 GrGLShaderBuilder::GetTexParamSwizzle(texture->config(), this->glCaps
()), | 2038 GrGLShaderBuilder::GetTexParamSwizzle(texture->config(), this->glCaps
()), |
2015 sizeof(newTexParams.fSwizzleRGBA)); | 2039 sizeof(newTexParams.fSwizzleRGBA)); |
2016 if (setAll || newTexParams.fFilter != oldTexParams.fFilter) { | 2040 if (setAll || newTexParams.fFilter != oldTexParams.fFilter) { |
2017 this->setTextureUnit(unitIdx); | 2041 this->setTextureUnit(unitIdx); |
2018 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 2042 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
2019 GR_GL_TEXTURE_MAG_FILTER, | 2043 GR_GL_TEXTURE_MAG_FILTER, |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 this->setVertexArrayID(gpu, 0); | 2539 this->setVertexArrayID(gpu, 0); |
2516 } | 2540 } |
2517 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2541 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2518 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2542 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2519 fDefaultVertexArrayAttribState.resize(attrCount); | 2543 fDefaultVertexArrayAttribState.resize(attrCount); |
2520 } | 2544 } |
2521 attribState = &fDefaultVertexArrayAttribState; | 2545 attribState = &fDefaultVertexArrayAttribState; |
2522 } | 2546 } |
2523 return attribState; | 2547 return attribState; |
2524 } | 2548 } |
OLD | NEW |