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

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

Issue 2215323003: Start using RenderTargetProxy (omnibus) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 1 month 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/GrClipStackClip.h ('k') | src/gpu/GrContext.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 2016 Google Inc. 2 * Copyright 2016 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 "GrClipStackClip.h" 8 #include "GrClipStackClip.h"
9 9
10 #include "GrAppliedClip.h" 10 #include "GrAppliedClip.h"
11 #include "GrContextPriv.h" 11 #include "GrContextPriv.h"
12 #include "GrDrawingManager.h" 12 #include "GrDrawingManager.h"
13 #include "GrRenderTargetContextPriv.h" 13 #include "GrRenderTargetContextPriv.h"
14 #include "GrFixedClip.h" 14 #include "GrFixedClip.h"
15 #include "GrGpuResourcePriv.h" 15 #include "GrGpuResourcePriv.h"
16 #include "GrRenderTargetPriv.h" 16 #include "GrRenderTargetPriv.h"
17 #include "GrStencilAttachment.h" 17 #include "GrStencilAttachment.h"
18 #include "GrSWMaskHelper.h" 18 #include "GrSWMaskHelper.h"
19 #include "GrTextureProxy.h"
19 #include "effects/GrConvexPolyEffect.h" 20 #include "effects/GrConvexPolyEffect.h"
20 #include "effects/GrRRectEffect.h" 21 #include "effects/GrRRectEffect.h"
21 #include "effects/GrTextureDomain.h" 22 #include "effects/GrTextureDomain.h"
22 23
23 typedef SkClipStack::Element Element; 24 typedef SkClipStack::Element Element;
24 typedef GrReducedClip::InitialState InitialState; 25 typedef GrReducedClip::InitialState InitialState;
25 typedef GrReducedClip::ElementList ElementList; 26 typedef GrReducedClip::ElementList ElementList;
26 27
27 static const int kMaxAnalyticElements = 4; 28 static const int kMaxAnalyticElements = 4;
28 29
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return; 74 return;
74 } 75 }
75 SkRect devBounds; 76 SkRect devBounds;
76 fStack->getConservativeBounds(-fOrigin.x(), -fOrigin.y(), width, height, &de vBounds, 77 fStack->getConservativeBounds(-fOrigin.x(), -fOrigin.y(), width, height, &de vBounds,
77 isIntersectionOfRects); 78 isIntersectionOfRects);
78 devBounds.roundOut(devResult); 79 devBounds.roundOut(devResult);
79 } 80 }
80 81
81 //////////////////////////////////////////////////////////////////////////////// 82 ////////////////////////////////////////////////////////////////////////////////
82 // set up the draw state to enable the aa clipping mask. 83 // set up the draw state to enable the aa clipping mask.
83 static sk_sp<GrFragmentProcessor> create_fp_for_mask(GrTexture* result, 84 static sk_sp<GrFragmentProcessor> create_fp_for_mask(GrTextureProxy* result,
84 const SkIRect &devBound) { 85 const SkIRect &devBound) {
85 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); 86 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
86 return GrDeviceSpaceTextureDecalFragmentProcessor::Make(result, domainTexels , 87 return GrDeviceSpaceTextureDecalFragmentProcessor::Make(result, domainTexels ,
87 {devBound.fLeft, dev Bound.fTop}); 88 {devBound.fLeft, dev Bound.fTop});
88 } 89 }
89 90
90 // Does the path in 'element' require SW rendering? If so, return true (and, 91 // Does the path in 'element' require SW rendering? If so, return true (and,
91 // optionally, set 'prOut' to NULL. If not, return false (and, optionally, set 92 // optionally, set 'prOut' to NULL. If not, return false (and, optionally, set
92 // 'prOut' to the non-SW path renderer that will do the job). 93 // 'prOut' to the non-SW path renderer that will do the job).
93 bool GrClipStackClip::PathNeedsSWRenderer(GrContext* context, 94 bool GrClipStackClip::PathNeedsSWRenderer(GrContext* context,
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (reducedClip.requiresAA() && 329 if (reducedClip.requiresAA() &&
329 get_analytic_clip_processor(reducedClip.elements(), disallowAnalytic AA, 330 get_analytic_clip_processor(reducedClip.elements(), disallowAnalytic AA,
330 {-clipX, -clipY}, devBounds, &clipFP)) { 331 {-clipX, -clipY}, devBounds, &clipFP)) {
331 out->addCoverageFP(std::move(clipFP)); 332 out->addCoverageFP(std::move(clipFP));
332 return true; 333 return true;
333 } 334 }
334 } 335 }
335 336
336 // If the stencil buffer is multisampled we can use it to do everything. 337 // If the stencil buffer is multisampled we can use it to do everything.
337 if (!renderTargetContext->isStencilBufferMultisampled() && reducedClip.requi resAA()) { 338 if (!renderTargetContext->isStencilBufferMultisampled() && reducedClip.requi resAA()) {
338 sk_sp<GrTexture> result; 339 sk_sp<GrTextureProxy> result;
339 if (UseSWOnlyPath(context, hasUserStencilSettings, renderTargetContext, reducedClip)) { 340 if (UseSWOnlyPath(context, hasUserStencilSettings, renderTargetContext, reducedClip)) {
340 // The clip geometry is complex enough that it will be more efficien t to create it 341 // The clip geometry is complex enough that it will be more efficien t to create it
341 // entirely in software 342 // entirely in software
342 result = CreateSoftwareClipMask(context->textureProvider(), reducedC lip); 343 result = CreateSoftwareClipMask(context->textureProvider(), reducedC lip);
343 } else { 344 } else {
344 result = CreateAlphaClipMask(context, reducedClip); 345 result = CreateAlphaClipMask(context, reducedClip);
345 // If createAlphaClipMask fails it means UseSWOnlyPath has a bug 346 // If createAlphaClipMask fails it means UseSWOnlyPath has a bug
346 SkASSERT(result); 347 SkASSERT(result);
347 } 348 }
348 349
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 static void GetClipMaskKey(int32_t clipGenID, const SkIRect& bounds, GrUniqueKey * key) { 383 static void GetClipMaskKey(int32_t clipGenID, const SkIRect& bounds, GrUniqueKey * key) {
383 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); 384 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
384 GrUniqueKey::Builder builder(key, kDomain, 3); 385 GrUniqueKey::Builder builder(key, kDomain, 3);
385 builder[0] = clipGenID; 386 builder[0] = clipGenID;
386 // SkToS16 because image filters outset layers to a size indicated by the fi lter, which can 387 // SkToS16 because image filters outset layers to a size indicated by the fi lter, which can
387 // sometimes result in negative coordinates from clip space. 388 // sometimes result in negative coordinates from clip space.
388 builder[1] = SkToS16(bounds.fLeft) | (SkToS16(bounds.fRight) << 16); 389 builder[1] = SkToS16(bounds.fLeft) | (SkToS16(bounds.fRight) << 16);
389 builder[2] = SkToS16(bounds.fTop) | (SkToS16(bounds.fBottom) << 16); 390 builder[2] = SkToS16(bounds.fTop) | (SkToS16(bounds.fBottom) << 16);
390 } 391 }
391 392
392 sk_sp<GrTexture> GrClipStackClip::CreateAlphaClipMask(GrContext* context, 393 sk_sp<GrTextureProxy> GrClipStackClip::CreateAlphaClipMask(GrContext* context,
393 const GrReducedClip& reduc edClip) { 394 const GrReducedClip& reducedClip) {
394 GrResourceProvider* resourceProvider = context->resourceProvider(); 395 GrResourceProvider* resourceProvider = context->resourceProvider();
395 GrUniqueKey key; 396 GrUniqueKey key;
396 GetClipMaskKey(reducedClip.elementsGenID(), reducedClip.ibounds(), &key); 397 GetClipMaskKey(reducedClip.elementsGenID(), reducedClip.ibounds(), &key);
397 if (GrTexture* texture = resourceProvider->findAndRefTextureByUniqueKey(key) ) { 398 if (GrTexture* texture = resourceProvider->findAndRefTextureByUniqueKey(key) ) {
398 return sk_sp<GrTexture>(texture); 399 return GrTextureProxy::Make(sk_sp<GrTexture>(texture));
399 } 400 }
400 401
401 sk_sp<GrRenderTargetContext> rtc(context->makeRenderTargetContextWithFallbac k( 402 sk_sp<GrRenderTargetContext> rtc(context->makeRenderTargetContextWithFallbac k(
402 SkB ackingFit::kApprox, 403 SkB ackingFit::kApprox,
403 red ucedClip.width(), 404 red ucedClip.width(),
404 red ucedClip.height(), 405 red ucedClip.height(),
405 kAl pha_8_GrPixelConfig, 406 kAl pha_8_GrPixelConfig,
406 nul lptr)); 407 nul lptr));
407 if (!rtc) { 408 if (!rtc) {
408 return nullptr; 409 return nullptr;
409 } 410 }
410 411
411 if (!reducedClip.drawAlphaClipMask(rtc.get())) { 412 if (!reducedClip.drawAlphaClipMask(rtc.get())) {
412 return nullptr; 413 return nullptr;
413 } 414 }
414 415
415 sk_sp<GrTexture> texture(rtc->asTexture()); 416 sk_sp<GrTextureProxy> texture(rtc->asDeferredTexture());
416 SkASSERT(texture); 417 SkASSERT(texture);
417 texture->resourcePriv().setUniqueKey(key); 418 //texture->resourcePriv().setUniqueKey(key);
418 return texture; 419 return texture;
419 } 420 }
420 421
421 sk_sp<GrTexture> GrClipStackClip::CreateSoftwareClipMask(GrTextureProvider* texP rovider, 422 ////////////////////////////////////////////////////////////////////////////////
422 const GrReducedClip& re ducedClip) { 423 sk_sp<GrTextureProxy> GrClipStackClip::CreateSoftwareClipMask(GrTextureProvider* texProvider,
424 const GrReducedCli p& reducedClip) {
423 GrUniqueKey key; 425 GrUniqueKey key;
424 GetClipMaskKey(reducedClip.elementsGenID(), reducedClip.ibounds(), &key); 426 GetClipMaskKey(reducedClip.elementsGenID(), reducedClip.ibounds(), &key);
425 if (GrTexture* texture = texProvider->findAndRefTextureByUniqueKey(key)) { 427 if (GrTexture* texture = texProvider->findAndRefTextureByUniqueKey(key)) {
426 return sk_sp<GrTexture>(texture); 428 return GrTextureProxy::Make(sk_ref_sp(texture)); // sub-optimal!!
427 } 429 }
428 430
429 // The mask texture may be larger than necessary. We round out the clip spac e bounds and pin 431 // The mask texture may be larger than necessary. We round out the clip spac e bounds and pin
430 // the top left corner of the resulting rect to the top left of the texture. 432 // the top left corner of the resulting rect to the top left of the texture.
431 SkIRect maskSpaceIBounds = SkIRect::MakeWH(reducedClip.width(), reducedClip. height()); 433 SkIRect maskSpaceIBounds = SkIRect::MakeWH(reducedClip.width(), reducedClip. height());
432 434
433 GrSWMaskHelper helper(texProvider); 435 GrSWMaskHelper helper(texProvider);
434 436
435 // Set the matrix so that rendered clip elements are transformed to mask spa ce from clip 437 // Set the matrix so that rendered clip elements are transformed to mask spa ce from clip
436 // space. 438 // space.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 desc.fConfig = kAlpha_8_GrPixelConfig; 485 desc.fConfig = kAlpha_8_GrPixelConfig;
484 486
485 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); 487 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc));
486 if (!result) { 488 if (!result) {
487 return nullptr; 489 return nullptr;
488 } 490 }
489 result->resourcePriv().setUniqueKey(key); 491 result->resourcePriv().setUniqueKey(key);
490 492
491 helper.toTexture(result.get()); 493 helper.toTexture(result.get());
492 494
493 return result; 495 return GrTextureProxy::Make(result);
494 } 496 }
OLDNEW
« no previous file with comments | « src/gpu/GrClipStackClip.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698