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

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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/image/SkImageShader.cpp ('k') | src/image/SkSurface_Gpu.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 2012 Google Inc. 2 * Copyright 2012 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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkImage_Gpu.h" 9 #include "SkImage_Gpu.h"
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 GrContext* ctx = fTexture->getContext(); 150 GrContext* ctx = fTexture->getContext();
151 GrSurfaceDesc desc = fTexture->desc(); 151 GrSurfaceDesc desc = fTexture->desc();
152 desc.fWidth = subset.width(); 152 desc.fWidth = subset.width();
153 desc.fHeight = subset.height(); 153 desc.fHeight = subset.height();
154 154
155 GrTexture* subTx = ctx->textureProvider()->createTexture(desc, 155 GrTexture* subTx = ctx->textureProvider()->createTexture(desc,
156 SkSurface::kYes_Bud geted == fBudgeted); 156 SkSurface::kYes_Bud geted == fBudgeted);
157 if (!subTx) { 157 if (!subTx) {
158 return nullptr; 158 return nullptr;
159 } 159 }
160
160 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0)); 161 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0));
161 return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, fAl phaType, subTx, 162 return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, fAl phaType, subTx,
162 fBudgeted); 163 fBudgeted);
163 } 164 }
164 165
165 //////////////////////////////////////////////////////////////////////////////// /////////////////// 166 //////////////////////////////////////////////////////////////////////////////// ///////////////////
166 167
167 #include "SkGrPixelRef.h" 168 #include "SkGrPixelRef.h"
168 #include "SkImageFilter.h" 169 #include "SkImageFilter.h"
169 170
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (desc.fWidth <= 0 || desc.fHeight <= 0) { 278 if (desc.fWidth <= 0 || desc.fHeight <= 0) {
278 return nullptr; 279 return nullptr;
279 } 280 }
280 281
281 SkAutoTUnref<GrTexture> src(ctx->textureProvider()->wrapBackendTexture( 282 SkAutoTUnref<GrTexture> src(ctx->textureProvider()->wrapBackendTexture(
282 desc, kBorrow_GrWrapOwnership)); 283 desc, kBorrow_GrWrapOwnership));
283 if (!src) { 284 if (!src) {
284 return nullptr; 285 return nullptr;
285 } 286 }
286 287
288 src->setFromRawPixels(true);
289 src->setException(true);
290
287 const bool isBudgeted = true; 291 const bool isBudgeted = true;
288 SkAutoTUnref<GrTexture> dst(GrDeepCopyTexture(src, isBudgeted)); 292 SkAutoTUnref<GrTexture> dst(GrDeepCopyTexture(src, isBudgeted));
289 if (!dst) { 293 if (!dst) {
290 return nullptr; 294 return nullptr;
291 } 295 }
292 296
293 const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted; 297 const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted;
294 return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, dst, 298 return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, dst,
295 budgeted); 299 budgeted);
296 } 300 }
297 301
302 #include "GrDrawTarget.h"
303
298 SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS pace, 304 SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS pace,
299 const GrBackendObject yuvTextureHandles [3], 305 const GrBackendObject yuvTextureHandles [3],
300 const SkISize yuvSizes[3], 306 const SkISize yuvSizes[3],
301 GrSurfaceOrigin origin) { 307 GrSurfaceOrigin origin) {
302 const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted; 308 const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted;
303 309
304 if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 || 310 if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 ||
305 yuvSizes[1].fWidth <= 0 || yuvSizes[1].fHeight <= 0 || 311 yuvSizes[1].fWidth <= 0 || yuvSizes[1].fHeight <= 0 ||
306 yuvSizes[2].fWidth <= 0 || yuvSizes[2].fHeight <= 0) { 312 yuvSizes[2].fWidth <= 0 || yuvSizes[2].fHeight <= 0) {
307 return nullptr; 313 return nullptr;
(...skipping 26 matching lines...) Expand all
334 SkAutoTUnref<GrTexture> yTex(ctx->textureProvider()->wrapBackendTexture( 340 SkAutoTUnref<GrTexture> yTex(ctx->textureProvider()->wrapBackendTexture(
335 yDesc, kBorrow_GrWrapOwnership)); 341 yDesc, kBorrow_GrWrapOwnership));
336 SkAutoTUnref<GrTexture> uTex(ctx->textureProvider()->wrapBackendTexture( 342 SkAutoTUnref<GrTexture> uTex(ctx->textureProvider()->wrapBackendTexture(
337 uDesc, kBorrow_GrWrapOwnership)); 343 uDesc, kBorrow_GrWrapOwnership));
338 SkAutoTUnref<GrTexture> vTex(ctx->textureProvider()->wrapBackendTexture( 344 SkAutoTUnref<GrTexture> vTex(ctx->textureProvider()->wrapBackendTexture(
339 vDesc, kBorrow_GrWrapOwnership)); 345 vDesc, kBorrow_GrWrapOwnership));
340 if (!yTex || !uTex || !vTex) { 346 if (!yTex || !uTex || !vTex) {
341 return nullptr; 347 return nullptr;
342 } 348 }
343 349
350 yTex->setFromRawPixels(true);
351 yTex->setException(true);
352 uTex->setFromRawPixels(true);
353 uTex->setException(true);
354 vTex->setFromRawPixels(true);
355 vTex->setException(true);
356
344 GrSurfaceDesc dstDesc; 357 GrSurfaceDesc dstDesc;
345 // Needs to be a render target in order to draw to it for the yuv->rgb conve rsion. 358 // Needs to be a render target in order to draw to it for the yuv->rgb conve rsion.
346 dstDesc.fFlags = kRenderTarget_GrSurfaceFlag; 359 dstDesc.fFlags = kRenderTarget_GrSurfaceFlag;
347 dstDesc.fOrigin = origin; 360 dstDesc.fOrigin = origin;
348 dstDesc.fWidth = yuvSizes[0].fWidth; 361 dstDesc.fWidth = yuvSizes[0].fWidth;
349 dstDesc.fHeight = yuvSizes[0].fHeight; 362 dstDesc.fHeight = yuvSizes[0].fHeight;
350 dstDesc.fConfig = kRGBA_8888_GrPixelConfig; 363 dstDesc.fConfig = kRGBA_8888_GrPixelConfig;
351 dstDesc.fSampleCnt = 0; 364 dstDesc.fSampleCnt = 0;
352 365
353 SkAutoTUnref<GrTexture> dst(ctx->textureProvider()->createTexture(dstDesc, t rue)); 366 SkAutoTUnref<GrTexture> dst(ctx->textureProvider()->createTexture(dstDesc, t rue));
354 if (!dst) { 367 if (!dst) {
355 return nullptr; 368 return nullptr;
356 } 369 }
357 370
358 GrPaint paint; 371 GrPaint paint;
359 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 372 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
360 paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Create(yTex, uTex, vTex, y uvSizes, 373 paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Create(yTex, uTex, vTex, y uvSizes,
361 colorSpace))->unref (); 374 colorSpace, dst->as RenderTarget()))->unref();
362 375
363 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), 376 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth),
364 SkIntToScalar(dstDesc.fHeight)); 377 SkIntToScalar(dstDesc.fHeight));
365 SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext(dst->asRenderTarget ())); 378 SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext(dst->asRenderTarget ()));
366 if (!drawContext) { 379 if (!drawContext) {
367 return nullptr; 380 return nullptr;
368 } 381 }
369 382
383 // nothing to "use" in this case
370 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect); 384 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect);
385
371 ctx->flushSurfaceWrites(dst); 386 ctx->flushSurfaceWrites(dst);
372 return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueI D, 387 return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueI D,
373 kOpaque_SkAlphaType, dst, budgeted); 388 kOpaque_SkAlphaType, dst, budgeted);
374 } 389 }
375 390
376 //////////////////////////////////////////////////////////////////////////////// /////////////////// 391 //////////////////////////////////////////////////////////////////////////////// ///////////////////
377 392
378 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { 393 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) {
379 GrContext* ctx = src->getContext(); 394 GrContext* ctx = src->getContext();
380 395
381 GrSurfaceDesc desc = src->desc(); 396 GrSurfaceDesc desc = src->desc();
382 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp tr, 0); 397 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp tr, 0);
383 if (!dst) { 398 if (!dst) {
384 return nullptr; 399 return nullptr;
385 } 400 }
386 401
387 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); 402 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
388 const SkIPoint dstP = SkIPoint::Make(0, 0); 403 const SkIPoint dstP = SkIPoint::Make(0, 0);
389 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); 404 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp);
390 return dst; 405 return dst;
391 } 406 }
392 407
OLDNEW
« no previous file with comments | « src/image/SkImageShader.cpp ('k') | src/image/SkSurface_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698