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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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/GrResourceCache.cpp ('k') | src/gpu/GrStencilAndCoverTextContext.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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 fPixels.reset(bmImageInfo); 219 fPixels.reset(bmImageInfo);
220 } 220 }
221 fDraw.fDst = fPixels; 221 fDraw.fDst = fPixels;
222 fRasterClip.setRect(bounds); 222 fRasterClip.setRect(bounds);
223 fDraw.fRC = &fRasterClip; 223 fDraw.fRC = &fRasterClip;
224 fDraw.fClip = &fRasterClip.bwRgn(); 224 fDraw.fClip = &fRasterClip.bwRgn();
225 fDraw.fMatrix = &fMatrix; 225 fDraw.fMatrix = &fMatrix;
226 return true; 226 return true;
227 } 227 }
228 228
229 #include "GrContext.h"
230 #include "GrResourceProvider.h"
231
229 /** 232 /**
230 * Get a texture (from the texture cache) of the correct size & format. 233 * Get a texture (from the texture cache) of the correct size & format.
231 */ 234 */
232 GrTexture* GrSWMaskHelper::createTexture() { 235 GrTexture* GrSWMaskHelper::createTexture() {
233 GrSurfaceDesc desc; 236 GrSurfaceDesc desc;
234 desc.fWidth = fPixels.width(); 237 desc.fWidth = fPixels.width();
235 desc.fHeight = fPixels.height(); 238 desc.fHeight = fPixels.height();
236 desc.fConfig = kAlpha_8_GrPixelConfig; 239 desc.fConfig = kAlpha_8_GrPixelConfig;
237 240
238 if (kNone_CompressionMode != fCompressionMode) { 241 if (kNone_CompressionMode != fCompressionMode) {
239 242
240 #ifdef SK_DEBUG 243 #ifdef SK_DEBUG
241 int dimX, dimY; 244 int dimX, dimY;
242 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ; 245 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ;
243 SkASSERT((desc.fWidth % dimX) == 0); 246 SkASSERT((desc.fWidth % dimX) == 0);
244 SkASSERT((desc.fHeight % dimY) == 0); 247 SkASSERT((desc.fHeight % dimY) == 0);
245 #endif 248 #endif
246 249
247 desc.fConfig = fmt_to_config(fCompressedFormat); 250 desc.fConfig = fmt_to_config(fCompressedFormat);
248 SkASSERT(fContext->caps()->isConfigTexturable(desc.fConfig)); 251 SkASSERT(fContext->caps()->isConfigTexturable(desc.fConfig));
249 } 252 }
250 253
251 return fContext->textureProvider()->createApproxTexture(desc); 254 return fContext->resourceProvider()->createApproxTexture(desc, GrResourcePro vider::kNoPendingIO_Flag);
252 } 255 }
253 256
254 void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrSurfaceDesc& de sc, 257 void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrSurfaceDesc& de sc,
255 const void *data, size_t rowbytes) { 258 const void *data, size_t rowbytes) {
256 // If we aren't reusing scratch textures we don't need to flush before 259 // If we aren't reusing scratch textures we don't need to flush before
257 // writing since no one else will be using 'texture' 260 // writing since no one else will be using 'texture'
258 bool reuseScratch = fContext->caps()->reuseScratchTextures(); 261 bool reuseScratch = fContext->caps()->reuseScratchTextures();
259 262
260 // Since we're uploading to it, and it's compressed, 'texture' shouldn't 263 // Since we're uploading to it, and it's compressed, 'texture' shouldn't
261 // have a render target. 264 // have a render target.
262 SkASSERT(nullptr == texture->asRenderTarget()); 265 SkASSERT(nullptr == texture->asRenderTarget());
263 266
264 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, 267 texture->writePixels(NULL, 0, 0, desc.fWidth, desc.fHeight,
265 desc.fConfig, data, rowbytes, 268 desc.fConfig, data, rowbytes,
266 reuseScratch ? 0 : GrContext::kDontFlush_PixelOpsFlag); 269 reuseScratch ? 0 : GrContext::kDontFlush_PixelOpsFlag);
270
271 texture->setFromRawPixels(true);
272 texture->setException(true);
267 } 273 }
268 274
269 void GrSWMaskHelper::compressTextureData(GrTexture *texture, const GrSurfaceDesc & desc) { 275 void GrSWMaskHelper::compressTextureData(GrTexture *texture, const GrSurfaceDesc & desc) {
270 276
271 SkASSERT(GrPixelConfigIsCompressed(desc.fConfig)); 277 SkASSERT(GrPixelConfigIsCompressed(desc.fConfig));
272 SkASSERT(fmt_to_config(fCompressedFormat) == desc.fConfig); 278 SkASSERT(fmt_to_config(fCompressedFormat) == desc.fConfig);
273 279
274 SkAutoDataUnref cmpData(SkTextureCompressor::CompressBitmapToFormat(fPixels, 280 SkAutoDataUnref cmpData(SkTextureCompressor::CompressBitmapToFormat(fPixels,
275 fCompres sedFormat)); 281 fCompres sedFormat));
276 SkASSERT(cmpData); 282 SkASSERT(cmpData);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 return nullptr; 336 return nullptr;
331 } 337 }
332 338
333 helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF); 339 helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF);
334 340
335 GrTexture* texture(helper.createTexture()); 341 GrTexture* texture(helper.createTexture());
336 if (!texture) { 342 if (!texture) {
337 return nullptr; 343 return nullptr;
338 } 344 }
339 345
346
347
340 helper.toTexture(texture); 348 helper.toTexture(texture);
341 349
342 return texture; 350 return texture;
343 } 351 }
344 352
345 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, 353 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
346 GrDrawTarget* target, 354 GrDrawTarget* target,
347 GrPipelineBuilder* pipelineBuilder , 355 GrPipelineBuilder* pipelineBuilder ,
348 GrColor color, 356 GrColor color,
349 const SkMatrix& viewMatrix, 357 const SkMatrix& viewMatrix,
(...skipping 13 matching lines...) Expand all
363 // a translation so that the top-left of the device bounds maps to 0,0, and then a scaling 371 // a translation so that the top-left of the device bounds maps to 0,0, and then a scaling
364 // matrix to normalized coords. 372 // matrix to normalized coords.
365 SkMatrix maskMatrix; 373 SkMatrix maskMatrix;
366 maskMatrix.setIDiv(texture->width(), texture->height()); 374 maskMatrix.setIDiv(texture->width(), texture->height());
367 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop )); 375 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop ));
368 376
369 pipelineBuilder->addCoverageFragmentProcessor( 377 pipelineBuilder->addCoverageFragmentProcessor(
370 GrSimpleTextureEffect::Create(texture, 378 GrSimpleTextureEffect::Create(texture,
371 maskMatrix, 379 maskMatrix,
372 GrTextureParams::kNone_Fi lterMode, 380 GrTextureParams::kNone_Fi lterMode,
373 kDevice_GrCoordSet))->unr ef(); 381 kDevice_GrCoordSet, targe t->rt_delete_me()))->unref();
374 382
375 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), dstRect, inver t); 383 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), dstRect, inver t);
376 } 384 }
OLDNEW
« no previous file with comments | « src/gpu/GrResourceCache.cpp ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698