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

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

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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 | « src/gpu/GrDrawContext.cpp ('k') | src/gpu/GrFragmentProcessor.cpp » ('j') | 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 2010 Google Inc. 2 * Copyright 2010 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 "GrDrawTarget.h" 8 #include "GrDrawTarget.h"
9 9
10 #include "GrAuditTrail.h" 10 #include "GrAuditTrail.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 const GrClip& clip, 238 const GrClip& clip,
239 GrDrawBatch* batch) { 239 GrDrawBatch* batch) {
240 // Setup clip 240 // Setup clip
241 GrAppliedClip appliedClip; 241 GrAppliedClip appliedClip;
242 if (!clip.apply(fContext, pipelineBuilder, drawContext, &batch->bounds(), &a ppliedClip)) { 242 if (!clip.apply(fContext, pipelineBuilder, drawContext, &batch->bounds(), &a ppliedClip)) {
243 return; 243 return;
244 } 244 }
245 245
246 // TODO: this is the only remaining usage of the AutoRestoreFragmentProcesso rState - remove it 246 // TODO: this is the only remaining usage of the AutoRestoreFragmentProcesso rState - remove it
247 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; 247 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
248 if (appliedClip.clipCoverageFragmentProcessor()) { 248 if (appliedClip.getClipCoverageFragmentProcessor()) {
249 arfps.set(&pipelineBuilder); 249 arfps.set(&pipelineBuilder);
250 arfps.addCoverageFragmentProcessor(appliedClip.clipCoverageFragmentProce ssor()); 250 arfps.addCoverageFragmentProcessor(sk_ref_sp(appliedClip.getClipCoverage FragmentProcessor()));
251 } 251 }
252 252
253 GrPipeline::CreateArgs args; 253 GrPipeline::CreateArgs args;
254 args.fPipelineBuilder = &pipelineBuilder; 254 args.fPipelineBuilder = &pipelineBuilder;
255 args.fDrawContext = drawContext; 255 args.fDrawContext = drawContext;
256 args.fCaps = this->caps(); 256 args.fCaps = this->caps();
257 args.fScissor = &appliedClip.scissorState(); 257 args.fScissor = &appliedClip.scissorState();
258 args.fHasStencilClip = appliedClip.hasStencilClip(); 258 args.fHasStencilClip = appliedClip.hasStencilClip();
259 if (pipelineBuilder.hasUserStencilSettings() || appliedClip.hasStencilClip() ) { 259 if (pipelineBuilder.hasUserStencilSettings() || appliedClip.hasStencilClip() ) {
260 if (!fResourceProvider->attachStencilAttachment(drawContext->accessRende rTarget())) { 260 if (!fResourceProvider->attachStencilAttachment(drawContext->accessRende rTarget())) {
(...skipping 20 matching lines...) Expand all
281 viewport.fHeight); 281 viewport.fHeight);
282 if (appliedClip.scissorState().enabled()) { 282 if (appliedClip.scissorState().enabled()) {
283 const SkIRect& scissorRect = appliedClip.scissorState().rect(); 283 const SkIRect& scissorRect = appliedClip.scissorState().rect();
284 if (!ibounds.intersect(scissorRect)) { 284 if (!ibounds.intersect(scissorRect)) {
285 return; 285 return;
286 } 286 }
287 } 287 }
288 finalScissor.set(ibounds); 288 finalScissor.set(ibounds);
289 args.fScissor = &finalScissor; 289 args.fScissor = &finalScissor;
290 } 290 }
291 args.fOpts.fColorPOI.completeCalculations(pipelineBuilder.fColorFragmentProc essors.begin(), 291 args.fOpts.fColorPOI.completeCalculations(
292 pipelineBuilder.numColorFragmentPr ocessors()); 292 sk_sp_address_as_pointer_address(pipelineBuilder.fColorFragmentProcessor s.begin()),
293 pipelineBuilder.numColorFragmentProcessors());
293 args.fOpts.fCoveragePOI.completeCalculations( 294 args.fOpts.fCoveragePOI.completeCalculations(
294 pipelineBuilder.fCoverageFragment Processors.begin(), 295 sk_sp_address_as_pointer_address(pipelineBuilder.fCoverageFragmentProces sors.begin()),
295 pipelineBuilder.numCoverageFragme ntProcessors()); 296 pipelineBuilder.numCoverageFragmentProcessors());
296 if (!this->setupDstReadIfNecessary(pipelineBuilder, drawContext->accessRende rTarget(), 297 if (!this->setupDstReadIfNecessary(pipelineBuilder, drawContext->accessRende rTarget(),
297 clip, args.fOpts, 298 clip, args.fOpts,
298 &args.fDstTexture, batch->bounds())) { 299 &args.fDstTexture, batch->bounds())) {
299 return; 300 return;
300 } 301 }
301 302
302 if (!batch->installPipeline(args)) { 303 if (!batch->installPipeline(args)) {
303 return; 304 return;
304 } 305 }
305 306
(...skipping 17 matching lines...) Expand all
323 324
324 // Setup clip 325 // Setup clip
325 GrAppliedClip appliedClip; 326 GrAppliedClip appliedClip;
326 if (!clip.apply(fContext, pipelineBuilder, drawContext, nullptr, &appliedCli p)) { 327 if (!clip.apply(fContext, pipelineBuilder, drawContext, nullptr, &appliedCli p)) {
327 return; 328 return;
328 } 329 }
329 // TODO: respect fClipBatchToBounds if we ever start computing bounds here. 330 // TODO: respect fClipBatchToBounds if we ever start computing bounds here.
330 331
331 // Coverage AA does not make sense when rendering to the stencil buffer. The caller should never 332 // Coverage AA does not make sense when rendering to the stencil buffer. The caller should never
332 // attempt this in a situation that would require coverage AA. 333 // attempt this in a situation that would require coverage AA.
333 SkASSERT(!appliedClip.clipCoverageFragmentProcessor()); 334 SkASSERT(!appliedClip.getClipCoverageFragmentProcessor());
334 335
335 GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAtt achment( 336 GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAtt achment(
336 drawContext->accessRenderTarget( )); 337 drawContext->accessRenderTarget( ));
337 if (!stencilAttachment) { 338 if (!stencilAttachment) {
338 SkDebugf("ERROR creating stencil attachment. Draw skipped.\n"); 339 SkDebugf("ERROR creating stencil attachment. Draw skipped.\n");
339 return; 340 return;
340 } 341 }
341 342
342 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, 343 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix,
343 pipelineBuilder.isHWAntialias(), 344 pipelineBuilder.isHWAntialias(),
(...skipping 28 matching lines...) Expand all
372 if (this->caps()->useDrawInsteadOfClear()) { 373 if (this->caps()->useDrawInsteadOfClear()) {
373 // This works around a driver bug with clear by drawing a rect instead. 374 // This works around a driver bug with clear by drawing a rect instead.
374 // The driver will ignore a clear if it is the only thing rendered to a 375 // The driver will ignore a clear if it is the only thing rendered to a
375 // target before the target is read. 376 // target before the target is read.
376 if (rect == &rtRect) { 377 if (rect == &rtRect) {
377 drawContext->discard(); 378 drawContext->discard();
378 } 379 }
379 380
380 // TODO: flip this into real draw! 381 // TODO: flip this into real draw!
381 GrPipelineBuilder pipelineBuilder; 382 GrPipelineBuilder pipelineBuilder;
382 pipelineBuilder.setXPFactory( 383 pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSr c_Mode));
383 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
384 384
385 SkRect scalarRect = SkRect::Make(*rect); 385 SkRect scalarRect = SkRect::Make(*rect);
386 SkAutoTUnref<GrDrawBatch> batch( 386 SkAutoTUnref<GrDrawBatch> batch(
387 GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalar Rect, 387 GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalar Rect,
388 nullptr, nullptr)); 388 nullptr, nullptr));
389 this->drawBatch(pipelineBuilder, drawContext, GrNoClip(), batch); 389 this->drawBatch(pipelineBuilder, drawContext, GrNoClip(), batch);
390 } else { 390 } else {
391 GrBatch* batch = new GrClearBatch(*rect, color, drawContext->accessRende rTarget()); 391 GrBatch* batch = new GrClearBatch(*rect, color, drawContext->accessRende rTarget());
392 this->recordBatch(batch); 392 this->recordBatch(batch);
393 batch->unref(); 393 batch->unref();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 } 524 }
525 } 525 }
526 526
527 /////////////////////////////////////////////////////////////////////////////// 527 ///////////////////////////////////////////////////////////////////////////////
528 528
529 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { 529 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) {
530 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); 530 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
531 this->recordBatch(batch); 531 this->recordBatch(batch);
532 batch->unref(); 532 batch->unref();
533 } 533 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawContext.cpp ('k') | src/gpu/GrFragmentProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698