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 fWireRectArrayBuffer = 0; |
237 } | 238 } |
238 | 239 |
239 GrGLGpu::~GrGLGpu() { | 240 GrGLGpu::~GrGLGpu() { |
240 if (0 != fHWProgramID) { | 241 if (0 != fHWProgramID) { |
241 // detach the current program so there is no confusion on OpenGL's part | 242 // detach the current program so there is no confusion on OpenGL's part |
242 // that we want it to be deleted | 243 // that we want it to be deleted |
243 GL_CALL(UseProgram(0)); | 244 GL_CALL(UseProgram(0)); |
244 } | 245 } |
245 | 246 |
246 if (0 != fTempSrcFBOID) { | 247 if (0 != fTempSrcFBOID) { |
247 GL_CALL(DeleteFramebuffers(1, &fTempSrcFBOID)); | 248 GL_CALL(DeleteFramebuffers(1, &fTempSrcFBOID)); |
248 } | 249 } |
249 if (0 != fTempDstFBOID) { | 250 if (0 != fTempDstFBOID) { |
250 GL_CALL(DeleteFramebuffers(1, &fTempDstFBOID)); | 251 GL_CALL(DeleteFramebuffers(1, &fTempDstFBOID)); |
251 } | 252 } |
252 if (0 != fStencilClearFBOID) { | 253 if (0 != fStencilClearFBOID) { |
253 GL_CALL(DeleteFramebuffers(1, &fStencilClearFBOID)); | 254 GL_CALL(DeleteFramebuffers(1, &fStencilClearFBOID)); |
254 } | 255 } |
255 | 256 |
256 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 257 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
257 if (0 != fCopyPrograms[i].fProgram) { | 258 if (0 != fCopyPrograms[i].fProgram) { |
258 GL_CALL(DeleteProgram(fCopyPrograms[i].fProgram)); | 259 GL_CALL(DeleteProgram(fCopyPrograms[i].fProgram)); |
259 } | 260 } |
260 } | 261 } |
| 262 |
261 if (0 != fCopyProgramArrayBuffer) { | 263 if (0 != fCopyProgramArrayBuffer) { |
262 GL_CALL(DeleteBuffers(1, &fCopyProgramArrayBuffer)); | 264 GL_CALL(DeleteBuffers(1, &fCopyProgramArrayBuffer)); |
263 } | 265 } |
264 | 266 |
| 267 if (0 != fWireRectProgram.fProgram) { |
| 268 GL_CALL(DeleteProgram(fWireRectProgram.fProgram)); |
| 269 } |
| 270 |
| 271 if (0 != fWireRectArrayBuffer) { |
| 272 GL_CALL(DeleteBuffers(1, &fWireRectArrayBuffer)); |
| 273 } |
| 274 |
265 delete fProgramCache; | 275 delete fProgramCache; |
266 } | 276 } |
267 | 277 |
268 void GrGLGpu::contextAbandoned() { | 278 void GrGLGpu::contextAbandoned() { |
269 INHERITED::contextAbandoned(); | 279 INHERITED::contextAbandoned(); |
270 fProgramCache->abandon(); | 280 fProgramCache->abandon(); |
271 fHWProgramID = 0; | 281 fHWProgramID = 0; |
272 fTempSrcFBOID = 0; | 282 fTempSrcFBOID = 0; |
273 fTempDstFBOID = 0; | 283 fTempDstFBOID = 0; |
274 fStencilClearFBOID = 0; | 284 fStencilClearFBOID = 0; |
275 fCopyProgramArrayBuffer = 0; | 285 fCopyProgramArrayBuffer = 0; |
276 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 286 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
277 fCopyPrograms[i].fProgram = 0; | 287 fCopyPrograms[i].fProgram = 0; |
278 } | 288 } |
| 289 fWireRectProgram.fProgram = 0; |
| 290 fWireRectArrayBuffer = 0; |
279 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 291 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
280 this->glPathRendering()->abandonGpuResources(); | 292 this->glPathRendering()->abandonGpuResources(); |
281 } | 293 } |
282 } | 294 } |
283 | 295 |
284 /////////////////////////////////////////////////////////////////////////////// | 296 /////////////////////////////////////////////////////////////////////////////// |
285 | 297 |
286 void GrGLGpu::onResetContext(uint32_t resetBits) { | 298 void GrGLGpu::onResetContext(uint32_t resetBits) { |
287 // we don't use the zb at all | 299 // we don't use the zb at all |
288 if (resetBits & kMisc_GrGLBackendState) { | 300 if (resetBits & kMisc_GrGLBackendState) { |
(...skipping 2720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3009 return true; | 3021 return true; |
3010 } | 3022 } |
3011 | 3023 |
3012 if (can_blit_framebuffer(dst, src, this)) { | 3024 if (can_blit_framebuffer(dst, src, this)) { |
3013 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); | 3025 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); |
3014 } | 3026 } |
3015 | 3027 |
3016 return false; | 3028 return false; |
3017 } | 3029 } |
3018 | 3030 |
3019 | |
3020 void GrGLGpu::createCopyPrograms() { | 3031 void GrGLGpu::createCopyPrograms() { |
3021 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 3032 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { |
3022 fCopyPrograms[i].fProgram = 0; | 3033 fCopyPrograms[i].fProgram = 0; |
3023 } | 3034 } |
3024 const char* version = this->glCaps().glslCaps()->versionDeclString(); | 3035 const char* version = this->glCaps().glslCaps()->versionDeclString(); |
3025 static const GrSLType kSamplerTypes[2] = { kSampler2D_GrSLType, kSamplerExte
rnal_GrSLType }; | 3036 static const GrSLType kSamplerTypes[2] = { kSampler2D_GrSLType, kSamplerExte
rnal_GrSLType }; |
3026 SkASSERT(2 == SK_ARRAY_COUNT(fCopyPrograms)); | 3037 SkASSERT(2 == SK_ARRAY_COUNT(fCopyPrograms)); |
3027 int programCount = this->glCaps().externalTextureSupport() ? 2 : 1; | 3038 int programCount = this->glCaps().externalTextureSupport() ? 2 : 1; |
3028 for (int i = 0; i < programCount; ++i) { | 3039 for (int i = 0; i < programCount; ++i) { |
3029 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttri
bute_TypeModifier); | 3040 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttri
bute_TypeModifier); |
3030 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, | 3041 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, |
3031 GrShaderVar::kUniform_TypeModifier); | 3042 GrShaderVar::kUniform_TypeModifier); |
3032 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, | 3043 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, |
3033 GrShaderVar::kUniform_TypeModifier); | 3044 GrShaderVar::kUniform_TypeModifier); |
3034 GrGLSLShaderVar uTexture("u_texture", kSamplerTypes[i], | 3045 GrGLSLShaderVar uTexture("u_texture", kSamplerTypes[i], |
3035 GrShaderVar::kUniform_TypeModifier); | 3046 GrShaderVar::kUniform_TypeModifier); |
3036 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, | 3047 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, |
3037 GrShaderVar::kVaryingOut_TypeModifier); | 3048 GrShaderVar::kVaryingOut_TypeModifier); |
3038 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, | 3049 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, |
3039 GrShaderVar::kOut_TypeModifier); | 3050 GrShaderVar::kOut_TypeModifier); |
3040 | 3051 |
3041 SkString vshaderTxt(version); | 3052 SkString vshaderTxt(version); |
3042 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3053 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
3043 vshaderTxt.append(";"); | 3054 vshaderTxt.append(";"); |
3044 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3055 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
3045 vshaderTxt.append(";"); | 3056 vshaderTxt.append(";"); |
3046 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3057 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
3047 vshaderTxt.append(";"); | 3058 vshaderTxt.append(";"); |
3048 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 3059 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
3049 vshaderTxt.append(";"); | 3060 vshaderTxt.append(";"); |
3050 | 3061 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3126 1, 0, | 3137 1, 0, |
3127 1, 1 | 3138 1, 1 |
3128 }; | 3139 }; |
3129 GL_ALLOC_CALL(this->glInterface(), | 3140 GL_ALLOC_CALL(this->glInterface(), |
3130 BufferData(GR_GL_ARRAY_BUFFER, | 3141 BufferData(GR_GL_ARRAY_BUFFER, |
3131 (GrGLsizeiptr) sizeof(vdata), | 3142 (GrGLsizeiptr) sizeof(vdata), |
3132 vdata, // data ptr | 3143 vdata, // data ptr |
3133 GR_GL_STATIC_DRAW)); | 3144 GR_GL_STATIC_DRAW)); |
3134 } | 3145 } |
3135 | 3146 |
| 3147 void GrGLGpu::createWireRectProgram() { |
| 3148 SkASSERT(!fWireRectProgram.fProgram); |
| 3149 GrGLSLShaderVar uColor("u_color", kVec4f_GrSLType, GrShaderVar::kUniform_Typ
eModifier); |
| 3150 GrGLSLShaderVar uRect("u_rect", kVec4f_GrSLType, GrShaderVar::kUniform_TypeM
odifier); |
| 3151 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute
_TypeModifier); |
| 3152 const char* version = this->glCaps().glslCaps()->versionDeclString(); |
| 3153 |
| 3154 // The rect uniform specifies the rectangle in NDC space as a vec4 (left,top
,right,bottom). The |
| 3155 // program is used with a vbo containing the unit square. Vertices are compu
ted from the rect |
| 3156 // uniform using the 4 vbo vertices. |
| 3157 SkString vshaderTxt(version); |
| 3158 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 3159 vshaderTxt.append(";"); |
| 3160 uRect.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 3161 vshaderTxt.append(";"); |
| 3162 vshaderTxt.append( |
| 3163 "// Wire Rect Program VS\n" |
| 3164 "void main() {" |
| 3165 " gl_Position.x = u_rect.x + a_vertex.x * (u_rect.z - u_rect.x);" |
| 3166 " gl_Position.y = u_rect.y + a_vertex.y * (u_rect.w - u_rect.y);" |
| 3167 " gl_Position.zw = vec2(0, 1);" |
| 3168 "}" |
| 3169 ); |
| 3170 |
| 3171 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut
_TypeModifier); |
| 3172 |
| 3173 SkString fshaderTxt(version); |
| 3174 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, |
| 3175 *this->glCaps().glslCaps(), |
| 3176 &fshaderTxt); |
| 3177 uColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
| 3178 fshaderTxt.append(";"); |
| 3179 const char* fsOutName; |
| 3180 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { |
| 3181 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
| 3182 fshaderTxt.append(";"); |
| 3183 fsOutName = oFragColor.c_str(); |
| 3184 } else { |
| 3185 fsOutName = "gl_FragColor"; |
| 3186 } |
| 3187 fshaderTxt.appendf( |
| 3188 "// Write Rect Program FS\n" |
| 3189 "void main() {" |
| 3190 " %s = %s;" |
| 3191 "}", |
| 3192 fsOutName, |
| 3193 uColor.c_str() |
| 3194 ); |
| 3195 |
| 3196 GL_CALL_RET(fWireRectProgram.fProgram, CreateProgram()); |
| 3197 const char* str; |
| 3198 GrGLint length; |
| 3199 |
| 3200 str = vshaderTxt.c_str(); |
| 3201 length = SkToInt(vshaderTxt.size()); |
| 3202 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram.
fProgram, |
| 3203 GR_GL_VERTEX_SHADER, &str, &le
ngth, 1, |
| 3204 &fStats); |
| 3205 |
| 3206 str = fshaderTxt.c_str(); |
| 3207 length = SkToInt(fshaderTxt.size()); |
| 3208 GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram.
fProgram, |
| 3209 GR_GL_FRAGMENT_SHADER, &str, &
length, 1, |
| 3210 &fStats); |
| 3211 |
| 3212 GL_CALL(LinkProgram(fWireRectProgram.fProgram)); |
| 3213 |
| 3214 GL_CALL_RET(fWireRectProgram.fColorUniform, |
| 3215 GetUniformLocation(fWireRectProgram.fProgram, "u_color")); |
| 3216 GL_CALL_RET(fWireRectProgram.fRectUniform, |
| 3217 GetUniformLocation(fWireRectProgram.fProgram, "u_rect")); |
| 3218 GL_CALL(BindAttribLocation(fWireRectProgram.fProgram, 0, "a_vertex")); |
| 3219 |
| 3220 GL_CALL(DeleteShader(vshader)); |
| 3221 GL_CALL(DeleteShader(fshader)); |
| 3222 GL_CALL(GenBuffers(1, &fWireRectArrayBuffer)); |
| 3223 fHWGeometryState.setVertexBufferID(this, fWireRectArrayBuffer); |
| 3224 static const GrGLfloat vdata[] = { |
| 3225 0, 0, |
| 3226 0, 1, |
| 3227 1, 1, |
| 3228 1, 0, |
| 3229 }; |
| 3230 GL_ALLOC_CALL(this->glInterface(), |
| 3231 BufferData(GR_GL_ARRAY_BUFFER, |
| 3232 (GrGLsizeiptr) sizeof(vdata), |
| 3233 vdata, // data ptr |
| 3234 GR_GL_STATIC_DRAW)); |
| 3235 } |
| 3236 |
| 3237 void GrGLGpu::drawDebugWireRect(GrRenderTarget* rt, const SkIRect& rect, GrColor
color) { |
| 3238 this->handleDirtyContext(); |
| 3239 if (!fWireRectProgram.fProgram) { |
| 3240 this->createWireRectProgram(); |
| 3241 } |
| 3242 |
| 3243 int w = rt->width(); |
| 3244 int h = rt->height(); |
| 3245 |
| 3246 // Compute the edges of the rectangle (top,left,right,bottom) in NDC space.
Must consider |
| 3247 // whether the render target is flipped or not. |
| 3248 GrGLfloat edges[4]; |
| 3249 edges[0] = SkIntToScalar(rect.fLeft) + 0.5f; |
| 3250 edges[2] = SkIntToScalar(rect.fRight) - 0.5f; |
| 3251 if (kBottomLeft_GrSurfaceOrigin == rt->origin()) { |
| 3252 edges[1] = h - (SkIntToScalar(rect.fTop) + 0.5f); |
| 3253 edges[3] = h - (SkIntToScalar(rect.fBottom) - 0.5f); |
| 3254 } else { |
| 3255 edges[1] = SkIntToScalar(rect.fTop) + 0.5f; |
| 3256 edges[3] = SkIntToScalar(rect.fBottom) - 0.5f; |
| 3257 } |
| 3258 edges[0] = 2 * edges[0] / w - 1.0f; |
| 3259 edges[1] = 2 * edges[1] / h - 1.0f; |
| 3260 edges[2] = 2 * edges[2] / w - 1.0f; |
| 3261 edges[3] = 2 * edges[3] / h - 1.0f; |
| 3262 |
| 3263 GrGLfloat channels[4]; |
| 3264 static const GrGLfloat scale255 = 1.f / 255.f; |
| 3265 channels[0] = GrColorUnpackR(color) * scale255; |
| 3266 channels[1] = GrColorUnpackG(color) * scale255; |
| 3267 channels[2] = GrColorUnpackB(color) * scale255; |
| 3268 channels[3] = GrColorUnpackA(color) * scale255; |
| 3269 |
| 3270 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(rt->asRenderTarget()
); |
| 3271 this->flushRenderTarget(glRT, &rect); |
| 3272 |
| 3273 GL_CALL(UseProgram(fWireRectProgram.fProgram)); |
| 3274 fHWProgramID = fWireRectProgram.fProgram; |
| 3275 |
| 3276 fHWGeometryState.setVertexArrayID(this, 0); |
| 3277 |
| 3278 GrGLAttribArrayState* attribs = |
| 3279 fHWGeometryState.bindArrayAndBufferToDraw(this, fWireRectArrayBuffer); |
| 3280 attribs->set(this, 0, fWireRectArrayBuffer, 2, GR_GL_FLOAT, false, 2 * sizeo
f(GrGLfloat), 0); |
| 3281 attribs->disableUnusedArrays(this, 0x1); |
| 3282 |
| 3283 GL_CALL(Uniform4fv(fWireRectProgram.fRectUniform, 1, edges)); |
| 3284 GL_CALL(Uniform4fv(fWireRectProgram.fColorUniform, 1, channels)); |
| 3285 |
| 3286 GrXferProcessor::BlendInfo blendInfo; |
| 3287 blendInfo.reset(); |
| 3288 this->flushBlend(blendInfo); |
| 3289 this->flushColorWrite(true); |
| 3290 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
| 3291 this->flushHWAAState(glRT, false); |
| 3292 this->disableScissor(); |
| 3293 GrStencilSettings stencil; |
| 3294 stencil.setDisabled(); |
| 3295 this->flushStencil(stencil); |
| 3296 |
| 3297 GL_CALL(DrawArrays(GR_GL_LINE_LOOP, 0, 4)); |
| 3298 } |
| 3299 |
| 3300 |
3136 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, | 3301 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, |
3137 GrSurface* src, | 3302 GrSurface* src, |
3138 const SkIRect& srcRect, | 3303 const SkIRect& srcRect, |
3139 const SkIPoint& dstPoint) { | 3304 const SkIPoint& dstPoint) { |
3140 int w = srcRect.width(); | 3305 int w = srcRect.width(); |
3141 int h = srcRect.height(); | 3306 int h = srcRect.height(); |
3142 | 3307 |
3143 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); | 3308 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); |
3144 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil
terMode); | 3309 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil
terMode); |
3145 this->bindTexture(0, params, srcTex); | 3310 this->bindTexture(0, params, srcTex); |
3146 | 3311 |
3147 GrGLRenderTarget* dstRT = static_cast<GrGLRenderTarget*>(dst->asRenderTarget
()); | 3312 GrGLRenderTarget* dstRT = static_cast<GrGLRenderTarget*>(dst->asRenderTarget
()); |
3148 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); | 3313 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); |
3149 this->flushRenderTarget(dstRT, &dstRect); | 3314 this->flushRenderTarget(dstRT, &dstRect); |
3150 | 3315 |
3151 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); | 3316 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); |
3152 | 3317 |
3153 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); | 3318 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); |
3154 fHWProgramID = fCopyPrograms[progIdx].fProgram; | 3319 fHWProgramID = fCopyPrograms[progIdx].fProgram; |
3155 | 3320 |
3156 fHWGeometryState.setVertexArrayID(this, 0); | 3321 fHWGeometryState.setVertexArrayID(this, 0); |
3157 | 3322 |
3158 GrGLAttribArrayState* attribs = | 3323 GrGLAttribArrayState* attribs = |
3159 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer)
; | 3324 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer)
; |
3160 attribs->set(this, 0, fCopyProgramArrayBuffer, 2, GR_GL_FLOAT, false, | 3325 attribs->set(this, 0, fCopyProgramArrayBuffer, 2, GR_GL_FLOAT, false, 2 * si
zeof(GrGLfloat), 0); |
3161 2 * sizeof(GrGLfloat), 0); | |
3162 attribs->disableUnusedArrays(this, 0x1); | 3326 attribs->disableUnusedArrays(this, 0x1); |
3163 | 3327 |
3164 // dst rect edges in NDC (-1 to 1) | 3328 // dst rect edges in NDC (-1 to 1) |
3165 int dw = dst->width(); | 3329 int dw = dst->width(); |
3166 int dh = dst->height(); | 3330 int dh = dst->height(); |
3167 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; | 3331 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; |
3168 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; | 3332 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; |
3169 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; | 3333 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; |
3170 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; | 3334 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; |
3171 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { | 3335 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3439 this->setVertexArrayID(gpu, 0); | 3603 this->setVertexArrayID(gpu, 0); |
3440 } | 3604 } |
3441 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3605 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3442 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3606 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3443 fDefaultVertexArrayAttribState.resize(attrCount); | 3607 fDefaultVertexArrayAttribState.resize(attrCount); |
3444 } | 3608 } |
3445 attribState = &fDefaultVertexArrayAttribState; | 3609 attribState = &fDefaultVertexArrayAttribState; |
3446 } | 3610 } |
3447 return attribState; | 3611 return attribState; |
3448 } | 3612 } |
OLD | NEW |