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 #include "GrGpuGL.h" | 8 #include "GrGpuGL.h" |
| 9 | 9 |
| 10 #include "GrEffect.h" | 10 #include "GrEffect.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 void GrGpuGL::flushPathStencilMatrix() { | 205 void GrGpuGL::flushPathStencilMatrix() { |
| 206 const SkMatrix& viewMatrix = this->getDrawState().getViewMatrix(); | 206 const SkMatrix& viewMatrix = this->getDrawState().getViewMatrix(); |
| 207 const GrRenderTarget* rt = this->getDrawState().getRenderTarget(); | 207 const GrRenderTarget* rt = this->getDrawState().getRenderTarget(); |
| 208 SkISize size; | 208 SkISize size; |
| 209 size.set(rt->width(), rt->height()); | 209 size.set(rt->width(), rt->height()); |
| 210 const SkMatrix& vm = this->getDrawState().getViewMatrix(); | 210 const SkMatrix& vm = this->getDrawState().getViewMatrix(); |
| 211 | 211 |
| 212 if (fHWProjectionMatrixState.fRenderTargetOrigin != rt->origin() || | 212 if (fHWProjectionMatrixState.fRenderTargetOrigin != rt->origin() || |
| 213 !fHWProjectionMatrixState.fViewMatrix.cheapEqualTo(viewMatrix) || | 213 !fHWProjectionMatrixState.fViewMatrix.cheapEqualTo(viewMatrix) || |
| 214 fHWProjectionMatrixState.fRenderTargetSize!= size) { | 214 fHWProjectionMatrixState.fRenderTargetSize!= size) { |
| 215 // rescale the coords from skia's "device" coords to GL's normalized coo rds, | |
| 216 // and perform a y-flip if required. | |
| 217 SkMatrix m; | |
| 218 if (kBottomLeft_GrSurfaceOrigin == rt->origin()) { | |
| 219 m.setScale(SkIntToScalar(2) / rt->width(), SkIntToScalar(-2) / rt->h eight()); | |
| 220 m.postTranslate(-SK_Scalar1, SK_Scalar1); | |
| 221 } else { | |
| 222 m.setScale(SkIntToScalar(2) / rt->width(), SkIntToScalar(2) / rt->he ight()); | |
| 223 m.postTranslate(-SK_Scalar1, -SK_Scalar1); | |
| 224 } | |
| 225 m.preConcat(vm); | |
| 226 | 215 |
| 227 // GL wants a column-major 4x4. | |
| 228 GrGLfloat mv[] = { | |
| 229 // col 0 | |
| 230 SkScalarToFloat(m[SkMatrix::kMScaleX]), | |
| 231 SkScalarToFloat(m[SkMatrix::kMSkewY]), | |
| 232 0, | |
| 233 SkScalarToFloat(m[SkMatrix::kMPersp0]), | |
| 234 | |
| 235 // col 1 | |
| 236 SkScalarToFloat(m[SkMatrix::kMSkewX]), | |
| 237 SkScalarToFloat(m[SkMatrix::kMScaleY]), | |
| 238 0, | |
| 239 SkScalarToFloat(m[SkMatrix::kMPersp1]), | |
| 240 | |
| 241 // col 2 | |
| 242 0, 0, 0, 0, | |
| 243 | |
| 244 // col3 | |
| 245 SkScalarToFloat(m[SkMatrix::kMTransX]), | |
| 246 SkScalarToFloat(m[SkMatrix::kMTransY]), | |
| 247 0.0f, | |
| 248 SkScalarToFloat(m[SkMatrix::kMPersp2]) | |
| 249 }; | |
| 250 GL_CALL(MatrixMode(GR_GL_PROJECTION)); | |
| 251 GL_CALL(LoadMatrixf(mv)); | |
| 252 fHWProjectionMatrixState.fViewMatrix = vm; | 216 fHWProjectionMatrixState.fViewMatrix = vm; |
| 253 fHWProjectionMatrixState.fRenderTargetSize = size; | 217 fHWProjectionMatrixState.fRenderTargetSize = size; |
| 254 fHWProjectionMatrixState.fRenderTargetOrigin = rt->origin(); | 218 fHWProjectionMatrixState.fRenderTargetOrigin = rt->origin(); |
| 219 | |
| 220 GrGLfloat projectionMatrix[4 * 4]; | |
| 221 fHWProjectionMatrixState.getGLMatrix<4>(projectionMatrix); | |
| 222 GL_CALL(MatrixMode(GR_GL_PROJECTION)); | |
| 223 GL_CALL(LoadMatrixf(projectionMatrix)); | |
|
Mark Kilgard
2013/09/05 18:39:34
BTW, good opportunity to simply use DSA GL_CALL ve
bsalomon
2013/09/05 18:40:44
nice!
| |
| 255 } | 224 } |
| 256 } | 225 } |
| 257 | 226 |
| 258 bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC opy) { | 227 bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC opy) { |
| 259 const GrDrawState& drawState = this->getDrawState(); | 228 const GrDrawState& drawState = this->getDrawState(); |
| 260 | 229 |
| 261 // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true. | 230 // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true. |
| 262 SkASSERT(NULL != drawState.getRenderTarget()); | 231 SkASSERT(NULL != drawState.getRenderTarget()); |
| 263 | 232 |
| 264 if (kStencilPath_DrawType == type) { | 233 if (kStencilPath_DrawType == type) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 GrGLAttribTypeToLayout(attribType).fCount, | 366 GrGLAttribTypeToLayout(attribType).fCount, |
| 398 GrGLAttribTypeToLayout(attribType).fType, | 367 GrGLAttribTypeToLayout(attribType).fType, |
| 399 GrGLAttribTypeToLayout(attribType).fNormalized, | 368 GrGLAttribTypeToLayout(attribType).fNormalized, |
| 400 stride, | 369 stride, |
| 401 reinterpret_cast<GrGLvoid*>( | 370 reinterpret_cast<GrGLvoid*>( |
| 402 vertexOffsetInBytes + vertexAttrib->fOffset)); | 371 vertexOffsetInBytes + vertexAttrib->fOffset)); |
| 403 } | 372 } |
| 404 | 373 |
| 405 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask); | 374 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask); |
| 406 } | 375 } |
| OLD | NEW |