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

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

Issue 2225303002: Add flag for window rectangles to GrRenderTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add GrRenderTarget flag for window rectangles Created 4 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 | « src/gpu/GrRenderTargetPriv.h ('k') | src/gpu/gl/GrGLGpu.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 "GrRenderTargetProxy.h" 8 #include "GrRenderTargetProxy.h"
9 9
10 #include "GrCaps.h"
10 #include "GrDrawTarget.h" 11 #include "GrDrawTarget.h"
11 #include "GrGpuResourcePriv.h" 12 #include "GrGpuResourcePriv.h"
12 #include "GrRenderTargetPriv.h"
13 13
14 GrRenderTargetProxy::GrRenderTargetProxy(sk_sp<GrRenderTarget> rt) 14 // Deferred version
15 // TODO: we can probably munge the 'desc' in both the wrapped and deferred
16 // cases to make the sampleConfig/numSamples stuff more rational.
17 GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc & desc,
18 SkBackingFit fit, SkBudgeted budgeted)
19 : INHERITED(desc, fit, budgeted)
20 , fTarget(nullptr)
21 , fFlags(GrRenderTargetPriv::Flags::kNone)
22 , fLastDrawTarget(nullptr) {
23 // Since we know the newly created render target will be internal, we are ab le to precompute
24 // what the flags will ultimately end up being.
25 if (caps.usesMixedSamples() && fDesc.fSampleCnt > 0) {
26 fFlags |= GrRenderTargetPriv::Flags::kMixedSampled;
27 }
28 if (caps.maxWindowRectangles() > 0) {
29 fFlags |= GrRenderTargetPriv::Flags::kWindowRectsSupport;
30 }
31 }
32
33 // Wrapped version
34 GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, sk_sp<GrRenderTarge t> rt)
15 : INHERITED(rt->desc(), SkBackingFit::kExact, rt->resourcePriv().isBudgeted( )) 35 : INHERITED(rt->desc(), SkBackingFit::kExact, rt->resourcePriv().isBudgeted( ))
16 , fTarget(std::move(rt)) 36 , fTarget(std::move(rt))
17 , fSampleConfig(fTarget->renderTargetPriv().sampleConfig()) 37 , fFlags(fTarget->renderTargetPriv().flags())
18 , fLastDrawTarget(nullptr) { 38 , fLastDrawTarget(nullptr) {
19 } 39 }
20 40
21 GrRenderTargetProxy::~GrRenderTargetProxy() { 41 GrRenderTargetProxy::~GrRenderTargetProxy() {
22 if (fLastDrawTarget) { 42 if (fLastDrawTarget) {
23 fLastDrawTarget->clearRT(); 43 fLastDrawTarget->clearRT();
24 } 44 }
25 SkSafeUnref(fLastDrawTarget); 45 SkSafeUnref(fLastDrawTarget);
26 } 46 }
27 47
(...skipping 12 matching lines...) Expand all
40 } else { 60 } else {
41 tex.reset(texProvider->createTexture(desc, fBudgeted)); 61 tex.reset(texProvider->createTexture(desc, fBudgeted));
42 } 62 }
43 if (!tex || !tex->asRenderTarget()) { 63 if (!tex || !tex->asRenderTarget()) {
44 return nullptr; 64 return nullptr;
45 } 65 }
46 66
47 fTarget = sk_ref_sp(tex->asRenderTarget()); 67 fTarget = sk_ref_sp(tex->asRenderTarget());
48 68
49 // Check that our a priori computation matched the ultimate reality 69 // Check that our a priori computation matched the ultimate reality
50 SkASSERT(fSampleConfig == fTarget->renderTargetPriv().sampleConfig()); 70 SkASSERT(fFlags == fTarget->renderTargetPriv().flags());
51 71
52 return fTarget.get(); 72 return fTarget.get();
53 } 73 }
54 74
55 void GrRenderTargetProxy::setLastDrawTarget(GrDrawTarget* dt) { 75 void GrRenderTargetProxy::setLastDrawTarget(GrDrawTarget* dt) {
56 if (fLastDrawTarget) { 76 if (fLastDrawTarget) {
57 // The non-MDB world never closes so we can't check this condition 77 // The non-MDB world never closes so we can't check this condition
58 #ifdef ENABLE_MDB 78 #ifdef ENABLE_MDB
59 SkASSERT(fLastDrawTarget->isClosed()); 79 SkASSERT(fLastDrawTarget->isClosed());
60 #endif 80 #endif
61 fLastDrawTarget->clearRT(); 81 fLastDrawTarget->clearRT();
62 } 82 }
63 83
64 SkRefCnt_SafeAssign(fLastDrawTarget, dt); 84 SkRefCnt_SafeAssign(fLastDrawTarget, dt);
65 } 85 }
66 86
67 sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(const GrCaps& caps, 87 sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(const GrCaps& caps,
68 const GrSurfaceDesc& desc, 88 const GrSurfaceDesc& desc,
69 SkBackingFit fit, 89 SkBackingFit fit,
70 SkBudgeted budgeted) { 90 SkBudgeted budgeted) {
71 return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(caps, desc, fit, b udgeted)); 91 return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(caps, desc, fit, b udgeted));
72 } 92 }
73 93
74 sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(sk_sp<GrRenderTarget> rt) { 94 sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(const GrCaps& caps, sk_sp<G rRenderTarget> rt) {
75 return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(rt)); 95 return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(caps, rt));
76 } 96 }
77 97
OLDNEW
« no previous file with comments | « src/gpu/GrRenderTargetPriv.h ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698