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

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

Issue 1919993002: Added --deepColor option to SampleApp, triggers creation of a ten-bit/channel buffer on Windows. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Plumb gamma to shader, fix window title 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrContext.h" 8 #include "GrContext.h"
9 #include "GrContextOptions.h" 9 #include "GrContextOptions.h"
10 #include "GrDrawingManager.h" 10 #include "GrDrawingManager.h"
11 #include "GrDrawContext.h" 11 #include "GrDrawContext.h"
12 #include "GrLayerCache.h" 12 #include "GrLayerCache.h"
13 #include "GrResourceCache.h" 13 #include "GrResourceCache.h"
14 #include "GrResourceProvider.h" 14 #include "GrResourceProvider.h"
15 #include "GrSoftwarePathRenderer.h" 15 #include "GrSoftwarePathRenderer.h"
16 #include "GrSurfacePriv.h" 16 #include "GrSurfacePriv.h"
17 17
18 #include "SkConfig8888.h" 18 #include "SkConfig8888.h"
19 #include "SkGrPriv.h" 19 #include "SkGrPriv.h"
20 20
21 #include "batches/GrCopySurfaceBatch.h" 21 #include "batches/GrCopySurfaceBatch.h"
22 #include "effects/GrColorSpaceEffect.h"
22 #include "effects/GrConfigConversionEffect.h" 23 #include "effects/GrConfigConversionEffect.h"
23 #include "text/GrTextBlobCache.h" 24 #include "text/GrTextBlobCache.h"
24 25
25 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) 26 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
26 #define ASSERT_SINGLE_OWNER \ 27 #define ASSERT_SINGLE_OWNER \
27 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);) 28 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);)
28 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } 29 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
29 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal se; } 30 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal se; }
30 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null ptr; } 31 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null ptr; }
31 32
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 srcPI.fColorType = dstPI.fColorType; 522 srcPI.fColorType = dstPI.fColorType;
522 srcPI.fAlphaType = kPremul_SkAlphaType; 523 srcPI.fAlphaType = kPremul_SkAlphaType;
523 srcPI.fPixels = buffer; 524 srcPI.fPixels = buffer;
524 srcPI.fRowBytes = rowBytes; 525 srcPI.fRowBytes = rowBytes;
525 526
526 return srcPI.convertPixelsTo(&dstPI, width, height); 527 return srcPI.convertPixelsTo(&dstPI, width, height);
527 } 528 }
528 return true; 529 return true;
529 } 530 }
530 531
532 bool GrContext::writeSurfacePixelsWithColorSpace(GrSurface* surface,
533 int left, int top, int width, i nt height,
534 GrPixelConfig srcConfig,
535 const SkColorSpace* srcColorSpa ce,
536 const SkColorSpace* dstColorSpa ce,
537 const void* buffer, size_t rowB ytes,
538 uint32_t colorSpaceOpsFlags) {
539 ASSERT_SINGLE_OWNER
540 RETURN_FALSE_IF_ABANDONED
541 ASSERT_OWNED_RESOURCE(surface);
542 SkASSERT(surface);
543 GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::writeSurfacePixelsWithCo lorSpace");
544
545 if (surface->surfacePriv().hasPendingIO()) {
546 this->flush();
547 }
548
549 GrSurfaceDesc srcDesc;
550 srcDesc.fWidth = width;
551 srcDesc.fHeight = height;
552 srcDesc.fConfig = srcConfig;
553
554 SkAutoTUnref<GrTexture> tempTexture(
555 this->textureProvider()->createTexture(srcDesc, SkBudgeted::kYes, buffer , rowBytes));
556 if (!tempTexture) {
557 return false;
558 }
559
560 SkAutoTUnref<const GrFragmentProcessor> fp;
561 fp.reset(GrColorSpaceEffect::Create(tempTexture,
562 srcColorSpace, dstColorSpace, colorSpace OpsFlags));
563
564 GrRenderTarget* renderTarget = surface->asRenderTarget();
565 SkASSERT(renderTarget);
566
567 SkMatrix matrix;
568 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
569 SkSurfaceProps props(SkSurfaceProps::kGammaCorrect_Flag,
570 SkSurfaceProps::kLegacyFontHost_InitType);
571 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(renderTarget, &pro ps));
572 if (!drawContext) {
573 return false;
574 }
575
576 GrPaint paint;
577 paint.addColorFragmentProcessor(fp);
578 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
579 paint.setGammaCorrect(true);
580
581 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
582 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullptr);
583
584 this->flushSurfaceWrites(surface);
585
586 return true;
587 }
588
531 void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) { 589 void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) {
532 ASSERT_SINGLE_OWNER 590 ASSERT_SINGLE_OWNER
533 RETURN_IF_ABANDONED 591 RETURN_IF_ABANDONED
534 SkASSERT(surface); 592 SkASSERT(surface);
535 ASSERT_OWNED_RESOURCE(surface); 593 ASSERT_OWNED_RESOURCE(surface);
536 if (surface->surfacePriv().hasPendingIO()) { 594 if (surface->surfacePriv().hasPendingIO()) {
537 this->flush(); 595 this->flush();
538 } 596 }
539 GrRenderTarget* rt = surface->asRenderTarget(); 597 GrRenderTarget* rt = surface->asRenderTarget();
540 if (fGpu && rt) { 598 if (fGpu && rt) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 ASSERT_SINGLE_OWNER 751 ASSERT_SINGLE_OWNER
694 fResourceCache->setLimits(maxTextures, maxTextureBytes); 752 fResourceCache->setLimits(maxTextures, maxTextureBytes);
695 } 753 }
696 754
697 ////////////////////////////////////////////////////////////////////////////// 755 //////////////////////////////////////////////////////////////////////////////
698 756
699 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { 757 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
700 ASSERT_SINGLE_OWNER 758 ASSERT_SINGLE_OWNER
701 fResourceCache->dumpMemoryStatistics(traceMemoryDump); 759 fResourceCache->dumpMemoryStatistics(traceMemoryDump);
702 } 760 }
OLDNEW
« samplecode/SampleApp.cpp ('K') | « samplecode/SampleApp.cpp ('k') | src/gpu/GrSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698