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

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

Issue 292773002: Pass in GrContext instead of SkGpuDevice for dashing and Sk2GrPaint conversion (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Nit variable name Created 6 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/SkGpuDevice.cpp ('k') | src/gpu/effects/GrDashingEffect.h » ('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 2010 Google Inc. 2 * Copyright 2010 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 "SkGr.h" 8 #include "SkGr.h"
9 #include "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 #include "SkConfig8888.h" 10 #include "SkConfig8888.h"
11 #include "SkGpuDevice.h"
12 #include "SkMessageBus.h" 11 #include "SkMessageBus.h"
13 #include "SkPixelRef.h" 12 #include "SkPixelRef.h"
14 #include "GrResourceCache.h" 13 #include "GrResourceCache.h"
15 14
16 /* Fill out buffer with the compressed format Ganesh expects from a colortable 15 /* Fill out buffer with the compressed format Ganesh expects from a colortable
17 based bitmap. [palette (colortable) + indices]. 16 based bitmap. [palette (colortable) + indices].
18 17
19 At the moment Ganesh only supports 8bit version. If Ganesh allowed we others 18 At the moment Ganesh only supports 8bit version. If Ganesh allowed we others
20 we could detect that the colortable.count is <= 16, and then repack the 19 we could detect that the colortable.count is <= 16, and then repack the
21 indices as nibbles to save RAM, but it would take more time (i.e. a lot 20 indices as nibbles to save RAM, but it would take more time (i.e. a lot
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 return false; 320 return false;
322 } 321 }
323 if (ctOut) { 322 if (ctOut) {
324 *ctOut = ct; 323 *ctOut = ct;
325 } 324 }
326 return true; 325 return true;
327 } 326 }
328 327
329 /////////////////////////////////////////////////////////////////////////////// 328 ///////////////////////////////////////////////////////////////////////////////
330 329
331 void SkPaint2GrPaintNoShader(SkGpuDevice* dev, const SkPaint& skPaint, bool just Alpha, 330 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, bool ju stAlpha,
332 bool constantColor, GrPaint* grPaint) { 331 bool constantColor, GrPaint* grPaint) {
333 332
334 grPaint->setDither(skPaint.isDither()); 333 grPaint->setDither(skPaint.isDither());
335 grPaint->setAntiAlias(skPaint.isAntiAlias()); 334 grPaint->setAntiAlias(skPaint.isAntiAlias());
336 335
337 SkXfermode::Coeff sm; 336 SkXfermode::Coeff sm;
338 SkXfermode::Coeff dm; 337 SkXfermode::Coeff dm;
339 338
340 SkXfermode* mode = skPaint.getXfermode(); 339 SkXfermode* mode = skPaint.getXfermode();
341 GrEffectRef* xferEffect = NULL; 340 GrEffectRef* xferEffect = NULL;
(...skipping 22 matching lines...) Expand all
364 } 363 }
365 364
366 SkColorFilter* colorFilter = skPaint.getColorFilter(); 365 SkColorFilter* colorFilter = skPaint.getColorFilter();
367 if (NULL != colorFilter) { 366 if (NULL != colorFilter) {
368 // if the source color is a constant then apply the filter here once rat her than per pixel 367 // if the source color is a constant then apply the filter here once rat her than per pixel
369 // in a shader. 368 // in a shader.
370 if (constantColor) { 369 if (constantColor) {
371 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); 370 SkColor filtered = colorFilter->filterColor(skPaint.getColor());
372 grPaint->setColor(SkColor2GrColor(filtered)); 371 grPaint->setColor(SkColor2GrColor(filtered));
373 } else { 372 } else {
374 SkAutoTUnref<GrEffectRef> effect(colorFilter->asNewEffect(dev->conte xt())); 373 SkAutoTUnref<GrEffectRef> effect(colorFilter->asNewEffect(context));
375 if (NULL != effect.get()) { 374 if (NULL != effect.get()) {
376 grPaint->addColorEffect(effect); 375 grPaint->addColorEffect(effect);
377 } 376 }
378 } 377 }
379 } 378 }
380 } 379 }
381 380
382 void SkPaint2GrPaintShader(SkGpuDevice* dev, const SkPaint& skPaint, 381 void SkPaint2GrPaintShader(GrContext* context, const SkPaint& skPaint,
383 bool constantColor, GrPaint* grPaint) { 382 bool constantColor, GrPaint* grPaint) {
384 SkShader* shader = skPaint.getShader(); 383 SkShader* shader = skPaint.getShader();
385 if (NULL == shader) { 384 if (NULL == shader) {
386 SkPaint2GrPaintNoShader(dev, skPaint, false, constantColor, grPaint); 385 SkPaint2GrPaintNoShader(context, skPaint, false, constantColor, grPaint) ;
387 return; 386 return;
388 } 387 }
389 388
390 // SkShader::asNewEffect() may do offscreen rendering. Setup default drawing state and require 389 // SkShader::asNewEffect() may do offscreen rendering. Setup default drawing state and require
391 // the shader to set a render target. 390 // the shader to set a render target.
392 GrContext::AutoWideOpenIdentityDraw awo(dev->context(), NULL); 391 GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
393 392
394 // setup the shader as the first color effect on the paint 393 // setup the shader as the first color effect on the paint
395 SkAutoTUnref<GrEffectRef> effect(shader->asNewEffect(dev->context(), skPaint , NULL)); 394 SkAutoTUnref<GrEffectRef> effect(shader->asNewEffect(context, skPaint, NULL) );
396 if (NULL != effect.get()) { 395 if (NULL != effect.get()) {
397 grPaint->addColorEffect(effect); 396 grPaint->addColorEffect(effect);
398 // Now setup the rest of the paint. 397 // Now setup the rest of the paint.
399 SkPaint2GrPaintNoShader(dev, skPaint, true, false, grPaint); 398 SkPaint2GrPaintNoShader(context, skPaint, true, false, grPaint);
400 } else { 399 } else {
401 // We still don't have SkColorShader::asNewEffect() implemented. 400 // We still don't have SkColorShader::asNewEffect() implemented.
402 SkShader::GradientInfo info; 401 SkShader::GradientInfo info;
403 SkColor color; 402 SkColor color;
404 403
405 info.fColors = &color; 404 info.fColors = &color;
406 info.fColorOffsets = NULL; 405 info.fColorOffsets = NULL;
407 info.fColorCount = 1; 406 info.fColorCount = 1;
408 if (SkShader::kColor_GradientType == shader->asAGradient(&info)) { 407 if (SkShader::kColor_GradientType == shader->asAGradient(&info)) {
409 SkPaint copy(skPaint); 408 SkPaint copy(skPaint);
410 copy.setShader(NULL); 409 copy.setShader(NULL);
411 // modulate the paint alpha by the shader's solid color alpha 410 // modulate the paint alpha by the shader's solid color alpha
412 U8CPU newA = SkMulDiv255Round(SkColorGetA(color), copy.getAlpha()); 411 U8CPU newA = SkMulDiv255Round(SkColorGetA(color), copy.getAlpha());
413 copy.setColor(SkColorSetA(color, newA)); 412 copy.setColor(SkColorSetA(color, newA));
414 SkPaint2GrPaintNoShader(dev, copy, false, constantColor, grPaint); 413 SkPaint2GrPaintNoShader(context, copy, false, constantColor, grPaint );
415 } else { 414 } else {
416 SkPaint2GrPaintNoShader(dev, skPaint, false, constantColor, grPaint) ; 415 SkPaint2GrPaintNoShader(context, skPaint, false, constantColor, grPa int);
417 } 416 }
418 } 417 }
419 } 418 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/effects/GrDashingEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698