| 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 "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 } | 682 } |
| 683 | 683 |
| 684 // we now have a device-aligned 8bit mask in dstM, ready to be drawn using | 684 // we now have a device-aligned 8bit mask in dstM, ready to be drawn using |
| 685 // the current clip (and identity matrix) and GrPaint settings | 685 // the current clip (and identity matrix) and GrPaint settings |
| 686 GrSurfaceDesc desc; | 686 GrSurfaceDesc desc; |
| 687 desc.fWidth = dstM.fBounds.width(); | 687 desc.fWidth = dstM.fBounds.width(); |
| 688 desc.fHeight = dstM.fBounds.height(); | 688 desc.fHeight = dstM.fBounds.height(); |
| 689 desc.fConfig = kAlpha_8_GrPixelConfig; | 689 desc.fConfig = kAlpha_8_GrPixelConfig; |
| 690 | 690 |
| 691 SkAutoTUnref<GrTexture> texture(context->textureProvider()->refScratchTextur
e( | 691 SkAutoTUnref<GrTexture> texture(context->textureProvider()->refScratchTextur
e( |
| 692 desc, GrTextureProvider::kApprox_ScratchTexMatch)); | 692 desc, GrTextureProvider::kApprox_ScratchMatch)); |
| 693 if (!texture) { | 693 if (!texture) { |
| 694 return false; | 694 return false; |
| 695 } | 695 } |
| 696 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, | 696 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, |
| 697 dstM.fImage, dstM.fRowBytes); | 697 dstM.fImage, dstM.fRowBytes); |
| 698 | 698 |
| 699 SkRect maskRect = SkRect::Make(dstM.fBounds); | 699 SkRect maskRect = SkRect::Make(dstM.fBounds); |
| 700 | 700 |
| 701 return draw_mask(context, rt, clipData, viewMatrix, maskRect, grp, texture); | 701 return draw_mask(context, rt, clipData, viewMatrix, maskRect, grp, texture); |
| 702 } | 702 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 717 // We actually only need A8, but it often isn't supported as a | 717 // We actually only need A8, but it often isn't supported as a |
| 718 // render target so default to RGBA_8888 | 718 // render target so default to RGBA_8888 |
| 719 desc.fConfig = kRGBA_8888_GrPixelConfig; | 719 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 720 | 720 |
| 721 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, | 721 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, |
| 722 desc.fSampleCnt > 0)) { | 722 desc.fSampleCnt > 0)) { |
| 723 desc.fConfig = kAlpha_8_GrPixelConfig; | 723 desc.fConfig = kAlpha_8_GrPixelConfig; |
| 724 } | 724 } |
| 725 | 725 |
| 726 GrTexture* mask = context->textureProvider()->refScratchTexture( | 726 GrTexture* mask = context->textureProvider()->refScratchTexture( |
| 727 desc, GrTextureProvider::kApprox_ScratchTexMatch); | 727 desc, GrTextureProvider::kApprox_ScratchMatch); |
| 728 if (NULL == mask) { | 728 if (NULL == mask) { |
| 729 return NULL; | 729 return NULL; |
| 730 } | 730 } |
| 731 | 731 |
| 732 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); | 732 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); |
| 733 | 733 |
| 734 context->clear(NULL, 0x0, true, mask->asRenderTarget()); | 734 context->clear(NULL, 0x0, true, mask->asRenderTarget()); |
| 735 | 735 |
| 736 GrPaint tempPaint; | 736 GrPaint tempPaint; |
| 737 tempPaint.setAntiAlias(doAA); | 737 tempPaint.setAntiAlias(doAA); |
| (...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 desc.fWidth = cinfo.fInfo.width(); | 1960 desc.fWidth = cinfo.fInfo.width(); |
| 1961 desc.fHeight = cinfo.fInfo.height(); | 1961 desc.fHeight = cinfo.fInfo.height(); |
| 1962 desc.fSampleCnt = fRenderTarget->numSamples(); | 1962 desc.fSampleCnt = fRenderTarget->numSamples(); |
| 1963 | 1963 |
| 1964 SkAutoTUnref<GrTexture> texture; | 1964 SkAutoTUnref<GrTexture> texture; |
| 1965 // Skia's convention is to only clear a device if it is non-opaque. | 1965 // Skia's convention is to only clear a device if it is non-opaque. |
| 1966 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag; | 1966 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag; |
| 1967 | 1967 |
| 1968 // layers are never draw in repeat modes, so we can request an approx | 1968 // layers are never draw in repeat modes, so we can request an approx |
| 1969 // match and ignore any padding. | 1969 // match and ignore any padding. |
| 1970 const GrTextureProvider::ScratchTexMatch match = (kNever_TileUsage == cinfo.
fTileUsage) ? | 1970 const GrTextureProvider::ScratchMatch match = (kNever_TileUsage == cinfo.fTi
leUsage) ? |
| 1971 GrTextureProvider::kApprox_Scr
atchTexMatch : | 1971 GrTextureProvider::kApprox_Scr
atchMatch : |
| 1972 GrTextureProvider::kExact_Scra
tchTexMatch; | 1972 GrTextureProvider::kExact_Scra
tchMatch; |
| 1973 texture.reset(fContext->textureProvider()->refScratchTexture(desc, match)); | 1973 texture.reset(fContext->textureProvider()->refScratchTexture(desc, match)); |
| 1974 | 1974 |
| 1975 if (texture) { | 1975 if (texture) { |
| 1976 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry); | 1976 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry); |
| 1977 return SkGpuDevice::Create( | 1977 return SkGpuDevice::Create( |
| 1978 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height()
, &props, flags); | 1978 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height()
, &props, flags); |
| 1979 } else { | 1979 } else { |
| 1980 SkErrorInternals::SetError( kInternalError_SkError, | 1980 SkErrorInternals::SetError( kInternalError_SkError, |
| 1981 "---- failed to create gpu device texture [%
d %d]\n", | 1981 "---- failed to create gpu device texture [%
d %d]\n", |
| 1982 cinfo.fInfo.width(), cinfo.fInfo.height()); | 1982 cinfo.fInfo.width(), cinfo.fInfo.height()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2057 #endif | 2057 #endif |
| 2058 } | 2058 } |
| 2059 | 2059 |
| 2060 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 2060 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
| 2061 // We always return a transient cache, so it is freed after each | 2061 // We always return a transient cache, so it is freed after each |
| 2062 // filter traversal. | 2062 // filter traversal. |
| 2063 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 2063 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
| 2064 } | 2064 } |
| 2065 | 2065 |
| 2066 #endif | 2066 #endif |
| OLD | NEW |