| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrBlurUtils.h" | 8 #include "GrBlurUtils.h" |
| 9 #include "GrDrawContext.h" | 9 #include "GrDrawContext.h" |
| 10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 return false; | 76 return false; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // we now have a device-aligned 8bit mask in dstM, ready to be drawn using | 79 // we now have a device-aligned 8bit mask in dstM, ready to be drawn using |
| 80 // the current clip (and identity matrix) and GrPaint settings | 80 // the current clip (and identity matrix) and GrPaint settings |
| 81 GrSurfaceDesc desc; | 81 GrSurfaceDesc desc; |
| 82 desc.fWidth = dstM.fBounds.width(); | 82 desc.fWidth = dstM.fBounds.width(); |
| 83 desc.fHeight = dstM.fBounds.height(); | 83 desc.fHeight = dstM.fBounds.height(); |
| 84 desc.fConfig = kAlpha_8_GrPixelConfig; | 84 desc.fConfig = kAlpha_8_GrPixelConfig; |
| 85 | 85 |
| 86 SkAutoTUnref<GrTexture> texture(textureProvider->refScratchTexture( | 86 SkAutoTUnref<GrTexture> texture(textureProvider->createApproxTexture(desc)); |
| 87 desc, GrTextureProvider::kApprox_ScratchTexMatch)); | |
| 88 if (!texture) { | 87 if (!texture) { |
| 89 return false; | 88 return false; |
| 90 } | 89 } |
| 91 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, | 90 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, |
| 92 dstM.fImage, dstM.fRowBytes); | 91 dstM.fImage, dstM.fRowBytes); |
| 93 | 92 |
| 94 SkRect maskRect = SkRect::Make(dstM.fBounds); | 93 SkRect maskRect = SkRect::Make(dstM.fBounds); |
| 95 | 94 |
| 96 return draw_mask(drawContext, rt, clipData, viewMatrix, maskRect, grp, textu
re); | 95 return draw_mask(drawContext, rt, clipData, viewMatrix, maskRect, grp, textu
re); |
| 97 } | 96 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 109 desc.fHeight = SkScalarCeilToInt(maskRect.height()); | 108 desc.fHeight = SkScalarCeilToInt(maskRect.height()); |
| 110 desc.fSampleCnt = doAA ? sampleCnt : 0; | 109 desc.fSampleCnt = doAA ? sampleCnt : 0; |
| 111 // We actually only need A8, but it often isn't supported as a | 110 // We actually only need A8, but it often isn't supported as a |
| 112 // render target so default to RGBA_8888 | 111 // render target so default to RGBA_8888 |
| 113 desc.fConfig = kRGBA_8888_GrPixelConfig; | 112 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 114 | 113 |
| 115 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, desc.fSample
Cnt > 0)) { | 114 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, desc.fSample
Cnt > 0)) { |
| 116 desc.fConfig = kAlpha_8_GrPixelConfig; | 115 desc.fConfig = kAlpha_8_GrPixelConfig; |
| 117 } | 116 } |
| 118 | 117 |
| 119 GrTexture* mask = context->textureProvider()->refScratchTexture( | 118 GrTexture* mask = context->textureProvider()->createApproxTexture(desc); |
| 120 desc, GrTextureProvider::kApprox_ScratchTexMatch); | |
| 121 if (NULL == mask) { | 119 if (NULL == mask) { |
| 122 return NULL; | 120 return NULL; |
| 123 } | 121 } |
| 124 | 122 |
| 125 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); | 123 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); |
| 126 | 124 |
| 127 GrDrawContext* drawContext = context->drawContext(); | 125 GrDrawContext* drawContext = context->drawContext(); |
| 128 if (!drawContext) { | 126 if (!drawContext) { |
| 129 return NULL; | 127 return NULL; |
| 130 } | 128 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 SkPaint::kFill_Sty
le; | 286 SkPaint::kFill_Sty
le; |
| 289 draw_with_mask_filter(drawContext, context->textureProvider(), renderTar
get, | 287 draw_with_mask_filter(drawContext, context->textureProvider(), renderTar
get, |
| 290 clip, viewMatrix, *devPathPtr, | 288 clip, viewMatrix, *devPathPtr, |
| 291 paint.getMaskFilter(), clipBounds, &grPaint, style
); | 289 paint.getMaskFilter(), clipBounds, &grPaint, style
); |
| 292 return; | 290 return; |
| 293 } | 291 } |
| 294 | 292 |
| 295 drawContext->drawPath(renderTarget, clip, grPaint, viewMatrix, *pathPtr, str
okeInfo); | 293 drawContext->drawPath(renderTarget, clip, grPaint, viewMatrix, *pathPtr, str
okeInfo); |
| 296 } | 294 } |
| 297 | 295 |
| OLD | NEW |