• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "GrCaps.h"
11 #include "GrFixedClip.h"
12 #include "GrGpu.h"
13 #include "GrPrimitiveProcessor.h"
14 #include "GrRenderTarget.h"
15 #include "SkRect.h"
16 
submit()17 void GrGpuCommandBuffer::submit() {
18     this->gpu()->handleDirtyContext();
19     this->onSubmit();
20 }
21 
clear(GrRenderTarget * rt,const GrFixedClip & clip,GrColor color)22 void GrGpuCommandBuffer::clear(GrRenderTarget* rt, const GrFixedClip& clip, GrColor color) {
23 #ifdef SK_DEBUG
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()));
28 #endif
29     this->onClear(rt, clip, color);
30 }
31 
clearStencilClip(GrRenderTarget * rt,const GrFixedClip & clip,bool insideStencilMask)32 void GrGpuCommandBuffer::clearStencilClip(GrRenderTarget* rt, const GrFixedClip& clip,
33                                           bool insideStencilMask) {
34     this->onClearStencilClip(rt, clip, insideStencilMask);
35 }
36 
draw(const GrPipeline & pipeline,const GrPrimitiveProcessor & primProc,const GrMesh * mesh,int meshCount,const SkRect & bounds)37 bool GrGpuCommandBuffer::draw(const GrPipeline& pipeline,
38                               const GrPrimitiveProcessor& primProc,
39                               const GrMesh* mesh,
40                               int meshCount,
41                               const SkRect& bounds) {
42     SkASSERT(pipeline.isInitialized());
43     if (primProc.numAttribs() > this->gpu()->caps()->maxVertexAttributes()) {
44         this->gpu()->stats()->incNumFailedDraws();
45         return false;
46     }
47     this->onDraw(pipeline, primProc, mesh, meshCount, bounds);
48     return true;
49 }
50 
51