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

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

Issue 508663002: Create an optimized draw state but not hooked in yet to gpu pipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@drawBase
Patch Set: Review changes 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
« src/gpu/GrOptDrawState.cpp ('K') | « src/gpu/GrOptDrawState.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 GrRODrawState_DEFINED 8 #ifndef GrRODrawState_DEFINED
9 #define GrRODrawState_DEFINED 9 #define GrRODrawState_DEFINED
10 10
11 #include "GrStencil.h" 11 #include "GrStencil.h"
12 #include "GrEffectStage.h" 12 #include "GrEffectStage.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 14
15 class GrDrawState;
15 class GrDrawTargetCaps; 16 class GrDrawTargetCaps;
16 class GrPaint; 17 class GrPaint;
17 class GrRenderTarget; 18 class GrRenderTarget;
18 class GrTexture; 19 class GrTexture;
19 20
20 /** 21 /**
21 * Read-only base class for GrDrawState. This class contains all the necessary d ata to represent a 22 * Read-only base class for GrDrawState. This class contains all the necessary d ata to represent a
22 * canonical DrawState. All methods in the class are const, thus once created th e data in the class 23 * canonical DrawState. All methods in the class are const, thus once created th e data in the class
23 * cannot be changed. 24 * cannot be changed.
24 */ 25 */
25 class GrRODrawState : public SkRefCnt { 26 class GrRODrawState : public SkRefCnt {
26 public: 27 public:
27 SK_DECLARE_INST_COUNT(GrRODrawState) 28 SK_DECLARE_INST_COUNT(GrRODrawState)
28 29
30 GrRODrawState() {}
31
32 GrRODrawState& operator= (const GrRODrawState& that);
33
29 /////////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////////
30 /// @name Vertex Attributes 35 /// @name Vertex Attributes
31 //// 36 ////
32 37
33 enum { 38 enum {
34 kMaxVertexAttribCnt = kLast_GrVertexAttribBinding + 4, 39 kMaxVertexAttribCnt = kLast_GrVertexAttribBinding + 4,
35 }; 40 };
36 41
37 const GrVertexAttrib* getVertexAttribs() const { return fVAPtr; } 42 const GrVertexAttrib* getVertexAttribs() const { return fVAPtr; }
38 int getVertexAttribCount() const { return fVACount; } 43 int getVertexAttribCount() const { return fVACount; }
(...skipping 22 matching lines...) Expand all
61 bool hasLocalCoordAttribute() const { 66 bool hasLocalCoordAttribute() const {
62 return -1 != fFixedFunctionVertexAttribIndices[kLocalCoord_GrVertexAttri bBinding]; 67 return -1 != fFixedFunctionVertexAttribIndices[kLocalCoord_GrVertexAttri bBinding];
63 } 68 }
64 bool hasColorVertexAttribute() const { 69 bool hasColorVertexAttribute() const {
65 return -1 != fFixedFunctionVertexAttribIndices[kColor_GrVertexAttribBind ing]; 70 return -1 != fFixedFunctionVertexAttribIndices[kColor_GrVertexAttribBind ing];
66 } 71 }
67 bool hasCoverageVertexAttribute() const { 72 bool hasCoverageVertexAttribute() const {
68 return -1 != fFixedFunctionVertexAttribIndices[kCoverage_GrVertexAttribB inding]; 73 return -1 != fFixedFunctionVertexAttribIndices[kCoverage_GrVertexAttribB inding];
69 } 74 }
70 75
76 const int* getFixedFunctionVertexAttribIndices() const {
77 return fFixedFunctionVertexAttribIndices;
78 }
79
71 bool validateVertexAttribs() const; 80 bool validateVertexAttribs() const;
72 81
73 /// @} 82 /// @}
74 83
75 /** 84 /**
76 * Determines whether the output coverage is guaranteed to be one for all pi xels hit by a draw. 85 * Determines whether the output coverage is guaranteed to be one for all pi xels hit by a draw.
77 */ 86 */
78 bool hasSolidCoverage() const; 87 bool hasSolidCoverage() const;
79 88
80 /// @} 89 /// @}
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 * control over the blend coeffs. When set, there will be a single blend step controlled by 297 * control over the blend coeffs. When set, there will be a single blend step controlled by
289 * setBlendFunc() which will use coverage*color as the src color. 298 * setBlendFunc() which will use coverage*color as the src color.
290 */ 299 */
291 kCoverageDrawing_StateBit = 0x10, 300 kCoverageDrawing_StateBit = 0x10,
292 301
293 // Users of the class may add additional bits to the vector 302 // Users of the class may add additional bits to the vector
294 kDummyStateBit, 303 kDummyStateBit,
295 kLastPublicStateBit = kDummyStateBit-1, 304 kLastPublicStateBit = kDummyStateBit-1,
296 }; 305 };
297 306
307 uint32_t getFlagBits() const { return fFlagBits; }
308
298 bool isStateFlagEnabled(uint32_t stateBit) const { return 0 != (stateBit & f FlagBits); } 309 bool isStateFlagEnabled(uint32_t stateBit) const { return 0 != (stateBit & f FlagBits); }
299 310
300 bool isDitherState() const { return 0 != (fFlagBits & kDither_StateBit); } 311 bool isDitherState() const { return 0 != (fFlagBits & kDither_StateBit); }
301 bool isHWAntialiasState() const { return 0 != (fFlagBits & kHWAntialias_Stat eBit); } 312 bool isHWAntialiasState() const { return 0 != (fFlagBits & kHWAntialias_Stat eBit); }
302 bool isClipState() const { return 0 != (fFlagBits & kClip_StateBit); } 313 bool isClipState() const { return 0 != (fFlagBits & kClip_StateBit); }
303 bool isColorWriteDisabled() const { return 0 != (fFlagBits & kNoColorWrites_ StateBit); } 314 bool isColorWriteDisabled() const { return 0 != (fFlagBits & kNoColorWrites_ StateBit); }
304 bool isCoverageDrawing() const { return 0 != (fFlagBits & kCoverageDrawing_S tateBit); } 315 bool isCoverageDrawing() const { return 0 != (fFlagBits & kCoverageDrawing_S tateBit); }
305 316
306 /// @} 317 /// @}
307 318
(...skipping 25 matching lines...) Expand all
333 /** The GrDrawStates cannot be combined. */ 344 /** The GrDrawStates cannot be combined. */
334 kIncompatible_CombinedState, 345 kIncompatible_CombinedState,
335 /** Either draw state can be used in place of the other. */ 346 /** Either draw state can be used in place of the other. */
336 kAOrB_CombinedState, 347 kAOrB_CombinedState,
337 /** Use the first draw state. */ 348 /** Use the first draw state. */
338 kA_CombinedState, 349 kA_CombinedState,
339 /** Use the second draw state. */ 350 /** Use the second draw state. */
340 kB_CombinedState, 351 kB_CombinedState,
341 }; 352 };
342 353
343 GrRODrawState& operator= (const GrRODrawState& that); 354 protected:
355 explicit GrRODrawState(const GrRODrawState& drawState) : INHERITED() {
356 fRenderTarget.reset(SkSafeRef(drawState.fRenderTarget.get()));
357 }
344 358
345 protected:
346 bool isEqual(const GrRODrawState& that) const; 359 bool isEqual(const GrRODrawState& that) const;
347 360
348 // These fields are roughly sorted by decreasing likelihood of being differe nt in op== 361 // These fields are roughly sorted by decreasing likelihood of being differe nt in op==
349 SkAutoTUnref<GrRenderTarget> fRenderTarget; 362 SkAutoTUnref<GrRenderTarget> fRenderTarget;
350 GrColor fColor; 363 GrColor fColor;
351 SkMatrix fViewMatrix; 364 SkMatrix fViewMatrix;
352 GrColor fBlendConstant; 365 GrColor fBlendConstant;
353 uint32_t fFlagBits; 366 uint32_t fFlagBits;
354 const GrVertexAttrib* fVAPtr; 367 const GrVertexAttrib* fVAPtr;
355 int fVACount; 368 int fVACount;
(...skipping 16 matching lines...) Expand all
372 // not need to be compared in op==. 385 // not need to be compared in op==.
373 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ]; 386 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ];
374 387
375 private: 388 private:
376 typedef SkRefCnt INHERITED; 389 typedef SkRefCnt INHERITED;
377 }; 390 };
378 391
379 GR_MAKE_BITFIELD_OPS(GrRODrawState::BlendOptFlags); 392 GR_MAKE_BITFIELD_OPS(GrRODrawState::BlendOptFlags);
380 393
381 #endif 394 #endif
OLDNEW
« src/gpu/GrOptDrawState.cpp ('K') | « src/gpu/GrOptDrawState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698