New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 4 users
Status: Accepted
Owner:
Cc:
Area: ----
Priority: Medium
Type: Defect



Sign in to add a comment
Drawing A8 onto A8
Project Member Reported by reed@google.com, Jun 6 2014 Back to list
The blits need to treat the src as the "src", not as coverage, otherwise we can't respect the porter-duff modes properly.

http://skfiddle.com/c/0f1aecf798e3624797c2334ae7c7147f

void draw(SkCanvas* canvas) {
    SkPaint p;
    p.setColor(SK_ColorRED);
    p.setAntiAlias(true);
    p.setStyle(SkPaint::kStroke_Style);
    p.setStrokeWidth(10);
    SkRect r = SkRect::MakeXYWH(30, 30, SkIntToScalar(40), SkIntToScalar(40));
    
    SkBitmap src1, src2, src1a8, src2a8;
    src1.setConfig(SkBitmap::kARGB_8888_Config,100,100);
    src2.setConfig(SkBitmap::kARGB_8888_Config,100,100);
    src1a8.setConfig(SkBitmap::kA8_Config,100,100);
    src2a8.setConfig(SkBitmap::kA8_Config,100,100);
    src1.allocPixels(); src2.allocPixels(); src1a8.allocPixels(); src2a8.allocPixels();
    
    SkCanvas sc(src1), sc2(src2), sca8(src1a8), sc2a8(src2a8);
    // intiailize src1's with some content
    sc.drawRoundRect(r, 5, 5, p);
    sca8.drawRoundRect(r, 5, 5, p);

    sc2.clear(SK_ColorGREEN);
    sc2a8.clear(SK_ColorGREEN);

    // try to copy src1's into src2's
    SkPaint copyPaint;
    copyPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
    sc2.drawBitmap(src1, 0, 0, &copyPaint);
    // unfortunately this drawBitmap ends up doing a drawBitmapAsMask()
    // and we end up as a solid square
    sc2a8.drawBitmap(src1a8, 0, 0, &copyPaint);

    // display the results
    p.setColor(SK_ColorBLUE);
    canvas->drawBitmap(src1, 0, 0, &p);
    canvas->drawBitmap(src2, 100, 0, &p);
    canvas->drawBitmap(src1a8, 0, 100, &p);
    canvas->drawBitmap(src2a8, 100, 100, &p);
 
}
 
Project Member Comment 1 by hcm@google.com, Dec 7 2015
Labels: Hotlist-Fixit
Project Member Comment 2 by reed@google.com, Apr 19 2017
Sign in to add a comment