| 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 #ifndef GrDrawState_DEFINED | 8 #ifndef GrDrawState_DEFINED |
| 9 #define GrDrawState_DEFINED | 9 #define GrDrawState_DEFINED |
| 10 | 10 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 *matrix = inverse; | 299 *matrix = inverse; |
| 300 } | 300 } |
| 301 return true; | 301 return true; |
| 302 } | 302 } |
| 303 return false; | 303 return false; |
| 304 } | 304 } |
| 305 | 305 |
| 306 //////////////////////////////////////////////////////////////////////////// | 306 //////////////////////////////////////////////////////////////////////////// |
| 307 | 307 |
| 308 /** | 308 /** |
| 309 * Preconcats the current view matrix and restores the previous view matrix
in the destructor. | 309 * Sets the viewmatrix to identity and restores it in the destructor. |
| 310 * Effect matrices are automatically adjusted to compensate and adjusted bac
k in the destructor. | 310 * TODO remove vm off of drawstate |
| 311 */ | 311 */ |
| 312 class AutoViewMatrixRestore : public ::SkNoncopyable { | 312 class AutoViewMatrixRestore : public ::SkNoncopyable { |
| 313 public: | 313 public: |
| 314 AutoViewMatrixRestore() : fDrawState(NULL) {} | 314 AutoViewMatrixRestore() { |
| 315 | |
| 316 AutoViewMatrixRestore(GrDrawState* ds, const SkMatrix& preconcatMatrix)
{ | |
| 317 fDrawState = NULL; | 315 fDrawState = NULL; |
| 318 this->set(ds, preconcatMatrix); | |
| 319 } | 316 } |
| 320 | 317 |
| 321 ~AutoViewMatrixRestore() { this->restore(); } | 318 AutoViewMatrixRestore(GrDrawState* ds) { |
| 319 SkASSERT(ds); |
| 320 fDrawState = ds; |
| 321 fViewMatrix = fDrawState->fViewMatrix; |
| 322 fDrawState->fViewMatrix = SkMatrix::I(); |
| 323 } |
| 322 | 324 |
| 323 /** | 325 void setIdentity(GrDrawState* ds) { |
| 324 * Can be called prior to destructor to restore the original matrix. | 326 SkASSERT(ds); |
| 325 */ | 327 fDrawState = ds; |
| 326 void restore(); | 328 fViewMatrix = fDrawState->fViewMatrix; |
| 329 fDrawState->fViewMatrix = SkMatrix::I(); |
| 330 } |
| 327 | 331 |
| 328 void set(GrDrawState* drawState, const SkMatrix& preconcatMatrix); | 332 ~AutoViewMatrixRestore() { |
| 329 | 333 if (fDrawState) { |
| 330 /** Sets the draw state's matrix to identity. This can fail because the
current view matrix | 334 fDrawState->fViewMatrix = fViewMatrix; |
| 331 is not invertible. */ | 335 } |
| 332 bool setIdentity(GrDrawState* drawState); | 336 } |
| 333 | 337 |
| 334 private: | 338 private: |
| 335 void doEffectCoordChanges(const SkMatrix& coordChangeMatrix); | |
| 336 | |
| 337 GrDrawState* fDrawState; | 339 GrDrawState* fDrawState; |
| 338 SkMatrix fViewMatrix; | 340 SkMatrix fViewMatrix; |
| 339 int fNumColorStages; | |
| 340 SkAutoSTArray<8, GrFragmentStage::SavedCoordChange> fSavedCoordChange
s; | |
| 341 }; | 341 }; |
| 342 | 342 |
| 343 |
| 343 /// @} | 344 /// @} |
| 344 | 345 |
| 345 /////////////////////////////////////////////////////////////////////////// | 346 /////////////////////////////////////////////////////////////////////////// |
| 346 /// @name Render Target | 347 /// @name Render Target |
| 347 //// | 348 //// |
| 348 | 349 |
| 349 /** | 350 /** |
| 350 * Retrieves the currently set render-target. | 351 * Retrieves the currently set render-target. |
| 351 * | 352 * |
| 352 * @return The currently set render target. | 353 * @return The currently set render target. |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 mutable bool fCoverageProcInfoValid; | 542 mutable bool fCoverageProcInfoValid; |
| 542 mutable GrColor fColorCache; | 543 mutable GrColor fColorCache; |
| 543 mutable GrColor fCoverageCache; | 544 mutable GrColor fCoverageCache; |
| 544 mutable const GrPrimitiveProcessor* fColorPrimProc; | 545 mutable const GrPrimitiveProcessor* fColorPrimProc; |
| 545 mutable const GrPrimitiveProcessor* fCoveragePrimProc; | 546 mutable const GrPrimitiveProcessor* fCoveragePrimProc; |
| 546 | 547 |
| 547 friend class GrOptDrawState; | 548 friend class GrOptDrawState; |
| 548 }; | 549 }; |
| 549 | 550 |
| 550 #endif | 551 #endif |
| OLD | NEW |