Chromium Code Reviews| 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 "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
| 10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 fPixelConfigToStencilIndex[i] = kUnknownStencilIndex; | 225 fPixelConfigToStencilIndex[i] = kUnknownStencilIndex; |
| 226 } | 226 } |
| 227 fHWProgramID = 0; | 227 fHWProgramID = 0; |
| 228 fTempSrcFBOID = 0; | 228 fTempSrcFBOID = 0; |
| 229 fTempDstFBOID = 0; | 229 fTempDstFBOID = 0; |
| 230 fStencilClearFBOID = 0; | 230 fStencilClearFBOID = 0; |
| 231 | 231 |
| 232 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 232 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
| 233 fPathRendering.reset(new GrGLPathRendering(this)); | 233 fPathRendering.reset(new GrGLPathRendering(this)); |
| 234 } | 234 } |
| 235 | |
| 236 this->createCopyPrograms(); | 235 this->createCopyPrograms(); |
| 236 fWireRectProgram.fProgram = 0; | |
| 237 } | 237 } |
| 238 | 238 |
| 239 GrGLGpu::~GrGLGpu() { | 239 GrGLGpu::~GrGLGpu() { |
| 240 if (0 != fHWProgramID) { | 240 if (0 != fHWProgramID) { |
| 241 // detach the current program so there is no confusion on OpenGL's part | 241 // detach the current program so there is no confusion on OpenGL's part |
| 242 // that we want it to be deleted | 242 // that we want it to be deleted |
| 243 GL_CALL(UseProgram(0)); | 243 GL_CALL(UseProgram(0)); |
| 244 } | 244 } |
| 245 | 245 |
| 246 if (0 != fTempSrcFBOID) { | 246 if (0 != fTempSrcFBOID) { |
| 247 GL_CALL(DeleteFramebuffers(1, &fTempSrcFBOID)); | 247 GL_CALL(DeleteFramebuffers(1, &fTempSrcFBOID)); |
| 248 } | 248 } |
| 249 if (0 != fTempDstFBOID) { | 249 if (0 != fTempDstFBOID) { |
| 250 GL_CALL(DeleteFramebuffers(1, &fTempDstFBOID)); | 250 GL_CALL(DeleteFramebuffers(1, &fTempDstFBOID)); |
| 251 } | 251 } |
| 252 if (0 != fStencilClearFBOID) { | 252 if (0 != fStencilClearFBOID) { |
| 253 GL_CALL(DeleteFramebuffers(1, &fStencilClearFBOID)); | 253 GL_CALL(DeleteFramebuffers(1, &fStencilClearFBOID)); |
| 254 } | 254 } |
| 255 | 255 |
| 256 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 256 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
| 257 if (0 != fCopyPrograms[i].fProgram) { | 257 if (0 != fCopyPrograms[i].fProgram) { |
| 258 GL_CALL(DeleteProgram(fCopyPrograms[i].fProgram)); | 258 GL_CALL(DeleteProgram(fCopyPrograms[i].fProgram)); |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | |
| 261 if (0 != fCopyProgramArrayBuffer) { | 262 if (0 != fCopyProgramArrayBuffer) { |
| 262 GL_CALL(DeleteBuffers(1, &fCopyProgramArrayBuffer)); | 263 GL_CALL(DeleteBuffers(1, &fCopyProgramArrayBuffer)); |
| 263 } | 264 } |
| 264 | 265 |
| 266 if (0 != fWireRectProgram.fProgram) { | |
| 267 GL_CALL(DeleteProgram(fWireRectProgram.fProgram)); | |
| 268 } | |
| 269 | |
| 270 if (0 != fWireRectArrayBuffer) { | |
| 271 GL_CALL(DeleteBuffers(1, &fWireRectArrayBuffer)); | |
| 272 } | |
| 273 | |
| 265 delete fProgramCache; | 274 delete fProgramCache; |
| 266 } | 275 } |
| 267 | 276 |
| 268 void GrGLGpu::contextAbandoned() { | 277 void GrGLGpu::contextAbandoned() { |
| 269 INHERITED::contextAbandoned(); | 278 INHERITED::contextAbandoned(); |
| 270 fProgramCache->abandon(); | 279 fProgramCache->abandon(); |
| 271 fHWProgramID = 0; | 280 fHWProgramID = 0; |
| 272 fTempSrcFBOID = 0; | 281 fTempSrcFBOID = 0; |
| 273 fTempDstFBOID = 0; | 282 fTempDstFBOID = 0; |
| 274 fStencilClearFBOID = 0; | 283 fStencilClearFBOID = 0; |
| 275 fCopyProgramArrayBuffer = 0; | 284 fCopyProgramArrayBuffer = 0; |
| 276 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 285 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
| 277 fCopyPrograms[i].fProgram = 0; | 286 fCopyPrograms[i].fProgram = 0; |
| 278 } | 287 } |
| 288 fWireRectProgram.fProgram = 0; | |
| 289 fWireRectArrayBuffer = 0; | |
| 279 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 290 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
| 280 this->glPathRendering()->abandonGpuResources(); | 291 this->glPathRendering()->abandonGpuResources(); |
| 281 } | 292 } |
| 282 } | 293 } |
| 283 | 294 |
| 284 /////////////////////////////////////////////////////////////////////////////// | 295 /////////////////////////////////////////////////////////////////////////////// |
| 285 | 296 |
| 286 void GrGLGpu::onResetContext(uint32_t resetBits) { | 297 void GrGLGpu::onResetContext(uint32_t resetBits) { |
| 287 // we don't use the zb at all | 298 // we don't use the zb at all |
| 288 if (resetBits & kMisc_GrGLBackendState) { | 299 if (resetBits & kMisc_GrGLBackendState) { |
| (...skipping 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2972 return true; | 2983 return true; |
| 2973 } | 2984 } |
| 2974 | 2985 |
| 2975 if (can_blit_framebuffer(dst, src, this)) { | 2986 if (can_blit_framebuffer(dst, src, this)) { |
| 2976 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); | 2987 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); |
| 2977 } | 2988 } |
| 2978 | 2989 |
| 2979 return false; | 2990 return false; |
| 2980 } | 2991 } |
| 2981 | 2992 |
| 2982 | |
| 2983 void GrGLGpu::createCopyPrograms() { | 2993 void GrGLGpu::createCopyPrograms() { |
| 2984 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 2994 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
| 2985 fCopyPrograms[i].fProgram = 0; | 2995 fCopyPrograms[i].fProgram = 0; |
| 2986 } | 2996 } |
| 2987 const char* version = this->glCaps().glslCaps()->versionDeclString(); | 2997 const char* version = this->glCaps().glslCaps()->versionDeclString(); |
| 2988 static const GrSLType kSamplerTypes[2] = { kSampler2D_GrSLType, kSamplerExte rnal_GrSLType }; | 2998 static const GrSLType kSamplerTypes[2] = { kSampler2D_GrSLType, kSamplerExte rnal_GrSLType }; |
| 2989 SkASSERT(2 == SK_ARRAY_COUNT(fCopyPrograms)); | 2999 SkASSERT(2 == SK_ARRAY_COUNT(fCopyPrograms)); |
| 2990 int programCount = this->glCaps().externalTextureSupport() ? 2 : 1; | 3000 int programCount = this->glCaps().externalTextureSupport() ? 2 : 1; |
| 2991 for (int i = 0; i < programCount; ++i) { | 3001 for (int i = 0; i < programCount; ++i) { |
| 2992 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttri bute_TypeModifier); | 3002 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttri bute_TypeModifier); |
| 2993 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, | 3003 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, |
| 2994 GrShaderVar::kUniform_TypeModifier); | 3004 GrShaderVar::kUniform_TypeModifier); |
| 2995 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, | 3005 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, |
| 2996 GrShaderVar::kUniform_TypeModifier); | 3006 GrShaderVar::kUniform_TypeModifier); |
| 2997 GrGLSLShaderVar uTexture("u_texture", kSamplerTypes[i], | 3007 GrGLSLShaderVar uTexture("u_texture", kSamplerTypes[i], |
| 2998 GrShaderVar::kUniform_TypeModifier); | 3008 GrShaderVar::kUniform_TypeModifier); |
| 2999 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, | 3009 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, |
| 3000 GrShaderVar::kVaryingOut_TypeModifier); | 3010 GrShaderVar::kVaryingOut_TypeModifier); |
| 3001 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, | 3011 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, |
| 3002 GrShaderVar::kOut_TypeModifier); | 3012 GrShaderVar::kOut_TypeModifier); |
| 3003 | 3013 |
| 3004 SkString vshaderTxt(version); | 3014 SkString vshaderTxt(version); |
| 3005 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3015 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 3006 vshaderTxt.append(";"); | 3016 vshaderTxt.append(";"); |
| 3007 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3017 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 3008 vshaderTxt.append(";"); | 3018 vshaderTxt.append(";"); |
| 3009 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3019 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 3010 vshaderTxt.append(";"); | 3020 vshaderTxt.append(";"); |
| 3011 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3021 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 3012 vshaderTxt.append(";"); | 3022 vshaderTxt.append(";"); |
| 3013 | 3023 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3073 GL_CALL_RET(fCopyPrograms[i].fPosXformUniform, | 3083 GL_CALL_RET(fCopyPrograms[i].fPosXformUniform, |
| 3074 GetUniformLocation(fCopyPrograms[i].fProgram, "u_posXform")) ; | 3084 GetUniformLocation(fCopyPrograms[i].fProgram, "u_posXform")) ; |
| 3075 GL_CALL_RET(fCopyPrograms[i].fTexCoordXformUniform, | 3085 GL_CALL_RET(fCopyPrograms[i].fTexCoordXformUniform, |
| 3076 GetUniformLocation(fCopyPrograms[i].fProgram, "u_texCoordXfo rm")); | 3086 GetUniformLocation(fCopyPrograms[i].fProgram, "u_texCoordXfo rm")); |
| 3077 | 3087 |
| 3078 GL_CALL(BindAttribLocation(fCopyPrograms[i].fProgram, 0, "a_vertex")); | 3088 GL_CALL(BindAttribLocation(fCopyPrograms[i].fProgram, 0, "a_vertex")); |
| 3079 | 3089 |
| 3080 GL_CALL(DeleteShader(vshader)); | 3090 GL_CALL(DeleteShader(vshader)); |
| 3081 GL_CALL(DeleteShader(fshader)); | 3091 GL_CALL(DeleteShader(fshader)); |
| 3082 } | 3092 } |
| 3083 | |
|
joshualitt
2015/12/03 14:43:52
I kind of like this space here, but ymmv
bsalomon
2015/12/03 16:25:31
Done.
| |
| 3084 GL_CALL(GenBuffers(1, &fCopyProgramArrayBuffer)); | 3093 GL_CALL(GenBuffers(1, &fCopyProgramArrayBuffer)); |
| 3085 fHWGeometryState.setVertexBufferID(this, fCopyProgramArrayBuffer); | 3094 fHWGeometryState.setVertexBufferID(this, fCopyProgramArrayBuffer); |
| 3086 static const GrGLfloat vdata[] = { | 3095 static const GrGLfloat vdata[] = { |
| 3087 0, 0, | 3096 0, 0, |
| 3088 0, 1, | 3097 0, 1, |
| 3089 1, 0, | 3098 1, 0, |
| 3090 1, 1 | 3099 1, 1 |
| 3091 }; | 3100 }; |
| 3092 GL_ALLOC_CALL(this->glInterface(), | 3101 GL_ALLOC_CALL(this->glInterface(), |
| 3093 BufferData(GR_GL_ARRAY_BUFFER, | 3102 BufferData(GR_GL_ARRAY_BUFFER, |
| 3094 (GrGLsizeiptr) sizeof(vdata), | 3103 (GrGLsizeiptr) sizeof(vdata), |
| 3095 vdata, // data ptr | 3104 vdata, // data ptr |
| 3096 GR_GL_STATIC_DRAW)); | 3105 GR_GL_STATIC_DRAW)); |
| 3097 } | 3106 } |
| 3098 | 3107 |
| 3108 void GrGLGpu::createWireRectProgram() { | |
|
joshualitt
2015/12/03 14:43:52
I wonder if we want to create a 'createBackendProg
bsalomon
2015/12/03 16:25:31
I'd prefer to wait on that. I think the !/$ is not
joshualitt
2015/12/03 16:30:14
agreed.
| |
| 3109 SkASSERT(!fWireRectProgram.fProgram); | |
| 3110 GrGLSLShaderVar uColor("u_color", kVec4f_GrSLType, GrShaderVar::kUniform_Typ eModifier); | |
| 3111 GrGLSLShaderVar uRect("u_rect", kVec4f_GrSLType, GrShaderVar::kUniform_TypeM odifier); | |
| 3112 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute _TypeModifier); | |
| 3113 const char* version = this->glCaps().glslCaps()->versionDeclString(); | |
| 3114 | |
| 3115 SkString vshaderTxt(version); | |
| 3116 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
| 3117 vshaderTxt.append(";"); | |
| 3118 uRect.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
| 3119 vshaderTxt.append(";"); | |
| 3120 vshaderTxt.append( | |
|
joshualitt
2015/12/03 14:43:52
A comment on this algorithm would be nice.
bsalomon
2015/12/03 16:25:31
Done.
| |
| 3121 "// Wire Rect Program VS\n" | |
| 3122 "void main() {" | |
| 3123 " gl_Position.x = u_rect.x + a_vertex.x * (u_rect.z - u_rect.x);" | |
| 3124 " gl_Position.y = u_rect.y + a_vertex.y * (u_rect.w - u_rect.y);" | |
| 3125 " gl_Position.zw = vec2(0, 1);" | |
| 3126 "}" | |
| 3127 ); | |
| 3128 | |
| 3129 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut _TypeModifier); | |
| 3130 | |
| 3131 SkString fshaderTxt(version); | |
| 3132 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | |
| 3133 *this->glCaps().glslCaps(), | |
| 3134 &fshaderTxt); | |
| 3135 uColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
| 3136 fshaderTxt.append(";"); | |
| 3137 const char* fsOutName; | |
| 3138 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { | |
| 3139 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
| 3140 fshaderTxt.append(";"); | |
| 3141 fsOutName = oFragColor.c_str(); | |
| 3142 } else { | |
| 3143 fsOutName = "gl_FragColor"; | |
| 3144 } | |
| 3145 fshaderTxt.appendf( | |
| 3146 "// Write Rect Program FS\n" | |
| 3147 "void main() {" | |
| 3148 " %s = %s;" | |
| 3149 "}", | |
| 3150 fsOutName, | |
| 3151 uColor.c_str() | |
| 3152 ); | |
| 3153 | |
| 3154 GL_CALL_RET(fWireRectProgram.fProgram, CreateProgram()); | |
| 3155 const char* str; | |
| 3156 GrGLint length; | |
| 3157 | |
| 3158 str = vshaderTxt.c_str(); | |
| 3159 length = SkToInt(vshaderTxt.size()); | |
| 3160 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram. fProgram, | |
| 3161 GR_GL_VERTEX_SHADER, &str, &le ngth, 1, | |
| 3162 &fStats); | |
| 3163 | |
| 3164 str = fshaderTxt.c_str(); | |
| 3165 length = SkToInt(fshaderTxt.size()); | |
| 3166 GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram. fProgram, | |
| 3167 GR_GL_FRAGMENT_SHADER, &str, & length, 1, | |
| 3168 &fStats); | |
| 3169 | |
| 3170 GL_CALL(LinkProgram(fWireRectProgram.fProgram)); | |
| 3171 | |
| 3172 GL_CALL_RET(fWireRectProgram.fColorUniform, | |
| 3173 GetUniformLocation(fWireRectProgram.fProgram, "u_color")); | |
| 3174 GL_CALL_RET(fWireRectProgram.fRectUniform, | |
| 3175 GetUniformLocation(fWireRectProgram.fProgram, "u_rect")); | |
| 3176 GL_CALL(BindAttribLocation(fWireRectProgram.fProgram, 0, "a_vertex")); | |
| 3177 | |
| 3178 GL_CALL(DeleteShader(vshader)); | |
| 3179 GL_CALL(DeleteShader(fshader)); | |
| 3180 GL_CALL(GenBuffers(1, &fWireRectArrayBuffer)); | |
| 3181 fHWGeometryState.setVertexBufferID(this, fWireRectArrayBuffer); | |
| 3182 static const GrGLfloat vdata[] = { | |
| 3183 0, 0, | |
| 3184 0, 1, | |
| 3185 1, 1, | |
| 3186 1, 0, | |
| 3187 }; | |
| 3188 GL_ALLOC_CALL(this->glInterface(), | |
| 3189 BufferData(GR_GL_ARRAY_BUFFER, | |
| 3190 (GrGLsizeiptr) sizeof(vdata), | |
| 3191 vdata, // data ptr | |
| 3192 GR_GL_STATIC_DRAW)); | |
| 3193 } | |
| 3194 | |
| 3195 void GrGLGpu::drawDebugWireRect(GrRenderTarget* rt, const SkIRect& rect, GrColor color) { | |
|
joshualitt
2015/12/03 14:43:52
Similar to the above, a 'drawBackend' abstraction
bsalomon
2015/12/03 16:25:31
I'm not sure what there is to abstract... this cal
joshualitt
2015/12/03 16:30:14
Yea, I mean, kind of a backend GrBatch / GrGeometr
| |
| 3196 this->handleDirtyContext(); | |
| 3197 if (!fWireRectProgram.fProgram) { | |
| 3198 this->createWireRectProgram(); | |
| 3199 } | |
| 3200 | |
| 3201 int w = rt->width(); | |
| 3202 int h = rt->height(); | |
| 3203 | |
| 3204 GrGLfloat verts[4]; | |
|
joshualitt
2015/12/03 14:43:52
Could you comment exactly what you are doing here?
| |
| 3205 verts[0] = SkIntToScalar(rect.fLeft) + 0.5f; | |
| 3206 verts[2] = SkIntToScalar(rect.fRight) - 0.5f; | |
| 3207 if (kBottomLeft_GrSurfaceOrigin == rt->origin()) { | |
| 3208 verts[1] = h - (SkIntToScalar(rect.fTop) + 0.5f); | |
| 3209 verts[3] = h - (SkIntToScalar(rect.fBottom) - 0.5f); | |
| 3210 } else { | |
| 3211 verts[1] = SkIntToScalar(rect.fTop) + 0.5f; | |
| 3212 verts[3] = SkIntToScalar(rect.fBottom) - 0.5f; | |
| 3213 } | |
| 3214 verts[0] = 2 * verts[0] / w - 1.0f; | |
| 3215 verts[1] = 2 * verts[1] / h - 1.0f; | |
| 3216 verts[2] = 2 * verts[2] / w - 1.0f; | |
| 3217 verts[3] = 2 * verts[3] / h - 1.0f; | |
| 3218 | |
| 3219 GrGLfloat channels[4]; | |
| 3220 static const GrGLfloat scale255 = 1.f / 255.f; | |
| 3221 channels[0] = GrColorUnpackR(color) * scale255; | |
| 3222 channels[1] = GrColorUnpackG(color) * scale255; | |
| 3223 channels[2] = GrColorUnpackB(color) * scale255; | |
| 3224 channels[3] = GrColorUnpackA(color) * scale255; | |
| 3225 | |
| 3226 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(rt->asRenderTarget() ); | |
| 3227 this->flushRenderTarget(glRT, &rect); | |
| 3228 | |
| 3229 GL_CALL(UseProgram(fWireRectProgram.fProgram)); | |
| 3230 fHWProgramID = fWireRectProgram.fProgram; | |
| 3231 | |
| 3232 fHWGeometryState.setVertexArrayID(this, 0); | |
| 3233 | |
| 3234 GrGLAttribArrayState* attribs = | |
| 3235 fHWGeometryState.bindArrayAndBufferToDraw(this, fWireRectArrayBuffer); | |
| 3236 attribs->set(this, 0, fWireRectArrayBuffer, 2, GR_GL_FLOAT, false, 2 * sizeo f(GrGLfloat), 0); | |
| 3237 attribs->disableUnusedArrays(this, 0x1); | |
| 3238 | |
| 3239 GL_CALL(Uniform4fv(fWireRectProgram.fRectUniform, 1, verts)); | |
| 3240 GL_CALL(Uniform4fv(fWireRectProgram.fColorUniform, 1, channels)); | |
| 3241 | |
| 3242 GrXferProcessor::BlendInfo blendInfo; | |
| 3243 blendInfo.reset(); | |
| 3244 this->flushBlend(blendInfo); | |
| 3245 this->flushColorWrite(true); | |
| 3246 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | |
| 3247 this->flushHWAAState(glRT, false); | |
| 3248 this->disableScissor(); | |
| 3249 GrStencilSettings stencil; | |
| 3250 stencil.setDisabled(); | |
| 3251 this->flushStencil(stencil); | |
| 3252 | |
| 3253 GL_CALL(DrawArrays(GR_GL_LINE_LOOP, 0, 4)); | |
| 3254 } | |
| 3255 | |
| 3256 | |
| 3099 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, | 3257 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, |
| 3100 GrSurface* src, | 3258 GrSurface* src, |
| 3101 const SkIRect& srcRect, | 3259 const SkIRect& srcRect, |
| 3102 const SkIPoint& dstPoint) { | 3260 const SkIPoint& dstPoint) { |
| 3103 int w = srcRect.width(); | 3261 int w = srcRect.width(); |
| 3104 int h = srcRect.height(); | 3262 int h = srcRect.height(); |
| 3105 | 3263 |
| 3106 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); | 3264 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); |
| 3107 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil terMode); | 3265 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil terMode); |
| 3108 this->bindTexture(0, params, srcTex); | 3266 this->bindTexture(0, params, srcTex); |
| 3109 | 3267 |
| 3110 GrGLRenderTarget* dstRT = static_cast<GrGLRenderTarget*>(dst->asRenderTarget ()); | 3268 GrGLRenderTarget* dstRT = static_cast<GrGLRenderTarget*>(dst->asRenderTarget ()); |
| 3111 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); | 3269 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); |
| 3112 this->flushRenderTarget(dstRT, &dstRect); | 3270 this->flushRenderTarget(dstRT, &dstRect); |
| 3113 | 3271 |
| 3114 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); | 3272 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); |
| 3115 | 3273 |
| 3116 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); | 3274 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); |
| 3117 fHWProgramID = fCopyPrograms[progIdx].fProgram; | 3275 fHWProgramID = fCopyPrograms[progIdx].fProgram; |
| 3118 | 3276 |
| 3119 fHWGeometryState.setVertexArrayID(this, 0); | 3277 fHWGeometryState.setVertexArrayID(this, 0); |
| 3120 | 3278 |
| 3121 GrGLAttribArrayState* attribs = | 3279 GrGLAttribArrayState* attribs = |
| 3122 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer) ; | 3280 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer) ; |
| 3123 attribs->set(this, 0, fCopyProgramArrayBuffer, 2, GR_GL_FLOAT, false, | 3281 attribs->set(this, 0, fCopyProgramArrayBuffer, 2, GR_GL_FLOAT, false, 2 * si zeof(GrGLfloat), 0); |
| 3124 2 * sizeof(GrGLfloat), 0); | |
| 3125 attribs->disableUnusedArrays(this, 0x1); | 3282 attribs->disableUnusedArrays(this, 0x1); |
| 3126 | 3283 |
| 3127 // dst rect edges in NDC (-1 to 1) | 3284 // dst rect edges in NDC (-1 to 1) |
| 3128 int dw = dst->width(); | 3285 int dw = dst->width(); |
| 3129 int dh = dst->height(); | 3286 int dh = dst->height(); |
| 3130 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; | 3287 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; |
| 3131 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; | 3288 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; |
| 3132 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; | 3289 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; |
| 3133 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; | 3290 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; |
| 3134 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { | 3291 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3398 this->setVertexArrayID(gpu, 0); | 3555 this->setVertexArrayID(gpu, 0); |
| 3399 } | 3556 } |
| 3400 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3557 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3401 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3558 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3402 fDefaultVertexArrayAttribState.resize(attrCount); | 3559 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3403 } | 3560 } |
| 3404 attribState = &fDefaultVertexArrayAttribState; | 3561 attribState = &fDefaultVertexArrayAttribState; |
| 3405 } | 3562 } |
| 3406 return attribState; | 3563 return attribState; |
| 3407 } | 3564 } |
| OLD | NEW |