Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Side by Side Diff: src/gpu/GrSWMaskHelper.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrResourceProvider.cpp ('k') | src/gpu/GrSoftwarePathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // Best guess 63 // Best guess
64 config = kAlpha_8_GrPixelConfig; 64 config = kAlpha_8_GrPixelConfig;
65 break; 65 break;
66 } 66 }
67 67
68 return config; 68 return config;
69 } 69 }
70 70
71 static bool choose_compressed_fmt(const GrCaps* caps, 71 static bool choose_compressed_fmt(const GrCaps* caps,
72 SkTextureCompressor::Format *fmt) { 72 SkTextureCompressor::Format *fmt) {
73 if (NULL == fmt) { 73 if (nullptr == fmt) {
74 return false; 74 return false;
75 } 75 }
76 76
77 // We can't use scratch textures without the ability to update 77 // We can't use scratch textures without the ability to update
78 // compressed textures... 78 // compressed textures...
79 if (!(caps->compressedTexSubImageSupport())) { 79 if (!(caps->compressedTexSubImageSupport())) {
80 return false; 80 return false;
81 } 81 }
82 82
83 // Figure out what our preferred texture type is. If ASTC is available, that always 83 // Figure out what our preferred texture type is. If ASTC is available, that always
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } else { 135 } else {
136 paint.setStyle(SkPaint::kStroke_Style); 136 paint.setStyle(SkPaint::kStroke_Style);
137 paint.setStrokeJoin(stroke.getJoin()); 137 paint.setStrokeJoin(stroke.getJoin());
138 paint.setStrokeCap(stroke.getCap()); 138 paint.setStrokeCap(stroke.getCap());
139 paint.setStrokeWidth(stroke.getWidth()); 139 paint.setStrokeWidth(stroke.getWidth());
140 } 140 }
141 } 141 }
142 paint.setAntiAlias(antiAlias); 142 paint.setAntiAlias(antiAlias);
143 143
144 SkTBlitterAllocator allocator; 144 SkTBlitterAllocator allocator;
145 SkBlitter* blitter = NULL; 145 SkBlitter* blitter = nullptr;
146 if (kBlitter_CompressionMode == fCompressionMode) { 146 if (kBlitter_CompressionMode == fCompressionMode) {
147 SkASSERT(fCompressedBuffer.get()); 147 SkASSERT(fCompressedBuffer.get());
148 blitter = SkTextureCompressor::CreateBlitterForFormat( 148 blitter = SkTextureCompressor::CreateBlitterForFormat(
149 fPixels.width(), fPixels.height(), fCompressedBuffer.get(), &allocat or, 149 fPixels.width(), fPixels.height(), fCompressedBuffer.get(), &allocat or,
150 fCompressedFormat) ; 150 fCompressedFormat) ;
151 } 151 }
152 152
153 if (SkRegion::kReplace_Op == op && 0xFF == alpha) { 153 if (SkRegion::kReplace_Op == op && 0xFF == alpha) {
154 SkASSERT(0xFF == paint.getAlpha()); 154 SkASSERT(0xFF == paint.getAlpha());
155 fDraw.drawPathCoverage(path, paint, blitter); 155 fDraw.drawPathCoverage(path, paint, blitter);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ; 190 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ;
191 cmpWidth = dimX * ((cmpWidth + (dimX - 1)) / dimX); 191 cmpWidth = dimX * ((cmpWidth + (dimX - 1)) / dimX);
192 cmpHeight = dimY * ((cmpHeight + (dimY - 1)) / dimY); 192 cmpHeight = dimY * ((cmpHeight + (dimY - 1)) / dimY);
193 193
194 // Can we create a blitter? 194 // Can we create a blitter?
195 if (SkTextureCompressor::ExistsBlitterForFormat(fCompressedFormat)) { 195 if (SkTextureCompressor::ExistsBlitterForFormat(fCompressedFormat)) {
196 int cmpSz = SkTextureCompressor::GetCompressedDataSize( 196 int cmpSz = SkTextureCompressor::GetCompressedDataSize(
197 fCompressedFormat, cmpWidth, cmpHeight); 197 fCompressedFormat, cmpWidth, cmpHeight);
198 198
199 SkASSERT(cmpSz > 0); 199 SkASSERT(cmpSz > 0);
200 SkASSERT(NULL == fCompressedBuffer.get()); 200 SkASSERT(nullptr == fCompressedBuffer.get());
201 fCompressedBuffer.reset(cmpSz); 201 fCompressedBuffer.reset(cmpSz);
202 fCompressionMode = kBlitter_CompressionMode; 202 fCompressionMode = kBlitter_CompressionMode;
203 } 203 }
204 } 204 }
205 205
206 sk_bzero(&fDraw, sizeof(fDraw)); 206 sk_bzero(&fDraw, sizeof(fDraw));
207 207
208 // If we don't have a custom blitter, then we either need a bitmap to compre ss 208 // If we don't have a custom blitter, then we either need a bitmap to compre ss
209 // from or a bitmap that we're going to use as a texture. In any case, we sh ould 209 // from or a bitmap that we're going to use as a texture. In any case, we sh ould
210 // allocate the pixels for a bitmap 210 // allocate the pixels for a bitmap
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 252 }
253 253
254 void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrSurfaceDesc& de sc, 254 void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrSurfaceDesc& de sc,
255 const void *data, size_t rowbytes) { 255 const void *data, size_t rowbytes) {
256 // If we aren't reusing scratch textures we don't need to flush before 256 // If we aren't reusing scratch textures we don't need to flush before
257 // writing since no one else will be using 'texture' 257 // writing since no one else will be using 'texture'
258 bool reuseScratch = fContext->caps()->reuseScratchTextures(); 258 bool reuseScratch = fContext->caps()->reuseScratchTextures();
259 259
260 // Since we're uploading to it, and it's compressed, 'texture' shouldn't 260 // Since we're uploading to it, and it's compressed, 'texture' shouldn't
261 // have a render target. 261 // have a render target.
262 SkASSERT(NULL == texture->asRenderTarget()); 262 SkASSERT(nullptr == texture->asRenderTarget());
263 263
264 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, 264 texture->writePixels(0, 0, desc.fWidth, desc.fHeight,
265 desc.fConfig, data, rowbytes, 265 desc.fConfig, data, rowbytes,
266 reuseScratch ? 0 : GrContext::kDontFlush_PixelOpsFlag); 266 reuseScratch ? 0 : GrContext::kDontFlush_PixelOpsFlag);
267 } 267 }
268 268
269 void GrSWMaskHelper::compressTextureData(GrTexture *texture, const GrSurfaceDesc & desc) { 269 void GrSWMaskHelper::compressTextureData(GrTexture *texture, const GrSurfaceDesc & desc) {
270 270
271 SkASSERT(GrPixelConfigIsCompressed(desc.fConfig)); 271 SkASSERT(GrPixelConfigIsCompressed(desc.fConfig));
272 SkASSERT(fmt_to_config(fCompressedFormat) == desc.fConfig); 272 SkASSERT(fmt_to_config(fCompressedFormat) == desc.fConfig);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 */ 309 */
310 void GrSWMaskHelper::toSDF(unsigned char* sdf) { 310 void GrSWMaskHelper::toSDF(unsigned char* sdf) {
311 SkGenerateDistanceFieldFromA8Image(sdf, (const unsigned char*)fPixels.addr() , 311 SkGenerateDistanceFieldFromA8Image(sdf, (const unsigned char*)fPixels.addr() ,
312 fPixels.width(), fPixels.height(), fPixel s.rowBytes()); 312 fPixels.width(), fPixels.height(), fPixel s.rowBytes());
313 } 313 }
314 314
315 //////////////////////////////////////////////////////////////////////////////// 315 ////////////////////////////////////////////////////////////////////////////////
316 /** 316 /**
317 * Software rasterizes path to A8 mask (possibly using the context's matrix) 317 * Software rasterizes path to A8 mask (possibly using the context's matrix)
318 * and uploads the result to a scratch texture. Returns the resulting 318 * and uploads the result to a scratch texture. Returns the resulting
319 * texture on success; NULL on failure. 319 * texture on success; nullptr on failure.
320 */ 320 */
321 GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context, 321 GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context,
322 const SkPath& path, 322 const SkPath& path,
323 const SkStrokeRec& stroke, 323 const SkStrokeRec& stroke,
324 const SkIRect& resultBounds, 324 const SkIRect& resultBounds,
325 bool antiAlias, 325 bool antiAlias,
326 const SkMatrix* matrix) { 326 const SkMatrix* matrix) {
327 GrSWMaskHelper helper(context); 327 GrSWMaskHelper helper(context);
328 328
329 if (!helper.init(resultBounds, matrix)) { 329 if (!helper.init(resultBounds, matrix)) {
330 return NULL; 330 return nullptr;
331 } 331 }
332 332
333 helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF); 333 helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF);
334 334
335 GrTexture* texture(helper.createTexture()); 335 GrTexture* texture(helper.createTexture());
336 if (!texture) { 336 if (!texture) {
337 return NULL; 337 return nullptr;
338 } 338 }
339 339
340 helper.toTexture(texture); 340 helper.toTexture(texture);
341 341
342 return texture; 342 return texture;
343 } 343 }
344 344
345 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, 345 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
346 GrDrawTarget* target, 346 GrDrawTarget* target,
347 GrPipelineBuilder* pipelineBuilder , 347 GrPipelineBuilder* pipelineBuilder ,
(...skipping 20 matching lines...) Expand all
368 368
369 pipelineBuilder->addCoverageFragmentProcessor( 369 pipelineBuilder->addCoverageFragmentProcessor(
370 GrSimpleTextureEffect::Create(pipelineBuilder->getProce ssorDataManager(), 370 GrSimpleTextureEffect::Create(pipelineBuilder->getProce ssorDataManager(),
371 texture, 371 texture,
372 maskMatrix, 372 maskMatrix,
373 GrTextureParams::kNone_Fi lterMode, 373 GrTextureParams::kNone_Fi lterMode,
374 kDevice_GrCoordSet))->unr ef(); 374 kDevice_GrCoordSet))->unr ef();
375 375
376 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), dstRect, inver t); 376 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), dstRect, inver t);
377 } 377 }
OLDNEW
« no previous file with comments | « src/gpu/GrResourceProvider.cpp ('k') | src/gpu/GrSoftwarePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698