egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 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 | |
robertphillips | 28a838e | 2016-06-23 14:07:00 -0700 | [diff] [blame] | 10 | #include "GrCaps.h" |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 11 | #include "GrFixedClip.h" |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 12 | #include "GrGpu.h" |
| 13 | #include "GrPrimitiveProcessor.h" |
| 14 | #include "GrRenderTarget.h" |
| 15 | #include "SkRect.h" |
| 16 | |
Greg Daniel | 36a77ee | 2016-10-18 10:33:25 -0400 | [diff] [blame] | 17 | void GrGpuCommandBuffer::submit() { |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 18 | this->gpu()->handleDirtyContext(); |
Greg Daniel | 36a77ee | 2016-10-18 10:33:25 -0400 | [diff] [blame] | 19 | this->onSubmit(); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 20 | } |
| 21 | |
Brian Salomon | c293a29 | 2016-11-30 13:38:32 -0500 | [diff] [blame] | 22 | void GrGpuCommandBuffer::clear(GrRenderTarget* rt, const GrFixedClip& clip, GrColor color) { |
Greg Daniel | 65a0927 | 2016-10-12 09:47:22 -0400 | [diff] [blame] | 23 | #ifdef SK_DEBUG |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 24 | SkASSERT(rt); |
| 25 | SkASSERT(!clip.scissorEnabled() || |
| 26 | (SkIRect::MakeWH(rt->width(), rt->height()).contains(clip.scissorRect()) && |
| 27 | SkIRect::MakeWH(rt->width(), rt->height()) != clip.scissorRect())); |
Greg Daniel | 65a0927 | 2016-10-12 09:47:22 -0400 | [diff] [blame] | 28 | #endif |
Brian Salomon | c293a29 | 2016-11-30 13:38:32 -0500 | [diff] [blame] | 29 | this->onClear(rt, clip, color); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Brian Salomon | c293a29 | 2016-11-30 13:38:32 -0500 | [diff] [blame] | 32 | void GrGpuCommandBuffer::clearStencilClip(GrRenderTarget* rt, const GrFixedClip& clip, |
Greg Daniel | 65a0927 | 2016-10-12 09:47:22 -0400 | [diff] [blame] | 33 | bool insideStencilMask) { |
Brian Salomon | c293a29 | 2016-11-30 13:38:32 -0500 | [diff] [blame] | 34 | this->onClearStencilClip(rt, clip, insideStencilMask); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 35 | } |
| 36 | |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 37 | bool GrGpuCommandBuffer::draw(const GrPipeline& pipeline, |
| 38 | const GrPrimitiveProcessor& primProc, |
| 39 | const GrMesh* mesh, |
Greg Daniel | 36a77ee | 2016-10-18 10:33:25 -0400 | [diff] [blame] | 40 | int meshCount, |
| 41 | const SkRect& bounds) { |
Brian Salomon | b5cb683 | 2017-02-24 11:01:15 -0500 | [diff] [blame] | 42 | SkASSERT(pipeline.isInitialized()); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 43 | if (primProc.numAttribs() > this->gpu()->caps()->maxVertexAttributes()) { |
| 44 | this->gpu()->stats()->incNumFailedDraws(); |
| 45 | return false; |
| 46 | } |
Greg Daniel | 36a77ee | 2016-10-18 10:33:25 -0400 | [diff] [blame] | 47 | this->onDraw(pipeline, primProc, mesh, meshCount, bounds); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 48 | return true; |
| 49 | } |
| 50 | |