bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 10 | GrDrawBatch::GrDrawBatch(uint32_t classID) : INHERITED(classID), fPipelineInstalled(false) { } |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 11 | |
| 12 | GrDrawBatch::~GrDrawBatch() { |
| 13 | if (fPipelineInstalled) { |
| 14 | this->pipeline()->~GrPipeline(); |
| 15 | } |
| 16 | } |
| 17 | |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 18 | void 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 | |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 26 | bool GrDrawBatch::installPipeline(const GrPipeline::CreateArgs& args) { |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 27 | GrXPOverridesForBatch overrides; |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 28 | void* location = fPipelineStorage.get(); |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 29 | if (!GrPipeline::CreateAt(location, args, &overrides)) { |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 30 | return false; |
| 31 | } |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 32 | this->initBatchTracker(overrides); |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 33 | fPipelineInstalled = true; |
| 34 | return true; |
| 35 | } |