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 #include "GrGLGpu.h" | 8 #include "GrGLGpu.h" |
9 #include "GrGLGLSL.h" | 9 #include "GrGLGLSL.h" |
10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 uint32_t usedAttribArraysMask = 0; | 1752 uint32_t usedAttribArraysMask = 0; |
1753 size_t offset = 0; | 1753 size_t offset = 0; |
1754 | 1754 |
1755 for (int attribIndex = 0; attribIndex < vaCount; attribIndex++) { | 1755 for (int attribIndex = 0; attribIndex < vaCount; attribIndex++) { |
1756 const GrGeometryProcessor::Attribute& attrib = primProc.getAttrib(at
tribIndex); | 1756 const GrGeometryProcessor::Attribute& attrib = primProc.getAttrib(at
tribIndex); |
1757 usedAttribArraysMask |= (1 << attribIndex); | 1757 usedAttribArraysMask |= (1 << attribIndex); |
1758 GrVertexAttribType attribType = attrib.fType; | 1758 GrVertexAttribType attribType = attrib.fType; |
1759 attribState->set(this, | 1759 attribState->set(this, |
1760 attribIndex, | 1760 attribIndex, |
1761 vbuf->bufferID(), | 1761 vbuf->bufferID(), |
1762 GrGLAttribTypeToLayout(attribType).fCount, | 1762 attribType, |
1763 GrGLAttribTypeToLayout(attribType).fType, | |
1764 GrGLAttribTypeToLayout(attribType).fNormalized, | |
1765 stride, | 1763 stride, |
1766 reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + o
ffset)); | 1764 reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + o
ffset)); |
1767 offset += attrib.fOffset; | 1765 offset += attrib.fOffset; |
1768 } | 1766 } |
1769 attribState->disableUnusedArrays(this, usedAttribArraysMask); | 1767 attribState->disableUnusedArrays(this, usedAttribArraysMask); |
1770 } | 1768 } |
1771 } | 1769 } |
1772 | 1770 |
1773 void GrGLGpu::buildProgramDesc(GrProgramDesc* desc, | 1771 void GrGLGpu::buildProgramDesc(GrProgramDesc* desc, |
1774 const GrPrimitiveProcessor& primProc, | 1772 const GrPrimitiveProcessor& primProc, |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 #endif | 2531 #endif |
2534 } | 2532 } |
2535 | 2533 |
2536 void GrGLGpu::stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGL
int posXformUniform, | 2534 void GrGLGpu::stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGL
int posXformUniform, |
2537 GrGLuint arrayBuffer) { | 2535 GrGLuint arrayBuffer) { |
2538 GL_CALL(UseProgram(program)); | 2536 GL_CALL(UseProgram(program)); |
2539 this->fHWGeometryState.setVertexArrayID(this, 0); | 2537 this->fHWGeometryState.setVertexArrayID(this, 0); |
2540 | 2538 |
2541 GrGLAttribArrayState* attribs = | 2539 GrGLAttribArrayState* attribs = |
2542 this->fHWGeometryState.bindArrayAndBufferToDraw(this, arrayBuffer); | 2540 this->fHWGeometryState.bindArrayAndBufferToDraw(this, arrayBuffer); |
2543 attribs->set(this, 0, arrayBuffer, 2, GR_GL_FLOAT, false, 2 * sizeof(GrGLflo
at), 0); | 2541 attribs->set(this, 0, arrayBuffer, kVec2f_GrVertexAttribType, 2 * sizeof(GrG
Lfloat), 0); |
2544 attribs->disableUnusedArrays(this, 0x1); | 2542 attribs->disableUnusedArrays(this, 0x1); |
2545 | 2543 |
2546 GL_CALL(Uniform4f(posXformUniform, bounds.width(), bounds.height(), bounds.l
eft(), | 2544 GL_CALL(Uniform4f(posXformUniform, bounds.width(), bounds.height(), bounds.l
eft(), |
2547 bounds.top())); | 2545 bounds.top())); |
2548 | 2546 |
2549 GrXferProcessor::BlendInfo blendInfo; | 2547 GrXferProcessor::BlendInfo blendInfo; |
2550 blendInfo.reset(); | 2548 blendInfo.reset(); |
2551 this->flushBlend(blendInfo, GrSwizzle()); | 2549 this->flushBlend(blendInfo, GrSwizzle()); |
2552 this->flushColorWrite(true); | 2550 this->flushColorWrite(true); |
2553 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 2551 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3474 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(rt->asRenderTarget()
); | 3472 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(rt->asRenderTarget()
); |
3475 this->flushRenderTarget(glRT, &rect); | 3473 this->flushRenderTarget(glRT, &rect); |
3476 | 3474 |
3477 GL_CALL(UseProgram(fWireRectProgram.fProgram)); | 3475 GL_CALL(UseProgram(fWireRectProgram.fProgram)); |
3478 fHWProgramID = fWireRectProgram.fProgram; | 3476 fHWProgramID = fWireRectProgram.fProgram; |
3479 | 3477 |
3480 fHWGeometryState.setVertexArrayID(this, 0); | 3478 fHWGeometryState.setVertexArrayID(this, 0); |
3481 | 3479 |
3482 GrGLAttribArrayState* attribs = | 3480 GrGLAttribArrayState* attribs = |
3483 fHWGeometryState.bindArrayAndBufferToDraw(this, fWireRectArrayBuffer); | 3481 fHWGeometryState.bindArrayAndBufferToDraw(this, fWireRectArrayBuffer); |
3484 attribs->set(this, 0, fWireRectArrayBuffer, 2, GR_GL_FLOAT, false, 2 * sizeo
f(GrGLfloat), 0); | 3482 attribs->set(this, 0, fWireRectArrayBuffer, kVec2f_GrVertexAttribType, 2 * s
izeof(GrGLfloat), |
| 3483 0); |
3485 attribs->disableUnusedArrays(this, 0x1); | 3484 attribs->disableUnusedArrays(this, 0x1); |
3486 | 3485 |
3487 GL_CALL(Uniform4fv(fWireRectProgram.fRectUniform, 1, edges)); | 3486 GL_CALL(Uniform4fv(fWireRectProgram.fRectUniform, 1, edges)); |
3488 GL_CALL(Uniform4fv(fWireRectProgram.fColorUniform, 1, channels)); | 3487 GL_CALL(Uniform4fv(fWireRectProgram.fColorUniform, 1, channels)); |
3489 | 3488 |
3490 GrXferProcessor::BlendInfo blendInfo; | 3489 GrXferProcessor::BlendInfo blendInfo; |
3491 blendInfo.reset(); | 3490 blendInfo.reset(); |
3492 this->flushBlend(blendInfo, GrSwizzle::RGBA()); | 3491 this->flushBlend(blendInfo, GrSwizzle::RGBA()); |
3493 this->flushColorWrite(true); | 3492 this->flushColorWrite(true); |
3494 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 3493 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
(...skipping 24 matching lines...) Expand all Loading... |
3519 | 3518 |
3520 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); | 3519 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); |
3521 | 3520 |
3522 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); | 3521 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); |
3523 fHWProgramID = fCopyPrograms[progIdx].fProgram; | 3522 fHWProgramID = fCopyPrograms[progIdx].fProgram; |
3524 | 3523 |
3525 fHWGeometryState.setVertexArrayID(this, 0); | 3524 fHWGeometryState.setVertexArrayID(this, 0); |
3526 | 3525 |
3527 GrGLAttribArrayState* attribs = | 3526 GrGLAttribArrayState* attribs = |
3528 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer)
; | 3527 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer)
; |
3529 attribs->set(this, 0, fCopyProgramArrayBuffer, 2, GR_GL_FLOAT, false, 2 * si
zeof(GrGLfloat), 0); | 3528 attribs->set(this, 0, fCopyProgramArrayBuffer, kVec2f_GrVertexAttribType, 2
* sizeof(GrGLfloat), |
| 3529 0); |
3530 attribs->disableUnusedArrays(this, 0x1); | 3530 attribs->disableUnusedArrays(this, 0x1); |
3531 | 3531 |
3532 // dst rect edges in NDC (-1 to 1) | 3532 // dst rect edges in NDC (-1 to 1) |
3533 int dw = dst->width(); | 3533 int dw = dst->width(); |
3534 int dh = dst->height(); | 3534 int dh = dst->height(); |
3535 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; | 3535 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; |
3536 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; | 3536 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; |
3537 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; | 3537 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; |
3538 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; | 3538 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; |
3539 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { | 3539 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3843 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 3843 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
3844 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 3844 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
3845 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 3845 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
3846 copyParams->fWidth = texture->width(); | 3846 copyParams->fWidth = texture->width(); |
3847 copyParams->fHeight = texture->height(); | 3847 copyParams->fHeight = texture->height(); |
3848 return true; | 3848 return true; |
3849 } | 3849 } |
3850 } | 3850 } |
3851 return false; | 3851 return false; |
3852 } | 3852 } |
OLD | NEW |