| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrSWMaskHelper.h" | 8 #include "GrSWMaskHelper.h" |
| 9 | 9 |
| 10 #include "GrDrawState.h" | 10 #include "GrDrawState.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Draw a single rect element of the clip stack into the accumulation bitmap | 101 * Draw a single rect element of the clip stack into the accumulation bitmap |
| 102 */ | 102 */ |
| 103 void GrSWMaskHelper::draw(const SkRect& rect, SkRegion::Op op, | 103 void GrSWMaskHelper::draw(const SkRect& rect, SkRegion::Op op, |
| 104 bool antiAlias, uint8_t alpha) { | 104 bool antiAlias, uint8_t alpha) { |
| 105 SkPaint paint; | 105 SkPaint paint; |
| 106 | 106 |
| 107 SkXfermode* mode = SkXfermode::Create(op_to_mode(op)); | 107 SkXfermode* mode = SkXfermode::Create(op_to_mode(op)); |
| 108 | 108 |
| 109 SkASSERT(kNone_CompressionMode == fCompressionMode); |
| 110 |
| 109 paint.setXfermode(mode); | 111 paint.setXfermode(mode); |
| 110 paint.setAntiAlias(antiAlias); | 112 paint.setAntiAlias(antiAlias); |
| 111 paint.setColor(SkColorSetARGB(alpha, alpha, alpha, alpha)); | 113 paint.setColor(SkColorSetARGB(alpha, alpha, alpha, alpha)); |
| 112 | 114 |
| 113 fDraw.drawRect(rect, paint); | 115 fDraw.drawRect(rect, paint); |
| 114 | 116 |
| 115 SkSafeUnref(mode); | 117 SkSafeUnref(mode); |
| 116 } | 118 } |
| 117 | 119 |
| 118 /** | 120 /** |
| (...skipping 30 matching lines...) Expand all Loading... |
| 149 SkASSERT(0xFF == paint.getAlpha()); | 151 SkASSERT(0xFF == paint.getAlpha()); |
| 150 fDraw.drawPathCoverage(path, paint, blitter); | 152 fDraw.drawPathCoverage(path, paint, blitter); |
| 151 } else { | 153 } else { |
| 152 paint.setXfermodeMode(op_to_mode(op)); | 154 paint.setXfermodeMode(op_to_mode(op)); |
| 153 paint.setColor(SkColorSetARGB(alpha, alpha, alpha, alpha)); | 155 paint.setColor(SkColorSetARGB(alpha, alpha, alpha, alpha)); |
| 154 fDraw.drawPath(path, paint, blitter); | 156 fDraw.drawPath(path, paint, blitter); |
| 155 } | 157 } |
| 156 } | 158 } |
| 157 | 159 |
| 158 bool GrSWMaskHelper::init(const SkIRect& resultBounds, | 160 bool GrSWMaskHelper::init(const SkIRect& resultBounds, |
| 159 const SkMatrix* matrix) { | 161 const SkMatrix* matrix, |
| 162 bool allowCompression) { |
| 160 if (NULL != matrix) { | 163 if (NULL != matrix) { |
| 161 fMatrix = *matrix; | 164 fMatrix = *matrix; |
| 162 } else { | 165 } else { |
| 163 fMatrix.setIdentity(); | 166 fMatrix.setIdentity(); |
| 164 } | 167 } |
| 165 | 168 |
| 166 // Now translate so the bound's UL corner is at the origin | 169 // Now translate so the bound's UL corner is at the origin |
| 167 fMatrix.postTranslate(-resultBounds.fLeft * SK_Scalar1, | 170 fMatrix.postTranslate(-resultBounds.fLeft * SK_Scalar1, |
| 168 -resultBounds.fTop * SK_Scalar1); | 171 -resultBounds.fTop * SK_Scalar1); |
| 169 SkIRect bounds = SkIRect::MakeWH(resultBounds.width(), | 172 SkIRect bounds = SkIRect::MakeWH(resultBounds.width(), |
| 170 resultBounds.height()); | 173 resultBounds.height()); |
| 171 | 174 |
| 172 if (fContext->getOptions().fDrawPathToCompressedTexture && | 175 if (allowCompression && |
| 176 fContext->getOptions().fDrawPathToCompressedTexture && |
| 173 choose_compressed_fmt(fContext->getGpu()->caps(), &fCompressedFormat)) { | 177 choose_compressed_fmt(fContext->getGpu()->caps(), &fCompressedFormat)) { |
| 174 fCompressionMode = kCompress_CompressionMode; | 178 fCompressionMode = kCompress_CompressionMode; |
| 175 } | 179 } |
| 176 | 180 |
| 177 // Make sure that the width is a multiple of the desired block dimensions | 181 // Make sure that the width is a multiple of the desired block dimensions |
| 178 // to allow for specialized SIMD instructions that compress multiple blocks
at a time. | 182 // to allow for specialized SIMD instructions that compress multiple blocks
at a time. |
| 179 int cmpWidth = bounds.fRight; | 183 int cmpWidth = bounds.fRight; |
| 180 int cmpHeight = bounds.fBottom; | 184 int cmpHeight = bounds.fBottom; |
| 181 if (kCompress_CompressionMode == fCompressionMode) { | 185 if (kCompress_CompressionMode == fCompressionMode) { |
| 182 int dimX, dimY; | 186 int dimX, dimY; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 maskMatrix.preConcat(drawState->getViewMatrix()); | 362 maskMatrix.preConcat(drawState->getViewMatrix()); |
| 359 | 363 |
| 360 drawState->addCoverageEffect( | 364 drawState->addCoverageEffect( |
| 361 GrSimpleTextureEffect::Create(texture, | 365 GrSimpleTextureEffect::Create(texture, |
| 362 maskMatrix, | 366 maskMatrix, |
| 363 GrTextureParams::kNone_Fi
lterMode, | 367 GrTextureParams::kNone_Fi
lterMode, |
| 364 kPosition_GrCoordSet))->u
nref(); | 368 kPosition_GrCoordSet))->u
nref(); |
| 365 | 369 |
| 366 target->drawSimpleRect(dstRect); | 370 target->drawSimpleRect(dstRect); |
| 367 } | 371 } |
| OLD | NEW |