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 "GrInOrderDrawBuffer.h" | 8 #include "GrInOrderDrawBuffer.h" |
| 9 | 9 |
| 10 #include "GrDefaultGeoProcFactory.h" | 10 #include "GrDefaultGeoProcFactory.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 /** We always use per-vertex colors so that rects can be batched across color ch anges. Sometimes we | 55 /** We always use per-vertex colors so that rects can be batched across color ch anges. Sometimes we |
| 56 have explicit local coords and sometimes not. We *could* always provide expl icit local coords | 56 have explicit local coords and sometimes not. We *could* always provide expl icit local coords |
| 57 and just duplicate the positions when the caller hasn't provided a local coo rd rect, but we | 57 and just duplicate the positions when the caller hasn't provided a local coo rd rect, but we |
| 58 haven't seen a use case which frequently switches between local rect and no local rect draws. | 58 haven't seen a use case which frequently switches between local rect and no local rect draws. |
| 59 | 59 |
| 60 The color param is used to determine whether the opaque hint can be set on t he draw state. | 60 The color param is used to determine whether the opaque hint can be set on t he draw state. |
| 61 The caller must populate the vertex colors itself. | 61 The caller must populate the vertex colors itself. |
| 62 | 62 |
| 63 The vertex attrib order is always pos, color, [local coords]. | 63 The vertex attrib order is always pos, color, [local coords]. |
| 64 */ | 64 */ |
| 65 static const GrGeometryProcessor* create_rect_gp(GrDrawState* drawState, | 65 static const GrGeometryProcessor* create_rect_gp(bool hasExplicitLocalCoords, |
| 66 bool hasLocalCoords, | 66 GrColor color, |
| 67 GrColor color) { | 67 const SkMatrix* localMatrix) { |
| 68 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType | | 68 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType | |
| 69 GrDefaultGeoProcFactory::kColor_GPType; | 69 GrDefaultGeoProcFactory::kColor_GPType; |
| 70 flags |= hasLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0; | 70 flags |= hasExplicitLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPTyp e : 0; |
| 71 return GrDefaultGeoProcFactory::Create(color, flags, GrColorIsOpaque(color)) ; | 71 if (localMatrix && !hasExplicitLocalCoords) { |
| 72 return GrDefaultGeoProcFactory::Create(color, flags, GrColorIsOpaque(col or), 0xff, | |
| 73 *localMatrix); | |
| 74 } else { | |
| 75 return GrDefaultGeoProcFactory::Create(color, flags, GrColorIsOpaque(col or)); | |
| 76 } | |
| 72 } | 77 } |
| 73 | 78 |
| 74 static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettin gs) { | 79 static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettin gs) { |
| 75 static const GrStencilSettings::Face pathFace = GrStencilSettings::kFront_Fa ce; | 80 static const GrStencilSettings::Face pathFace = GrStencilSettings::kFront_Fa ce; |
| 76 bool isWinding = kInvert_StencilOp != pathStencilSettings.passOp(pathFace); | 81 bool isWinding = kInvert_StencilOp != pathStencilSettings.passOp(pathFace); |
| 77 if (isWinding) { | 82 if (isWinding) { |
| 78 // Double check that it is in fact winding. | 83 // Double check that it is in fact winding. |
| 79 SkASSERT(kIncClamp_StencilOp == pathStencilSettings.passOp(pathFace)); | 84 SkASSERT(kIncClamp_StencilOp == pathStencilSettings.passOp(pathFace)); |
| 80 SkASSERT(kIncClamp_StencilOp == pathStencilSettings.failOp(pathFace)); | 85 SkASSERT(kIncClamp_StencilOp == pathStencilSettings.failOp(pathFace)); |
| 81 SkASSERT(0x1 != pathStencilSettings.writeMask(pathFace)); | 86 SkASSERT(0x1 != pathStencilSettings.writeMask(pathFace)); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 108 | 113 |
| 109 static inline bool cmd_has_trace_marker(uint8_t cmd) { return SkToBool(cmd & kTr aceCmdBit); } | 114 static inline bool cmd_has_trace_marker(uint8_t cmd) { return SkToBool(cmd & kTr aceCmdBit); } |
| 110 | 115 |
| 111 void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds, | 116 void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds, |
| 112 GrColor color, | 117 GrColor color, |
| 113 const SkRect& rect, | 118 const SkRect& rect, |
| 114 const SkRect* localRect, | 119 const SkRect* localRect, |
| 115 const SkMatrix* localMatrix) { | 120 const SkMatrix* localMatrix) { |
| 116 GrDrawState::AutoRestoreEffects are(ds); | 121 GrDrawState::AutoRestoreEffects are(ds); |
| 117 | 122 |
| 118 SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(ds, SkToBool(local Rect), color)); | 123 SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(SkToBool(localRect ), color, |
|
bsalomon
2014/12/22 21:13:55
Seems like here if we have a localRect then we sho
| |
| 124 localMatrix)); | |
| 119 | 125 |
| 120 size_t vstride = gp->getVertexStride(); | 126 size_t vstride = gp->getVertexStride(); |
| 121 SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) : | 127 SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) : |
| 122 0)); | 128 0)); |
| 123 AutoReleaseGeometry geo(this, 4, vstride, 0); | 129 AutoReleaseGeometry geo(this, 4, vstride, 0); |
| 124 if (!geo.succeeded()) { | 130 if (!geo.succeeded()) { |
| 125 SkDebugf("Failed to get space for vertices!\n"); | 131 SkDebugf("Failed to get space for vertices!\n"); |
| 126 return; | 132 return; |
| 127 } | 133 } |
| 128 | 134 |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 517 | 523 |
| 518 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { | 524 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { |
| 519 SkASSERT(!fCmdBuffer.empty()); | 525 SkASSERT(!fCmdBuffer.empty()); |
| 520 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); | 526 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); |
| 521 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); | 527 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); |
| 522 if (activeTraceMarkers.count() > 0) { | 528 if (activeTraceMarkers.count() > 0) { |
| 523 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); | 529 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); |
| 524 fGpuCmdMarkers.push_back(activeTraceMarkers); | 530 fGpuCmdMarkers.push_back(activeTraceMarkers); |
| 525 } | 531 } |
| 526 } | 532 } |
| OLD | NEW |