Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: src/gpu/GrDrawState.h

Issue 504203004: Attach GrOptDrawState into shader building pipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@opt2
Patch Set: Remove BlendOpt Cache Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "GrBlend.h" 11 #include "GrBlend.h"
12 #include "GrOptDrawState.h"
13 #include "GrProgramResource.h" 12 #include "GrProgramResource.h"
14 #include "GrRODrawState.h" 13 #include "GrRODrawState.h"
15 #include "effects/GrSimpleTextureEffect.h" 14 #include "effects/GrSimpleTextureEffect.h"
16 15
16 class GrOptDrawState;
17
17 /** 18 /**
18 * Modifiable subclass derived from GrRODrawState. The majority of the data that represents a draw 19 * Modifiable subclass derived from GrRODrawState. The majority of the data that represents a draw
19 * state is stored in the parent class. GrDrawState contains methods for setting , adding to, etc. 20 * state is stored in the parent class. GrDrawState contains methods for setting , adding to, etc.
20 * various data members of the draw state. This class is used to configure the s tate used when 21 * various data members of the draw state. This class is used to configure the s tate used when
21 * issuing draws via GrDrawTarget. 22 * issuing draws via GrDrawTarget.
22 */ 23 */
23 class GrDrawState : public GrRODrawState { 24 class GrDrawState : public GrRODrawState {
24 public: 25 public:
25 SK_DECLARE_INST_COUNT(GrDrawState) 26 SK_DECLARE_INST_COUNT(GrDrawState)
26 27
(...skipping 13 matching lines...) Expand all
40 GrDrawState(const GrDrawState& state) : INHERITED(), fCachedOptState(NULL) { 41 GrDrawState(const GrDrawState& state) : INHERITED(), fCachedOptState(NULL) {
41 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) 42 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
42 *this = state; 43 *this = state;
43 } 44 }
44 45
45 /** 46 /**
46 * Copies another draw state with a preconcat to the view matrix. 47 * Copies another draw state with a preconcat to the view matrix.
47 **/ 48 **/
48 GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix); 49 GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix);
49 50
50 virtual ~GrDrawState() { 51 virtual ~GrDrawState();
51 SkSafeUnref(fCachedOptState);
52 SkASSERT(0 == fBlockEffectRemovalCnt);
53 }
54 52
55 /** 53 /**
56 * Resets to the default state. GrEffects will be removed from all stages. 54 * Resets to the default state. GrEffects will be removed from all stages.
57 */ 55 */
58 void reset() { this->onReset(NULL); } 56 void reset() { this->onReset(NULL); }
59 57
60 void reset(const SkMatrix& initialViewMatrix) { this->onReset(&initialViewMa trix); } 58 void reset(const SkMatrix& initialViewMatrix) { this->onReset(&initialViewMa trix); }
61 59
62 /** 60 /**
63 * Initializes the GrDrawState based on a GrPaint, view matrix and render ta rget. Note that 61 * Initializes the GrDrawState based on a GrPaint, view matrix and render ta rget. Note that
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 540
543 /** 541 /**
544 * Returns a snapshot of the current optimized state. If the current drawSta te has a valid 542 * Returns a snapshot of the current optimized state. If the current drawSta te has a valid
545 * cached optimiezed state it will simply return a pointer to it otherwise i t will create a new 543 * cached optimiezed state it will simply return a pointer to it otherwise i t will create a new
546 * GrOptDrawState. In all cases the GrOptDrawState is reffed and ownership i s given to the 544 * GrOptDrawState. In all cases the GrOptDrawState is reffed and ownership i s given to the
547 * caller. 545 * caller.
548 */ 546 */
549 GrOptDrawState* createOptState() const; 547 GrOptDrawState* createOptState() const;
550 548
551 private: 549 private:
552 void invalidateOptState() const { 550 void invalidateOptState() const;
553 SkSafeSetNull(fCachedOptState);
554 fBlendOptFlags = kInvalid_BlendOptFlag;
555 }
556 551
557 void onReset(const SkMatrix* initialViewMatrix); 552 void onReset(const SkMatrix* initialViewMatrix);
558 553
559 void invalidateBlendOptFlags() {
560 fBlendOptFlags = kInvalid_BlendOptFlag;
561 }
562
563 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. 554 // Some of the auto restore objects assume that no effects are removed durin g their lifetime.
564 // This is used to assert that this condition holds. 555 // This is used to assert that this condition holds.
565 SkDEBUGCODE(int fBlockEffectRemovalCnt;) 556 SkDEBUGCODE(int fBlockEffectRemovalCnt;)
566 557
567 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz e_t stride); 558 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz e_t stride);
568 559
569 mutable GrOptDrawState* fCachedOptState; 560 mutable GrOptDrawState* fCachedOptState;
570 561
571 typedef GrRODrawState INHERITED; 562 typedef GrRODrawState INHERITED;
572 }; 563 };
573 564
574 #endif 565 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrEffectStage.h ('k') | src/gpu/GrDrawState.cpp » ('j') | src/gpu/GrOptDrawState.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698