blob: 4253923f335dc9c5736824db437111e7d309d1dc [file] [log] [blame]
bsalomon16b99132015-08-13 14:55:50 -07001/*
2 * Copyright 2015 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 "GrDrawBatch.h"
9
reed1b55a962015-09-17 20:16:13 -070010GrDrawBatch::GrDrawBatch(uint32_t classID) : INHERITED(classID), fPipelineInstalled(false) { }
bsalomon16b99132015-08-13 14:55:50 -070011
12GrDrawBatch::~GrDrawBatch() {
13 if (fPipelineInstalled) {
14 this->pipeline()->~GrPipeline();
15 }
16}
17
ethannicholasff210322015-11-24 12:10:10 -080018void GrDrawBatch::getPipelineOptimizations(GrPipelineOptimizations* opt) const {
19 GrInitInvariantOutput color;
20 GrInitInvariantOutput coverage;
21 this->computePipelineOptimizations(&color, &coverage, &opt->fOverrides);
22 opt->fColorPOI.initUsingInvariantOutput(color);
23 opt->fCoveragePOI.initUsingInvariantOutput(coverage);
24}
25
bsalomon16b99132015-08-13 14:55:50 -070026bool GrDrawBatch::installPipeline(const GrPipeline::CreateArgs& args) {
ethannicholasff210322015-11-24 12:10:10 -080027 GrXPOverridesForBatch overrides;
bsalomon16b99132015-08-13 14:55:50 -070028 void* location = fPipelineStorage.get();
ethannicholasff210322015-11-24 12:10:10 -080029 if (!GrPipeline::CreateAt(location, args, &overrides)) {
bsalomon16b99132015-08-13 14:55:50 -070030 return false;
31 }
ethannicholasff210322015-11-24 12:10:10 -080032 this->initBatchTracker(overrides);
bsalomon16b99132015-08-13 14:55:50 -070033 fPipelineInstalled = true;
34 return true;
35}