OLD | NEW |
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 | 8 |
9 #include "GrGpu.h" | 9 #include "GrGpu.h" |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // By default, GrRenderTargets are GL's normal orientation so that they | 81 // By default, GrRenderTargets are GL's normal orientation so that they |
82 // can be drawn to by the outside world without the client having | 82 // can be drawn to by the outside world without the client having |
83 // to render upside down. | 83 // to render upside down. |
84 if (kDefault_GrSurfaceOrigin == origin) { | 84 if (kDefault_GrSurfaceOrigin == origin) { |
85 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr
igin; | 85 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr
igin; |
86 } else { | 86 } else { |
87 return origin; | 87 return origin; |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budget
ed, | 91 GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, bool budgeted, |
92 const void* srcData, size_t rowBytes) { | 92 const void* srcData, size_t rowBytes) { |
93 GrSurfaceDesc desc = origDesc; | 93 GrSurfaceDesc desc = origDesc; |
94 | 94 |
95 if (!this->caps()->isConfigTexturable(desc.fConfig)) { | 95 if (!this->caps()->isConfigTexturable(desc.fConfig)) { |
96 return nullptr; | 96 return nullptr; |
97 } | 97 } |
98 | 98 |
99 bool isRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); | 99 bool isRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); |
100 if (isRT && !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt
> 0)) { | 100 if (isRT && !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt
> 0)) { |
101 return nullptr; | 101 return nullptr; |
(...skipping 11 matching lines...) Expand all Loading... |
113 if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { | 113 if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { |
114 return nullptr; | 114 return nullptr; |
115 } | 115 } |
116 } else { | 116 } else { |
117 int maxSize = this->caps()->maxTextureSize(); | 117 int maxSize = this->caps()->maxTextureSize(); |
118 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | 118 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
119 return nullptr; | 119 return nullptr; |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 GrGpuResource::LifeCycle lifeCycle = SkBudgeted::kYes == budgeted ? | 123 GrGpuResource::LifeCycle lifeCycle = budgeted ? GrGpuResource::kCached_LifeC
ycle : |
124 GrGpuResource::kCached_LifeCycle : | 124 GrGpuResource::kUncached_Lif
eCycle; |
125 GrGpuResource::kUncached_LifeCycle; | |
126 | 125 |
127 desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); | 126 desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); |
128 // Attempt to catch un- or wrongly initialized sample counts; | 127 // Attempt to catch un- or wrongly initialized sample counts; |
129 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); | 128 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); |
130 | 129 |
131 desc.fOrigin = resolve_origin(desc.fOrigin, isRT); | 130 desc.fOrigin = resolve_origin(desc.fOrigin, isRT); |
132 | 131 |
133 if (GrPixelConfigIsCompressed(desc.fConfig)) { | 132 if (GrPixelConfigIsCompressed(desc.fConfig)) { |
134 // We shouldn't be rendering into this | 133 // We shouldn't be rendering into this |
135 SkASSERT(!isRT); | 134 SkASSERT(!isRT); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 398 } |
400 | 399 |
401 GrVertices::Iterator iter; | 400 GrVertices::Iterator iter; |
402 const GrNonInstancedVertices* verts = iter.init(vertices); | 401 const GrNonInstancedVertices* verts = iter.init(vertices); |
403 do { | 402 do { |
404 this->onDraw(args, *verts); | 403 this->onDraw(args, *verts); |
405 fStats.incNumDraws(); | 404 fStats.incNumDraws(); |
406 } while ((verts = iter.next())); | 405 } while ((verts = iter.next())); |
407 } | 406 } |
408 | 407 |
OLD | NEW |