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 "effects/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (kRGB_565_SkColorType == ct) { | 164 if (kRGB_565_SkColorType == ct) { |
165 at = kOpaque_SkAlphaType; // force this setting | 165 at = kOpaque_SkAlphaType; // force this setting |
166 } else { | 166 } else { |
167 ct = kN32_SkColorType; | 167 ct = kN32_SkColorType; |
168 if (kOpaque_SkAlphaType != at) { | 168 if (kOpaque_SkAlphaType != at) { |
169 at = kPremul_SkAlphaType; // force this setting | 169 at = kPremul_SkAlphaType; // force this setting |
170 } | 170 } |
171 } | 171 } |
172 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height
(), ct, at); | 172 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height
(), ct, at); |
173 | 173 |
174 GrTextureDesc desc; | 174 GrSurfaceDesc desc; |
175 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 175 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
176 desc.fWidth = info.width(); | 176 desc.fWidth = info.width(); |
177 desc.fHeight = info.height(); | 177 desc.fHeight = info.height(); |
178 desc.fConfig = SkImageInfo2GrPixelConfig(info); | 178 desc.fConfig = SkImageInfo2GrPixelConfig(info); |
179 desc.fSampleCnt = sampleCount; | 179 desc.fSampleCnt = sampleCount; |
180 | 180 |
181 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0
)); | 181 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0
)); |
182 if (!texture.get()) { | 182 if (!texture.get()) { |
183 return NULL; | 183 return NULL; |
184 } | 184 } |
185 | 185 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 600 } |
601 // this will free-up dstM when we're done (allocated in filterMask()) | 601 // this will free-up dstM when we're done (allocated in filterMask()) |
602 SkAutoMaskFreeImage autoDst(dstM.fImage); | 602 SkAutoMaskFreeImage autoDst(dstM.fImage); |
603 | 603 |
604 if (clip.quickReject(dstM.fBounds)) { | 604 if (clip.quickReject(dstM.fBounds)) { |
605 return false; | 605 return false; |
606 } | 606 } |
607 | 607 |
608 // we now have a device-aligned 8bit mask in dstM, ready to be drawn using | 608 // we now have a device-aligned 8bit mask in dstM, ready to be drawn using |
609 // the current clip (and identity matrix) and GrPaint settings | 609 // the current clip (and identity matrix) and GrPaint settings |
610 GrTextureDesc desc; | 610 GrSurfaceDesc desc; |
611 desc.fWidth = dstM.fBounds.width(); | 611 desc.fWidth = dstM.fBounds.width(); |
612 desc.fHeight = dstM.fBounds.height(); | 612 desc.fHeight = dstM.fBounds.height(); |
613 desc.fConfig = kAlpha_8_GrPixelConfig; | 613 desc.fConfig = kAlpha_8_GrPixelConfig; |
614 | 614 |
615 SkAutoTUnref<GrTexture> texture( | 615 SkAutoTUnref<GrTexture> texture( |
616 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); | 616 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); |
617 if (!texture) { | 617 if (!texture) { |
618 return false; | 618 return false; |
619 } | 619 } |
620 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, | 620 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, |
621 dstM.fImage, dstM.fRowBytes); | 621 dstM.fImage, dstM.fRowBytes); |
622 | 622 |
623 SkRect maskRect = SkRect::Make(dstM.fBounds); | 623 SkRect maskRect = SkRect::Make(dstM.fBounds); |
624 | 624 |
625 return draw_mask(context, maskRect, grp, texture); | 625 return draw_mask(context, maskRect, grp, texture); |
626 } | 626 } |
627 | 627 |
628 // Create a mask of 'devPath' and place the result in 'mask'. | 628 // Create a mask of 'devPath' and place the result in 'mask'. |
629 GrTexture* create_mask_GPU(GrContext* context, | 629 GrTexture* create_mask_GPU(GrContext* context, |
630 const SkRect& maskRect, | 630 const SkRect& maskRect, |
631 const SkPath& devPath, | 631 const SkPath& devPath, |
632 const GrStrokeInfo& strokeInfo, | 632 const GrStrokeInfo& strokeInfo, |
633 bool doAA, | 633 bool doAA, |
634 int sampleCnt) { | 634 int sampleCnt) { |
635 GrTextureDesc desc; | 635 GrSurfaceDesc desc; |
636 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 636 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
637 desc.fWidth = SkScalarCeilToInt(maskRect.width()); | 637 desc.fWidth = SkScalarCeilToInt(maskRect.width()); |
638 desc.fHeight = SkScalarCeilToInt(maskRect.height()); | 638 desc.fHeight = SkScalarCeilToInt(maskRect.height()); |
639 desc.fSampleCnt = doAA ? sampleCnt : 0; | 639 desc.fSampleCnt = doAA ? sampleCnt : 0; |
640 // We actually only need A8, but it often isn't supported as a | 640 // We actually only need A8, but it often isn't supported as a |
641 // render target so default to RGBA_8888 | 641 // render target so default to RGBA_8888 |
642 desc.fConfig = kRGBA_8888_GrPixelConfig; | 642 desc.fConfig = kRGBA_8888_GrPixelConfig; |
643 | 643 |
644 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, | 644 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, |
645 desc.fSampleCnt > 0)) { | 645 desc.fSampleCnt > 0)) { |
646 desc.fConfig = kAlpha_8_GrPixelConfig; | 646 desc.fConfig = kAlpha_8_GrPixelConfig; |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 } | 1744 } |
1745 | 1745 |
1746 void SkGpuDevice::flush() { | 1746 void SkGpuDevice::flush() { |
1747 DO_DEFERRED_CLEAR(); | 1747 DO_DEFERRED_CLEAR(); |
1748 fContext->resolveRenderTarget(fRenderTarget); | 1748 fContext->resolveRenderTarget(fRenderTarget); |
1749 } | 1749 } |
1750 | 1750 |
1751 /////////////////////////////////////////////////////////////////////////////// | 1751 /////////////////////////////////////////////////////////////////////////////// |
1752 | 1752 |
1753 SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage)
{ | 1753 SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage)
{ |
1754 GrTextureDesc desc; | 1754 GrSurfaceDesc desc; |
1755 desc.fConfig = fRenderTarget->config(); | 1755 desc.fConfig = fRenderTarget->config(); |
1756 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 1756 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
1757 desc.fWidth = info.width(); | 1757 desc.fWidth = info.width(); |
1758 desc.fHeight = info.height(); | 1758 desc.fHeight = info.height(); |
1759 desc.fSampleCnt = fRenderTarget->numSamples(); | 1759 desc.fSampleCnt = fRenderTarget->numSamples(); |
1760 | 1760 |
1761 SkAutoTUnref<GrTexture> texture; | 1761 SkAutoTUnref<GrTexture> texture; |
1762 // Skia's convention is to only clear a device if it is non-opaque. | 1762 // Skia's convention is to only clear a device if it is non-opaque. |
1763 unsigned flags = info.isOpaque() ? 0 : kNeedClear_Flag; | 1763 unsigned flags = info.isOpaque() ? 0 : kNeedClear_Flag; |
1764 | 1764 |
1765 #if CACHE_COMPATIBLE_DEVICE_TEXTURES | 1765 #if CACHE_COMPATIBLE_DEVICE_TEXTURES |
1766 // layers are never draw in repeat modes, so we can request an approx | 1766 // layers are never draw in repeat modes, so we can request an approx |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 GrLayerHoister::UnlockLayers(fContext, atlasedRecycled); | 1848 GrLayerHoister::UnlockLayers(fContext, atlasedRecycled); |
1849 | 1849 |
1850 return true; | 1850 return true; |
1851 } | 1851 } |
1852 | 1852 |
1853 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1853 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1854 // We always return a transient cache, so it is freed after each | 1854 // We always return a transient cache, so it is freed after each |
1855 // filter traversal. | 1855 // filter traversal. |
1856 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1856 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1857 } | 1857 } |
OLD | NEW |