| OLD | NEW |
| 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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
| 9 | 9 |
| 10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 return nullptr; | 184 return nullptr; |
| 185 } | 185 } |
| 186 | 186 |
| 187 if (!context) { | 187 if (!context) { |
| 188 return nullptr; | 188 return nullptr; |
| 189 } | 189 } |
| 190 | 190 |
| 191 SkColorType ct = origInfo.colorType(); | 191 SkColorType ct = origInfo.colorType(); |
| 192 SkAlphaType at = origInfo.alphaType(); | 192 SkAlphaType at = origInfo.alphaType(); |
| 193 SkColorProfileType pt = origInfo.profileType(); | 193 SkColorProfileType pt = origInfo.profileType(); |
| 194 if (kRGB_565_SkColorType == ct) { | 194 if (kRGB_565_SkColorType == ct || kGray_8_SkColorType == ct) { |
| 195 at = kOpaque_SkAlphaType; // force this setting | 195 at = kOpaque_SkAlphaType; // force this setting |
| 196 } else if (ct != kBGRA_8888_SkColorType && ct != kRGBA_8888_SkColorType) { | |
| 197 // Fall back from whatever ct was to default of kRGBA or kBGRA which is
aliased as kN32 | |
| 198 ct = kN32_SkColorType; | |
| 199 } | 196 } |
| 200 if (kOpaque_SkAlphaType != at) { | 197 if (kOpaque_SkAlphaType != at) { |
| 201 at = kPremul_SkAlphaType; // force this setting | 198 at = kPremul_SkAlphaType; // force this setting |
| 202 } | 199 } |
| 200 |
| 201 GrPixelConfig origConfig = SkImageInfo2GrPixelConfig(ct, at, pt, *context->c
aps()); |
| 202 if (!context->caps()->isConfigRenderable(origConfig, sampleCount > 0)) { |
| 203 // Fall back from whatever ct was to default of kRGBA or kBGRA which is
aliased as kN32 |
| 204 ct = kN32_SkColorType; |
| 205 } |
| 206 |
| 203 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height
(), ct, at, pt); | 207 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height
(), ct, at, pt); |
| 204 | 208 |
| 205 GrSurfaceDesc desc; | 209 GrSurfaceDesc desc; |
| 206 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 210 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 207 desc.fWidth = info.width(); | 211 desc.fWidth = info.width(); |
| 208 desc.fHeight = info.height(); | 212 desc.fHeight = info.height(); |
| 209 desc.fConfig = SkImageInfo2GrPixelConfig(info, *context->caps()); | 213 desc.fConfig = SkImageInfo2GrPixelConfig(info, *context->caps()); |
| 210 desc.fSampleCnt = sampleCount; | 214 desc.fSampleCnt = sampleCount; |
| 211 desc.fIsMipMapped = false; | 215 desc.fIsMipMapped = false; |
| 212 GrTexture* texture = context->textureProvider()->createTexture(desc, budgete
d, nullptr, 0); | 216 GrTexture* texture = context->textureProvider()->createTexture(desc, budgete
d, nullptr, 0); |
| (...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1937 } | 1941 } |
| 1938 | 1942 |
| 1939 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1943 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
| 1940 ASSERT_SINGLE_OWNER | 1944 ASSERT_SINGLE_OWNER |
| 1941 // We always return a transient cache, so it is freed after each | 1945 // We always return a transient cache, so it is freed after each |
| 1942 // filter traversal. | 1946 // filter traversal. |
| 1943 return SkGpuDevice::NewImageFilterCache(); | 1947 return SkGpuDevice::NewImageFilterCache(); |
| 1944 } | 1948 } |
| 1945 | 1949 |
| 1946 #endif | 1950 #endif |
| OLD | NEW |