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 |
235 this->createCopyPrograms(); | 236 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 | |
262 if (0 != fCopyProgramArrayBuffer) { | 261 if (0 != fCopyProgramArrayBuffer) { |
263 GL_CALL(DeleteBuffers(1, &fCopyProgramArrayBuffer)); | 262 GL_CALL(DeleteBuffers(1, &fCopyProgramArrayBuffer)); |
264 } | 263 } |
265 | 264 |
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 | |
274 delete fProgramCache; | 265 delete fProgramCache; |
275 } | 266 } |
276 | 267 |
277 void GrGLGpu::contextAbandoned() { | 268 void GrGLGpu::contextAbandoned() { |
278 INHERITED::contextAbandoned(); | 269 INHERITED::contextAbandoned(); |
279 fProgramCache->abandon(); | 270 fProgramCache->abandon(); |
280 fHWProgramID = 0; | 271 fHWProgramID = 0; |
281 fTempSrcFBOID = 0; | 272 fTempSrcFBOID = 0; |
282 fTempDstFBOID = 0; | 273 fTempDstFBOID = 0; |
283 fStencilClearFBOID = 0; | 274 fStencilClearFBOID = 0; |
284 fCopyProgramArrayBuffer = 0; | 275 fCopyProgramArrayBuffer = 0; |
285 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 276 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
286 fCopyPrograms[i].fProgram = 0; | 277 fCopyPrograms[i].fProgram = 0; |
287 } | 278 } |
288 fWireRectProgram.fProgram = 0; | |
289 fWireRectArrayBuffer = 0; | |
290 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 279 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
291 this->glPathRendering()->abandonGpuResources(); | 280 this->glPathRendering()->abandonGpuResources(); |
292 } | 281 } |
293 } | 282 } |
294 | 283 |
295 /////////////////////////////////////////////////////////////////////////////// | 284 /////////////////////////////////////////////////////////////////////////////// |
296 | 285 |
297 void GrGLGpu::onResetContext(uint32_t resetBits) { | 286 void GrGLGpu::onResetContext(uint32_t resetBits) { |
298 // we don't use the zb at all | 287 // we don't use the zb at all |
299 if (resetBits & kMisc_GrGLBackendState) { | 288 if (resetBits & kMisc_GrGLBackendState) { |
(...skipping 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2983 return true; | 2972 return true; |
2984 } | 2973 } |
2985 | 2974 |
2986 if (can_blit_framebuffer(dst, src, this)) { | 2975 if (can_blit_framebuffer(dst, src, this)) { |
2987 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); | 2976 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); |
2988 } | 2977 } |
2989 | 2978 |
2990 return false; | 2979 return false; |
2991 } | 2980 } |
2992 | 2981 |
| 2982 |
2993 void GrGLGpu::createCopyPrograms() { | 2983 void GrGLGpu::createCopyPrograms() { |
2994 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 2984 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
2995 fCopyPrograms[i].fProgram = 0; | 2985 fCopyPrograms[i].fProgram = 0; |
2996 } | 2986 } |
2997 const char* version = this->glCaps().glslCaps()->versionDeclString(); | 2987 const char* version = this->glCaps().glslCaps()->versionDeclString(); |
2998 static const GrSLType kSamplerTypes[2] = { kSampler2D_GrSLType, kSamplerExte
rnal_GrSLType }; | 2988 static const GrSLType kSamplerTypes[2] = { kSampler2D_GrSLType, kSamplerExte
rnal_GrSLType }; |
2999 SkASSERT(2 == SK_ARRAY_COUNT(fCopyPrograms)); | 2989 SkASSERT(2 == SK_ARRAY_COUNT(fCopyPrograms)); |
3000 int programCount = this->glCaps().externalTextureSupport() ? 2 : 1; | 2990 int programCount = this->glCaps().externalTextureSupport() ? 2 : 1; |
3001 for (int i = 0; i < programCount; ++i) { | 2991 for (int i = 0; i < programCount; ++i) { |
3002 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttri
bute_TypeModifier); | 2992 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttri
bute_TypeModifier); |
3003 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, | 2993 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, |
3004 GrShaderVar::kUniform_TypeModifier); | 2994 GrShaderVar::kUniform_TypeModifier); |
3005 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, | 2995 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, |
3006 GrShaderVar::kUniform_TypeModifier); | 2996 GrShaderVar::kUniform_TypeModifier); |
3007 GrGLSLShaderVar uTexture("u_texture", kSamplerTypes[i], | 2997 GrGLSLShaderVar uTexture("u_texture", kSamplerTypes[i], |
3008 GrShaderVar::kUniform_TypeModifier); | 2998 GrShaderVar::kUniform_TypeModifier); |
3009 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, | 2999 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, |
3010 GrShaderVar::kVaryingOut_TypeModifier); | 3000 GrShaderVar::kVaryingOut_TypeModifier); |
3011 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, | 3001 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, |
3012 GrShaderVar::kOut_TypeModifier); | 3002 GrShaderVar::kOut_TypeModifier); |
3013 | 3003 |
3014 SkString vshaderTxt(version); | 3004 SkString vshaderTxt(version); |
3015 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3005 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
3016 vshaderTxt.append(";"); | 3006 vshaderTxt.append(";"); |
3017 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3007 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
3018 vshaderTxt.append(";"); | 3008 vshaderTxt.append(";"); |
3019 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3009 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
3020 vshaderTxt.append(";"); | 3010 vshaderTxt.append(";"); |
3021 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3011 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
3022 vshaderTxt.append(";"); | 3012 vshaderTxt.append(";"); |
3023 | 3013 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3099 1, 0, | 3089 1, 0, |
3100 1, 1 | 3090 1, 1 |
3101 }; | 3091 }; |
3102 GL_ALLOC_CALL(this->glInterface(), | 3092 GL_ALLOC_CALL(this->glInterface(), |
3103 BufferData(GR_GL_ARRAY_BUFFER, | 3093 BufferData(GR_GL_ARRAY_BUFFER, |
3104 (GrGLsizeiptr) sizeof(vdata), | 3094 (GrGLsizeiptr) sizeof(vdata), |
3105 vdata, // data ptr | 3095 vdata, // data ptr |
3106 GR_GL_STATIC_DRAW)); | 3096 GR_GL_STATIC_DRAW)); |
3107 } | 3097 } |
3108 | 3098 |
3109 void GrGLGpu::createWireRectProgram() { | |
3110 SkASSERT(!fWireRectProgram.fProgram); | |
3111 GrGLSLShaderVar uColor("u_color", kVec4f_GrSLType, GrShaderVar::kUniform_Typ
eModifier); | |
3112 GrGLSLShaderVar uRect("u_rect", kVec4f_GrSLType, GrShaderVar::kUniform_TypeM
odifier); | |
3113 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute
_TypeModifier); | |
3114 const char* version = this->glCaps().glslCaps()->versionDeclString(); | |
3115 | |
3116 // The rect uniform specifies the rectangle in NDC space as a vec4 (left,top
,right,bottom). The | |
3117 // program is used with a vbo containing the unit square. Vertices are compu
ted from the rect | |
3118 // uniform using the 4 vbo vertices. | |
3119 SkString vshaderTxt(version); | |
3120 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
3121 vshaderTxt.append(";"); | |
3122 uRect.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
3123 vshaderTxt.append(";"); | |
3124 vshaderTxt.append( | |
3125 "// Wire Rect Program VS\n" | |
3126 "void main() {" | |
3127 " gl_Position.x = u_rect.x + a_vertex.x * (u_rect.z - u_rect.x);" | |
3128 " gl_Position.y = u_rect.y + a_vertex.y * (u_rect.w - u_rect.y);" | |
3129 " gl_Position.zw = vec2(0, 1);" | |
3130 "}" | |
3131 ); | |
3132 | |
3133 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut
_TypeModifier); | |
3134 | |
3135 SkString fshaderTxt(version); | |
3136 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | |
3137 *this->glCaps().glslCaps(), | |
3138 &fshaderTxt); | |
3139 uColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
3140 fshaderTxt.append(";"); | |
3141 const char* fsOutName; | |
3142 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { | |
3143 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
3144 fshaderTxt.append(";"); | |
3145 fsOutName = oFragColor.c_str(); | |
3146 } else { | |
3147 fsOutName = "gl_FragColor"; | |
3148 } | |
3149 fshaderTxt.appendf( | |
3150 "// Write Rect Program FS\n" | |
3151 "void main() {" | |
3152 " %s = %s;" | |
3153 "}", | |
3154 fsOutName, | |
3155 uColor.c_str() | |
3156 ); | |
3157 | |
3158 GL_CALL_RET(fWireRectProgram.fProgram, CreateProgram()); | |
3159 const char* str; | |
3160 GrGLint length; | |
3161 | |
3162 str = vshaderTxt.c_str(); | |
3163 length = SkToInt(vshaderTxt.size()); | |
3164 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram.
fProgram, | |
3165 GR_GL_VERTEX_SHADER, &str, &le
ngth, 1, | |
3166 &fStats); | |
3167 | |
3168 str = fshaderTxt.c_str(); | |
3169 length = SkToInt(fshaderTxt.size()); | |
3170 GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram.
fProgram, | |
3171 GR_GL_FRAGMENT_SHADER, &str, &
length, 1, | |
3172 &fStats); | |
3173 | |
3174 GL_CALL(LinkProgram(fWireRectProgram.fProgram)); | |
3175 | |
3176 GL_CALL_RET(fWireRectProgram.fColorUniform, | |
3177 GetUniformLocation(fWireRectProgram.fProgram, "u_color")); | |
3178 GL_CALL_RET(fWireRectProgram.fRectUniform, | |
3179 GetUniformLocation(fWireRectProgram.fProgram, "u_rect")); | |
3180 GL_CALL(BindAttribLocation(fWireRectProgram.fProgram, 0, "a_vertex")); | |
3181 | |
3182 GL_CALL(DeleteShader(vshader)); | |
3183 GL_CALL(DeleteShader(fshader)); | |
3184 GL_CALL(GenBuffers(1, &fWireRectArrayBuffer)); | |
3185 fHWGeometryState.setVertexBufferID(this, fWireRectArrayBuffer); | |
3186 static const GrGLfloat vdata[] = { | |
3187 0, 0, | |
3188 0, 1, | |
3189 1, 1, | |
3190 1, 0, | |
3191 }; | |
3192 GL_ALLOC_CALL(this->glInterface(), | |
3193 BufferData(GR_GL_ARRAY_BUFFER, | |
3194 (GrGLsizeiptr) sizeof(vdata), | |
3195 vdata, // data ptr | |
3196 GR_GL_STATIC_DRAW)); | |
3197 } | |
3198 | |
3199 void GrGLGpu::drawDebugWireRect(GrRenderTarget* rt, const SkIRect& rect, GrColor
color) { | |
3200 this->handleDirtyContext(); | |
3201 if (!fWireRectProgram.fProgram) { | |
3202 this->createWireRectProgram(); | |
3203 } | |
3204 | |
3205 int w = rt->width(); | |
3206 int h = rt->height(); | |
3207 | |
3208 // Compute the edges of the rectangle (top,left,right,bottom) in NDC space.
Must consider | |
3209 // whether the render target is flipped or not. | |
3210 GrGLfloat edges[4]; | |
3211 edges[0] = SkIntToScalar(rect.fLeft) + 0.5f; | |
3212 edges[2] = SkIntToScalar(rect.fRight) - 0.5f; | |
3213 if (kBottomLeft_GrSurfaceOrigin == rt->origin()) { | |
3214 edges[1] = h - (SkIntToScalar(rect.fTop) + 0.5f); | |
3215 edges[3] = h - (SkIntToScalar(rect.fBottom) - 0.5f); | |
3216 } else { | |
3217 edges[1] = SkIntToScalar(rect.fTop) + 0.5f; | |
3218 edges[3] = SkIntToScalar(rect.fBottom) - 0.5f; | |
3219 } | |
3220 edges[0] = 2 * edges[0] / w - 1.0f; | |
3221 edges[1] = 2 * edges[1] / h - 1.0f; | |
3222 edges[2] = 2 * edges[2] / w - 1.0f; | |
3223 edges[3] = 2 * edges[3] / h - 1.0f; | |
3224 | |
3225 GrGLfloat channels[4]; | |
3226 static const GrGLfloat scale255 = 1.f / 255.f; | |
3227 channels[0] = GrColorUnpackR(color) * scale255; | |
3228 channels[1] = GrColorUnpackG(color) * scale255; | |
3229 channels[2] = GrColorUnpackB(color) * scale255; | |
3230 channels[3] = GrColorUnpackA(color) * scale255; | |
3231 | |
3232 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(rt->asRenderTarget()
); | |
3233 this->flushRenderTarget(glRT, &rect); | |
3234 | |
3235 GL_CALL(UseProgram(fWireRectProgram.fProgram)); | |
3236 fHWProgramID = fWireRectProgram.fProgram; | |
3237 | |
3238 fHWGeometryState.setVertexArrayID(this, 0); | |
3239 | |
3240 GrGLAttribArrayState* attribs = | |
3241 fHWGeometryState.bindArrayAndBufferToDraw(this, fWireRectArrayBuffer); | |
3242 attribs->set(this, 0, fWireRectArrayBuffer, 2, GR_GL_FLOAT, false, 2 * sizeo
f(GrGLfloat), 0); | |
3243 attribs->disableUnusedArrays(this, 0x1); | |
3244 | |
3245 GL_CALL(Uniform4fv(fWireRectProgram.fRectUniform, 1, edges)); | |
3246 GL_CALL(Uniform4fv(fWireRectProgram.fColorUniform, 1, channels)); | |
3247 | |
3248 GrXferProcessor::BlendInfo blendInfo; | |
3249 blendInfo.reset(); | |
3250 this->flushBlend(blendInfo); | |
3251 this->flushColorWrite(true); | |
3252 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | |
3253 this->flushHWAAState(glRT, false); | |
3254 this->disableScissor(); | |
3255 GrStencilSettings stencil; | |
3256 stencil.setDisabled(); | |
3257 this->flushStencil(stencil); | |
3258 | |
3259 GL_CALL(DrawArrays(GR_GL_LINE_LOOP, 0, 4)); | |
3260 } | |
3261 | |
3262 | |
3263 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, | 3099 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, |
3264 GrSurface* src, | 3100 GrSurface* src, |
3265 const SkIRect& srcRect, | 3101 const SkIRect& srcRect, |
3266 const SkIPoint& dstPoint) { | 3102 const SkIPoint& dstPoint) { |
3267 int w = srcRect.width(); | 3103 int w = srcRect.width(); |
3268 int h = srcRect.height(); | 3104 int h = srcRect.height(); |
3269 | 3105 |
3270 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); | 3106 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); |
3271 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil
terMode); | 3107 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil
terMode); |
3272 this->bindTexture(0, params, srcTex); | 3108 this->bindTexture(0, params, srcTex); |
3273 | 3109 |
3274 GrGLRenderTarget* dstRT = static_cast<GrGLRenderTarget*>(dst->asRenderTarget
()); | 3110 GrGLRenderTarget* dstRT = static_cast<GrGLRenderTarget*>(dst->asRenderTarget
()); |
3275 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); | 3111 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); |
3276 this->flushRenderTarget(dstRT, &dstRect); | 3112 this->flushRenderTarget(dstRT, &dstRect); |
3277 | 3113 |
3278 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); | 3114 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); |
3279 | 3115 |
3280 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); | 3116 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); |
3281 fHWProgramID = fCopyPrograms[progIdx].fProgram; | 3117 fHWProgramID = fCopyPrograms[progIdx].fProgram; |
3282 | 3118 |
3283 fHWGeometryState.setVertexArrayID(this, 0); | 3119 fHWGeometryState.setVertexArrayID(this, 0); |
3284 | 3120 |
3285 GrGLAttribArrayState* attribs = | 3121 GrGLAttribArrayState* attribs = |
3286 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer)
; | 3122 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer)
; |
3287 attribs->set(this, 0, fCopyProgramArrayBuffer, 2, GR_GL_FLOAT, false, 2 * si
zeof(GrGLfloat), 0); | 3123 attribs->set(this, 0, fCopyProgramArrayBuffer, 2, GR_GL_FLOAT, false, |
| 3124 2 * sizeof(GrGLfloat), 0); |
3288 attribs->disableUnusedArrays(this, 0x1); | 3125 attribs->disableUnusedArrays(this, 0x1); |
3289 | 3126 |
3290 // dst rect edges in NDC (-1 to 1) | 3127 // dst rect edges in NDC (-1 to 1) |
3291 int dw = dst->width(); | 3128 int dw = dst->width(); |
3292 int dh = dst->height(); | 3129 int dh = dst->height(); |
3293 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; | 3130 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; |
3294 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; | 3131 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; |
3295 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; | 3132 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; |
3296 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; | 3133 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; |
3297 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { | 3134 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3565 this->setVertexArrayID(gpu, 0); | 3402 this->setVertexArrayID(gpu, 0); |
3566 } | 3403 } |
3567 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3404 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3568 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3405 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3569 fDefaultVertexArrayAttribState.resize(attrCount); | 3406 fDefaultVertexArrayAttribState.resize(attrCount); |
3570 } | 3407 } |
3571 attribState = &fDefaultVertexArrayAttribState; | 3408 attribState = &fDefaultVertexArrayAttribState; |
3572 } | 3409 } |
3573 return attribState; | 3410 return attribState; |
3574 } | 3411 } |
OLD | NEW |