From 74f681dce2fbadd481596aea15afb3e0fb36ceff Mon Sep 17 00:00:00 2001 From: bsalomon Date: Tue, 23 Jun 2015 14:38:48 -0700 Subject: Make SkGpuDevice know its alpha type Make SkImage_Gpu snapshots opaque if surface is opaque. BUG=skia:3965 Review URL: https://codereview.chromium.org/1205643002 --- src/image/SkImage_Gpu.cpp | 2 +- src/image/SkSurface_Gpu.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/image') diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 973f4ba304..4003631c8a 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -61,7 +61,7 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { } bool SkImage_Gpu::isOpaque() const { - return GrPixelConfigIsOpaque(fTexture->config()); + return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_SkAlphaType; } static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) { diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index cbc183eacf..fa006a61cd 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -83,7 +83,8 @@ void SkSurface_Gpu::onDiscard() { /////////////////////////////////////////////////////////////////////////////// SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurfaceProps* props) { - SkAutoTUnref device(SkGpuDevice::Create(target, props)); + SkAutoTUnref device( + SkGpuDevice::Create(target, props, SkGpuDevice::kUninit_InitContents)); if (!device) { return NULL; } @@ -93,7 +94,7 @@ SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurf SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, Budgeted budgeted, const SkImageInfo& info, int sampleCount, const SkSurfaceProps* props) { SkAutoTUnref device(SkGpuDevice::Create(ctx, budgeted, info, sampleCount, props, - SkGpuDevice::kNeedClear_Flag)); + SkGpuDevice::kClear_InitContents)); if (!device) { return NULL; } @@ -113,7 +114,8 @@ SkSurface* SkSurface::NewWrappedRenderTarget(GrContext* context, GrBackendTextur if (!surface) { return NULL; } - SkAutoTUnref device(SkGpuDevice::Create(surface->asRenderTarget(), props)); + SkAutoTUnref device(SkGpuDevice::Create(surface->asRenderTarget(), props, + SkGpuDevice::kUninit_InitContents)); if (!device) { return NULL; } -- cgit v1.2.3