1 /* 2 * Copyright 2016 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "GrGpuCommandBuffer.h" 9 10 #include "GrContext.h" 11 #include "GrCaps.h" 12 #include "GrFixedClip.h" 13 #include "GrGpu.h" 14 #include "GrMesh.h" 15 #include "GrPrimitiveProcessor.h" 16 #include "GrRenderTarget.h" 17 #include "SkRect.h" 18 19 void GrGpuRTCommandBuffer::clear(const GrFixedClip& clip, GrColor color) { 20 #ifdef SK_DEBUG 21 GrRenderTarget* rt = fRenderTarget; 22 SkASSERT(rt); 23 SkASSERT(!clip.scissorEnabled() || 24 (SkIRect::MakeWH(rt->width(), rt->height()).contains(clip.scissorRect()) && 25 SkIRect::MakeWH(rt->width(), rt->height()) != clip.scissorRect())); 26 #endif 27 this->onClear(clip, color); 28 } 29 30 void GrGpuRTCommandBuffer::clearStencilClip(const GrFixedClip& clip, bool insideStencilMask) { 31 this->onClearStencilClip(clip, insideStencilMask); 32 } 33 34 bool GrGpuRTCommandBuffer::draw(const GrPipeline& pipeline, 35 const GrPrimitiveProcessor& primProc, 36 const GrMesh meshes[], 37 const GrPipeline::DynamicState dynamicStates[], 38 int meshCount, 39 const SkRect& bounds) { 40 #ifdef SK_DEBUG 41 SkASSERT(!primProc.hasInstanceAttribs() || this->gpu()->caps()->instanceAttribSupport()); 42 SkASSERT(!primProc.willUsePrimitiveRestart() || this->gpu()->caps()->usePrimitiveRestart()); 43 for (int i = 0; i < meshCount; ++i) { 44 SkASSERT(!GrPrimTypeRequiresGeometryShaderSupport(meshes[i].primitiveType()) || 45 this->gpu()->caps()->shaderCaps()->geometryShaderSupport()); 46 SkASSERT(primProc.hasVertexAttribs() == meshes[i].hasVertexData()); 47 SkASSERT(primProc.hasInstanceAttribs() == meshes[i].isInstanced()); 48 } 49 #endif 50 auto resourceProvider = this->gpu()->getContext()->contextPriv().resourceProvider(); 51 52 if (pipeline.isBad() || !primProc.instantiate(resourceProvider)) { 53 return false; 54 } 55 56 if (primProc.numAttribs() > this->gpu()->caps()->maxVertexAttributes()) { 57 this->gpu()->stats()->incNumFailedDraws(); 58 return false; 59 } 60 this->onDraw(pipeline, primProc, meshes, dynamicStates, meshCount, bounds); 61 return true; 62 } 63 64