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

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

Issue 1918003003: Bring sk_sp to GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 8 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
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 "GrTextureToYUVPlanes.h" 8 #include "GrTextureToYUVPlanes.h"
9 #include "effects/GrSimpleTextureEffect.h" 9 #include "effects/GrSimpleTextureEffect.h"
10 #include "effects/GrYUVEffect.h" 10 #include "effects/GrYUVEffect.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 uvDesc.fHeight = sizes[2].fHeight; 110 uvDesc.fHeight = sizes[2].fHeight;
111 vTex.reset(context->textureProvider()->createApproxTexture(uvDes c)); 111 vTex.reset(context->textureProvider()->createApproxTexture(uvDes c));
112 if (!uTex || !vTex) { 112 if (!uTex || !vTex) {
113 return false; 113 return false;
114 } 114 }
115 } 115 }
116 } 116 }
117 117
118 // Do all the draws before any readback. 118 // Do all the draws before any readback.
119 if (yuvTex) { 119 if (yuvTex) {
120 SkAutoTUnref<GrDrawContext> dc(context->drawContext(yuvTex->asRender Target())); 120 sk_sp<GrDrawContext> dc(context->drawContext(sk_ref_sp(yuvTex->asRen derTarget())));
121 if (!dc) { 121 if (!dc) {
122 return false; 122 return false;
123 } 123 }
124 if (!convert_texture(texture, dc, sizes[0].fWidth, sizes[0].fHeight, colorSpace, 124 if (!convert_texture(texture, dc.get(), sizes[0].fWidth, sizes[0].fH eight, colorSpace,
125 GrYUVEffect::CreateRGBToYUV)) { 125 GrYUVEffect::CreateRGBToYUV)) {
126 return false; 126 return false;
127 } 127 }
128 128
129 } else { 129 } else {
130 SkASSERT(yTex); 130 SkASSERT(yTex);
131 SkAutoTUnref<GrDrawContext> dc(context->drawContext(yTex->asRenderTa rget())); 131 sk_sp<GrDrawContext> dc(context->drawContext(sk_ref_sp(yTex->asRende rTarget())));
132 if (!dc) { 132 if (!dc) {
133 return false; 133 return false;
134 } 134 }
135 if (!convert_texture(texture, dc, sizes[0].fWidth, sizes[0].fHeight, colorSpace, 135 if (!convert_texture(texture, dc.get(), sizes[0].fWidth, sizes[0].fH eight, colorSpace,
136 GrYUVEffect::CreateRGBToY)) { 136 GrYUVEffect::CreateRGBToY)) {
137 return false; 137 return false;
138 } 138 }
139 if (uvTex) { 139 if (uvTex) {
140 dc.reset(context->drawContext(uvTex->asRenderTarget())); 140 dc = context->drawContext(sk_ref_sp(uvTex->asRenderTarget()));
141 if (!dc) { 141 if (!dc) {
142 return false; 142 return false;
143 } 143 }
144 if (!convert_texture(texture, dc, sizes[1].fWidth, sizes[1].fHei ght, 144 if (!convert_texture(texture, dc.get(), sizes[1].fWidth, sizes[1 ].fHeight,
145 colorSpace, GrYUVEffect::CreateRGBToUV)) { 145 colorSpace, GrYUVEffect::CreateRGBToUV)) {
146 return false; 146 return false;
147 } 147 }
148 } else { 148 } else {
149 SkASSERT(uTex && vTex); 149 SkASSERT(uTex && vTex);
150 dc.reset(context->drawContext(uTex->asRenderTarget())); 150 dc = context->drawContext(sk_ref_sp(uTex->asRenderTarget()));
151 if (!dc) { 151 if (!dc) {
152 return false; 152 return false;
153 } 153 }
154 if (!convert_texture(texture, dc, sizes[1].fWidth, sizes[1].fHei ght, 154 if (!convert_texture(texture, dc.get(), sizes[1].fWidth, sizes[1 ].fHeight,
155 colorSpace, GrYUVEffect::CreateRGBToU)) { 155 colorSpace, GrYUVEffect::CreateRGBToU)) {
156 return false; 156 return false;
157 } 157 }
158 dc.reset(context->drawContext(vTex->asRenderTarget())); 158 dc = context->drawContext(sk_ref_sp(vTex->asRenderTarget()));
159 if (!dc) { 159 if (!dc) {
160 return false; 160 return false;
161 } 161 }
162 if (!convert_texture(texture, dc, sizes[2].fWidth, sizes[2].fHei ght, 162 if (!convert_texture(texture, dc.get(), sizes[2].fWidth, sizes[2 ].fHeight,
163 colorSpace, GrYUVEffect::CreateRGBToV)) { 163 colorSpace, GrYUVEffect::CreateRGBToV)) {
164 return false; 164 return false;
165 } 165 }
166 } 166 }
167 } 167 }
168 168
169 if (yuvTex) { 169 if (yuvTex) {
170 SkASSERT(sizes[0] == sizes[1] && sizes[1] == sizes[2]); 170 SkASSERT(sizes[0] == sizes[1] && sizes[1] == sizes[2]);
171 SkISize yuvSize = sizes[0]; 171 SkISize yuvSize = sizes[0];
172 // We have no kRGB_888 pixel format, so readback rgba and then copy three channels. 172 // We have no kRGB_888 pixel format, so readback rgba and then copy three channels.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (!vTex->readPixels(0, 0, sizes[2].fWidth, sizes[2].fHeight, 239 if (!vTex->readPixels(0, 0, sizes[2].fWidth, sizes[2].fHeight,
240 kAlpha_8_GrPixelConfig, planes[2], rowByte s[2])) { 240 kAlpha_8_GrPixelConfig, planes[2], rowByte s[2])) {
241 return false; 241 return false;
242 } 242 }
243 return true; 243 return true;
244 } 244 }
245 } 245 }
246 } 246 }
247 return false; 247 return false;
248 } 248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698