Chromium Code Reviews| 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 "GrPipelineBuilder.h" | 10 #include "GrPipelineBuilder.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 int cmpSz = SkTextureCompressor::GetCompressedDataSize( | 195 int cmpSz = SkTextureCompressor::GetCompressedDataSize( |
| 196 fCompressedFormat, cmpWidth, cmpHeight); | 196 fCompressedFormat, cmpWidth, cmpHeight); |
| 197 | 197 |
| 198 SkASSERT(cmpSz > 0); | 198 SkASSERT(cmpSz > 0); |
| 199 SkASSERT(NULL == fCompressedBuffer.get()); | 199 SkASSERT(NULL == fCompressedBuffer.get()); |
| 200 fCompressedBuffer.reset(cmpSz); | 200 fCompressedBuffer.reset(cmpSz); |
| 201 fCompressionMode = kBlitter_CompressionMode; | 201 fCompressionMode = kBlitter_CompressionMode; |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 sk_bzero(&fDraw, sizeof(fDraw)); | |
| 206 | |
| 205 // If we don't have a custom blitter, then we either need a bitmap to compre ss | 207 // If we don't have a custom blitter, then we either need a bitmap to compre ss |
| 206 // from or a bitmap that we're going to use as a texture. In any case, we sh ould | 208 // from or a bitmap that we're going to use as a texture. In any case, we sh ould |
| 207 // allocate the pixels for a bitmap | 209 // allocate the pixels for a bitmap |
| 208 const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(cmpWidth, cmpHeight); | 210 const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(cmpWidth, cmpHeight); |
| 209 if (kBlitter_CompressionMode != fCompressionMode) { | 211 if (kBlitter_CompressionMode != fCompressionMode) { |
| 210 if (!fBM.tryAllocPixels(bmImageInfo)) { | 212 if (!fBM.tryAllocPixels(bmImageInfo)) { |
| 211 return false; | 213 return false; |
| 212 } | 214 } |
| 213 | |
| 214 sk_bzero(fBM.getPixels(), fBM.getSafeSize()); | 215 sk_bzero(fBM.getPixels(), fBM.getSafeSize()); |
|
jvanverth1
2015/06/08 13:21:10
Add a comment explaining why we're peeking at the
reed1
2015/06/08 17:00:22
removed fBM
| |
| 216 if (!fBM.peekPixels(&fDraw.fDst)) { | |
| 217 return false; | |
| 218 } | |
| 215 } else { | 219 } else { |
| 216 // Otherwise, we just need to remember how big the buffer is... | 220 // Otherwise, we just need to remember how big the buffer is... |
| 217 fBM.setInfo(bmImageInfo); | 221 fBM.setInfo(bmImageInfo); |
| 222 fDraw.fDst.reset(bmImageInfo); | |
| 218 } | 223 } |
| 219 | |
| 220 sk_bzero(&fDraw, sizeof(fDraw)); | |
| 221 | |
| 222 fRasterClip.setRect(bounds); | 224 fRasterClip.setRect(bounds); |
| 223 fDraw.fRC = &fRasterClip; | 225 fDraw.fRC = &fRasterClip; |
| 224 fDraw.fClip = &fRasterClip.bwRgn(); | 226 fDraw.fClip = &fRasterClip.bwRgn(); |
| 225 fDraw.fMatrix = &fMatrix; | 227 fDraw.fMatrix = &fMatrix; |
| 226 fDraw.fBitmap = &fBM; | |
| 227 return true; | 228 return true; |
| 228 } | 229 } |
| 229 | 230 |
| 230 /** | 231 /** |
| 231 * Get a texture (from the texture cache) of the correct size & format. | 232 * Get a texture (from the texture cache) of the correct size & format. |
| 232 */ | 233 */ |
| 233 GrTexture* GrSWMaskHelper::createTexture() { | 234 GrTexture* GrSWMaskHelper::createTexture() { |
| 234 GrSurfaceDesc desc; | 235 GrSurfaceDesc desc; |
| 235 desc.fWidth = fBM.width(); | 236 desc.fWidth = fBM.width(); |
| 236 desc.fHeight = fBM.height(); | 237 desc.fHeight = fBM.height(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop )); | 373 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop )); |
| 373 | 374 |
| 374 pipelineBuilder->addCoverageProcessor( | 375 pipelineBuilder->addCoverageProcessor( |
| 375 GrSimpleTextureEffect::Create(texture, | 376 GrSimpleTextureEffect::Create(texture, |
| 376 maskMatrix, | 377 maskMatrix, |
| 377 GrTextureParams::kNone_Fi lterMode, | 378 GrTextureParams::kNone_Fi lterMode, |
| 378 kDevice_GrCoordSet))->unr ef(); | 379 kDevice_GrCoordSet))->unr ef(); |
| 379 | 380 |
| 380 target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), dstRect, NULL, &in vert); | 381 target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), dstRect, NULL, &in vert); |
| 381 } | 382 } |
| OLD | NEW |