Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Side by Side Diff: src/gpu/GrPipeline.cpp

Issue 1286173006: Fail early in GrPipeline::CreateAt() if XP creation fails (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrPipeline.h" 8 #include "GrPipeline.h"
9 9
10 #include "GrCaps.h" 10 #include "GrCaps.h"
11 #include "GrGpu.h" 11 #include "GrGpu.h"
12 #include "GrPipelineBuilder.h" 12 #include "GrPipelineBuilder.h"
13 #include "GrProcOptInfo.h" 13 #include "GrProcOptInfo.h"
14 #include "GrXferProcessor.h" 14 #include "GrXferProcessor.h"
15 15
16 #include "batches/GrBatch.h" 16 #include "batches/GrBatch.h"
17 17
18 GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, 18 GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args,
19 GrPipelineOptimizations* opts) { 19 GrPipelineOptimizations* opts) {
20 GrPipeline* pipeline = SkNEW_PLACEMENT(memory, GrPipeline);
21 const GrPipelineBuilder& builder = *args.fPipelineBuilder; 20 const GrPipelineBuilder& builder = *args.fPipelineBuilder;
22 21
23 // Create XferProcessor from DS's XPFactory 22 // Create XferProcessor from DS's XPFactory
24 SkAutoTUnref<GrXferProcessor> xferProcessor( 23 SkAutoTUnref<GrXferProcessor> xferProcessor(
25 builder.getXPFactory()->createXferProcessor(args.fColorPOI, args.fCovera gePOI, 24 builder.getXPFactory()->createXferProcessor(args.fColorPOI, args.fCovera gePOI,
26 builder.hasMixedSamples(), & args.fDstTexture, 25 builder.hasMixedSamples(), & args.fDstTexture,
27 *args.fCaps)); 26 *args.fCaps));
27 if (!xferProcessor) {
28 return nullptr;
29 }
28 30
29 GrColor overrideColor = GrColor_ILLEGAL; 31 GrColor overrideColor = GrColor_ILLEGAL;
30 if (args.fColorPOI.firstEffectiveStageIndex() != 0) { 32 if (args.fColorPOI.firstEffectiveStageIndex() != 0) {
31 overrideColor = args.fColorPOI.inputColorToEffectiveStage(); 33 overrideColor = args.fColorPOI.inputColorToEffectiveStage();
32 } 34 }
33 35
34 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; 36 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
35 if (xferProcessor) {
36 pipeline->fXferProcessor.reset(xferProcessor.get());
37 37
38 optFlags = xferProcessor->getOptimizations(args.fColorPOI, 38 optFlags = xferProcessor->getOptimizations(args.fColorPOI,
39 args.fCoveragePOI, 39 args.fCoveragePOI,
40 builder.getStencil().doesWrit e(), 40 builder.getStencil().doesWrite() ,
41 &overrideColor, 41 &overrideColor,
42 *args.fCaps); 42 *args.fCaps);
43
44 // When path rendering the stencil settings are not always set on the GrPipe lineBuilder
45 // so we must check the draw type. In cases where we will skip drawing we si mply return a
46 // null GrPipeline.
47 if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) {
48 return nullptr;
43 } 49 }
44 50
45 // No need to have an override color if it isn't even going to be used. 51 // No need to have an override color if it isn't even going to be used.
46 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { 52 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) {
47 overrideColor = GrColor_ILLEGAL; 53 overrideColor = GrColor_ILLEGAL;
48 } 54 }
49 55
50 // When path rendering the stencil settings are not always set on the GrPipe lineBuilder 56 GrPipeline* pipeline = SkNEW_PLACEMENT(memory, GrPipeline);
51 // so we must check the draw type. In cases where we will skip drawing we si mply return a 57 pipeline->fXferProcessor.reset(xferProcessor.get());
52 // null GrPipeline.
53 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) {
54 pipeline->~GrPipeline();
55 return nullptr;
56 }
57 58
58 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); 59 pipeline->fRenderTarget.reset(builder.fRenderTarget.get());
59 SkASSERT(pipeline->fRenderTarget); 60 SkASSERT(pipeline->fRenderTarget);
60 pipeline->fScissorState = *args.fScissor; 61 pipeline->fScissorState = *args.fScissor;
61 pipeline->fStencilSettings = builder.getStencil(); 62 pipeline->fStencilSettings = builder.getStencil();
62 pipeline->fDrawFace = builder.getDrawFace(); 63 pipeline->fDrawFace = builder.getDrawFace();
63 64
64 pipeline->fFlags = 0; 65 pipeline->fFlags = 0;
65 if (builder.isHWAntialias()) { 66 if (builder.isHWAntialias()) {
66 pipeline->fFlags |= kHWAA_Flag; 67 pipeline->fFlags |= kHWAA_Flag;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 171
171 for (int i = 0; i < a.numFragmentStages(); i++) { 172 for (int i = 0; i < a.numFragmentStages(); i++) {
172 if (!a.getFragmentStage(i).processor()->isEqual(*b.getFragmentStage(i).p rocessor(), 173 if (!a.getFragmentStage(i).processor()->isEqual(*b.getFragmentStage(i).p rocessor(),
173 ignoreCoordTransform s)) { 174 ignoreCoordTransform s)) {
174 return false; 175 return false;
175 } 176 }
176 } 177 }
177 return true; 178 return true;
178 } 179 }
179 180
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698