blob: 4eb98433efb5affea78a6df995f7b0fb9d9d7c71 [file] [log] [blame]
egdaniel9cb63402016-06-23 08:37:05 -07001/*
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
robertphillips28a838e2016-06-23 14:07:00 -070010#include "GrCaps.h"
csmartdalton29df7602016-08-31 11:55:52 -070011#include "GrFixedClip.h"
egdaniel9cb63402016-06-23 08:37:05 -070012#include "GrGpu.h"
13#include "GrPrimitiveProcessor.h"
14#include "GrRenderTarget.h"
15#include "SkRect.h"
16
Greg Daniel36a77ee2016-10-18 10:33:25 -040017void GrGpuCommandBuffer::submit() {
egdaniel9cb63402016-06-23 08:37:05 -070018 this->gpu()->handleDirtyContext();
Greg Daniel36a77ee2016-10-18 10:33:25 -040019 this->onSubmit();
egdaniel9cb63402016-06-23 08:37:05 -070020}
21
Brian Salomonc293a292016-11-30 13:38:32 -050022void GrGpuCommandBuffer::clear(GrRenderTarget* rt, const GrFixedClip& clip, GrColor color) {
Greg Daniel65a09272016-10-12 09:47:22 -040023#ifdef SK_DEBUG
csmartdalton29df7602016-08-31 11:55:52 -070024 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 Daniel65a09272016-10-12 09:47:22 -040028#endif
Brian Salomonc293a292016-11-30 13:38:32 -050029 this->onClear(rt, clip, color);
egdaniel9cb63402016-06-23 08:37:05 -070030}
31
Brian Salomonc293a292016-11-30 13:38:32 -050032void GrGpuCommandBuffer::clearStencilClip(GrRenderTarget* rt, const GrFixedClip& clip,
Greg Daniel65a09272016-10-12 09:47:22 -040033 bool insideStencilMask) {
Brian Salomonc293a292016-11-30 13:38:32 -050034 this->onClearStencilClip(rt, clip, insideStencilMask);
egdaniel9cb63402016-06-23 08:37:05 -070035}
36
egdaniel9cb63402016-06-23 08:37:05 -070037bool GrGpuCommandBuffer::draw(const GrPipeline& pipeline,
38 const GrPrimitiveProcessor& primProc,
39 const GrMesh* mesh,
Greg Daniel36a77ee2016-10-18 10:33:25 -040040 int meshCount,
41 const SkRect& bounds) {
Brian Salomonb5cb6832017-02-24 11:01:15 -050042 SkASSERT(pipeline.isInitialized());
egdaniel9cb63402016-06-23 08:37:05 -070043 if (primProc.numAttribs() > this->gpu()->caps()->maxVertexAttributes()) {
44 this->gpu()->stats()->incNumFailedDraws();
45 return false;
46 }
Greg Daniel36a77ee2016-10-18 10:33:25 -040047 this->onDraw(pipeline, primProc, mesh, meshCount, bounds);
egdaniel9cb63402016-06-23 08:37:05 -070048 return true;
49}
50