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

Issue 163493005: Revert of add peekPixels to SkCanvas and SkSurface (Closed)

Created:
6 years, 10 months ago by reed1
Modified:
6 years, 10 months ago
Reviewers:
rmistry, reed2
CC:
skia-review_googlegroups.com
Visibility:
Public.

Description

Revert of add peekPixels to SkCanvas and SkSurface (https://codereview.chromium.org/161733002/) Reason for revert: xfermodes3 gm failed to compile Original issue's description: > add peekPixels to SkCanvas and SkSurface > > clone of https://codereview.chromium.org/159723006/ > > Committed: https://code.google.com/p/skia/source/detail?r=13427 TBR=reed@chromium.org NOTREECHECKS=true NOTRY=true

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+304 lines, -403 lines) Patch
M gm/aaclip.cpp View 3 chunks +214 lines, -5 lines 0 comments Download
M gm/bitmapcopy.cpp View 1 chunk +5 lines, -5 lines 0 comments Download
M gm/bitmapsource.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M gm/deviceproperties.cpp View 1 chunk +0 lines, -1 line 0 comments Download
M gm/displacement.cpp View 2 chunks +4 lines, -2 lines 0 comments Download
M gm/gammatext.cpp View 2 chunks +6 lines, -14 lines 0 comments Download
M gm/gm.h View 1 chunk +2 lines, -1 line 0 comments Download
M gm/imagefiltersclipped.cpp View 2 chunks +5 lines, -3 lines 0 comments Download
M gm/imagefiltersgraph.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M gm/imagefiltersscaled.cpp View 2 chunks +4 lines, -2 lines 0 comments Download
M gm/lighting.cpp View 2 chunks +3 lines, -2 lines 0 comments Download
M gm/matrixconvolution.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M gm/morphology.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M gm/ninepatchstretch.cpp View 1 chunk +4 lines, -1 line 0 comments Download
M gm/offsetimagefilter.cpp View 2 chunks +6 lines, -3 lines 0 comments Download
D gm/peekpixels.cpp View 1 chunk +0 lines, -78 lines 0 comments Download
M gm/tileimagefilter.cpp View 2 chunks +4 lines, -2 lines 0 comments Download
M gm/xfermodeimagefilter.cpp View 2 chunks +4 lines, -2 lines 0 comments Download
M gyp/gmslides.gypi View 1 chunk +0 lines, -1 line 0 comments Download
M include/core/SkBitmap.h View 1 chunk +0 lines, -7 lines 0 comments Download
M include/core/SkBitmapDevice.h View 2 chunks +0 lines, -3 lines 0 comments Download
M include/core/SkCanvas.h View 5 chunks +4 lines, -73 lines 0 comments Download
M include/core/SkDevice.h View 2 chunks +1 line, -10 lines 0 comments Download
M include/core/SkSurface.h View 1 chunk +0 lines, -12 lines 0 comments Download
M samplecode/SampleApp.cpp View 1 chunk +2 lines, -3 lines 0 comments Download
M samplecode/SampleCircle.cpp View 1 chunk +6 lines, -0 lines 0 comments Download
M samplecode/SampleLayers.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M src/core/SkBitmapDevice.cpp View 2 chunks +0 lines, -14 lines 0 comments Download
M src/core/SkCanvas.cpp View 1 chunk +0 lines, -49 lines 0 comments Download
M src/core/SkDevice.cpp View 2 chunks +0 lines, -8 lines 0 comments Download
M src/core/SkPictureRecord.h View 1 chunk +0 lines, -3 lines 0 comments Download
M src/image/SkImagePriv.h View 1 chunk +2 lines, -0 lines 0 comments Download
M src/image/SkSurface.cpp View 1 chunk +0 lines, -5 lines 0 comments Download
M tests/SkpSkGrTest.cpp View 1 chunk +1 line, -5 lines 0 comments Download
M tests/SurfaceTest.cpp View 4 chunks +17 lines, -82 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
reed1
Created Revert of add peekPixels to SkCanvas and SkSurface
6 years, 10 months ago (2014-02-13 15:29:35 UTC) #1
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/reed@google.com/163493005/1
6 years, 10 months ago (2014-02-13 15:29:49 UTC) #2
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 10 months ago (2014-02-13 15:30:00 UTC) #3
commit-bot: I haz the power
Failed to apply patch for gm/aaclip.cpp: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file ...
6 years, 10 months ago (2014-02-13 15:30:00 UTC) #4
rmistry
6 years, 10 months ago (2014-02-13 15:57:45 UTC) #5
On 2014/02/13 15:30:00, I haz the power (commit-bot) wrote:
> Failed to apply patch for gm/aaclip.cpp:
> While running patch -p1 --forward --force --no-backup-if-mismatch;
>   patching file gm/aaclip.cpp
>   Hunk #1 FAILED at 9.
>   Hunk #2 FAILED at 36.
>   Hunk #3 FAILED at 80.
>   3 out of 3 hunks FAILED -- saving rejects to file gm/aaclip.cpp.rej
> 
> Patch:       gm/aaclip.cpp
> Index: gm/aaclip.cpp
> diff --git a/gm/aaclip.cpp b/gm/aaclip.cpp
> index
>
5742902f090970346d778df9027d7d8f54fe5e3e..ec29a4f896f324a87d3f8d7e9b825d6210b17885
> 100644
> --- a/gm/aaclip.cpp
> +++ b/gm/aaclip.cpp
> @@ -9,11 +9,203 @@
>  #include "SkCanvas.h"
>  #include "SkPath.h"
>  
> +static void test_quadstroke(SkCanvas* canvas) {
> +    SkPath path;
> +    path.moveTo(6, 0);
> +    path.quadTo(150, 150, 0, 6);
> +
> +    SkPaint paint;
> +
> +    paint.setAntiAlias(true);
> +    paint.setStyle(SkPaint::kStroke_Style);
> +    canvas->translate(20, 20);
> +
> +#if 1
> +    canvas->drawPath(path, paint);
> +    canvas->translate(100, 0);
> +#endif
> +
> +    paint.setStrokeWidth(1.01f);
> +    canvas->drawPath(path, paint);
> +}
> +
> +static void draw_conic(SkCanvas* canvas, SkScalar weight, const SkPaint&
paint)
> {
> +    SkPath path;
> +    path.moveTo(100, 100);
> +    path.conicTo(300, 100, 300, 300, weight);
> +    canvas->drawPath(path, paint);
> +}
> +
> +static void test_conic(SkCanvas* canvas) {
> +    SkPaint paint;
> +    paint.setAntiAlias(true);
> +    paint.setStyle(SkPaint::kStroke_Style);
> +
> +    static const struct {
> +        SkScalar fWeight;
> +        SkColor  fColor;
> +    } gRec[] = {
> +        { 2   , SK_ColorRED },
> +        { 1   , SK_ColorGREEN },
> +        { 0.5f, SK_ColorBLUE },
> +    };
> +
> +    for (SkScalar width = 0; width <= 20; width += 20) {
> +        canvas->save();
> +        paint.setStrokeWidth(width);
> +        for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
> +            paint.setColor(gRec[i].fColor);
> +            draw_conic(canvas, gRec[i].fWeight, paint);
> +            canvas->translate(-30, 30);
> +        }
> +        canvas->restore();
> +        canvas->translate(300, 0);
> +    }
> +}
> +
> +#include "SkGradientShader.h"
> +static void test_shallow_gradient(SkCanvas* canvas, SkScalar width, SkScalar
> height) {
> +    SkColor colors[] = { 0xFF7F7F7F, 0xFF7F7F7F, 0xFF000000 };
> +    SkScalar pos[] = { 0, 0.35f, SK_Scalar1 };
> +    SkPoint pts[] = { { 0, 0 }, { width, height } };
> +    SkShader* s = SkGradientShader::CreateLinear(pts, colors, pos,
> +                                                 SK_ARRAY_COUNT(colors),
> +                                                 SkShader::kClamp_TileMode);
> +    SkPaint paint;
> +    paint.setShader(s)->unref();
> +    canvas->drawPaint(paint);
> +}
> +
> +#include "SkDashPathEffect.h"
> +static void test_giant_dash(SkCanvas* canvas) {
> +    SkPaint paint;
> +    const SkScalar intervals[] = { SK_Scalar1, SK_Scalar1 };
> +
> +    paint.setStrokeWidth(2);
> +    paint.setPathEffect(new SkDashPathEffect(intervals, 2, 0))->unref();
> +
> +    SkScalar big = 500 * 1000;
> +
> +    canvas->drawLine(10, 10, big, 10, paint);
> +    canvas->drawLine(-big, 20, 500, 20, paint);
> +    canvas->drawLine(-big, 30, big, 30, paint);
> +
> +    const SkScalar intervals2[] = { 20, 5, 10, 5 };
> +    paint.setPathEffect(new SkDashPathEffect(intervals2, 4, 17))->unref();
> +
> +    canvas->translate(0, 40);
> +    SkScalar x = -500;
> +    SkScalar width = 3173;
> +    for (int i = 0; i < 40; ++i) {
> +        if (i > 10)
> +        canvas->drawLine(x, 0, x + width, 0, paint);
> +        x += 1;
> +        canvas->translate(0, 4);
> +    }
> +}
> +
> +
> +
> +// Reproduces bug found here: http://jsfiddle.net/R8Cu5/1/
> +//
> +#include "SkGradientShader.h"
> +static void test_grad(SkCanvas* canvas) {
> +    SkPoint pts[] = {
> +        { 478.544067f, -84.2041016f },
> +        { 602.455933f, 625.204102f },
> +    };
> +    SkColor colors[] = { SK_ColorBLACK, SK_ColorBLACK, SK_ColorRED,
SK_ColorRED
> };
> +    SkScalar pos[] = { 0, 0.3f, 0.3f, 1.0f };
> +    SkShader* s = SkGradientShader::CreateLinear(pts, colors, pos, 4,
> SkShader::kClamp_TileMode);
> +    SkPaint p;
> +    p.setShader(s)->unref();
> +    canvas->drawPaint(p);
> +}
> +
> +static SkCanvas* MakeCanvas(const SkIRect& bounds) {
> +    SkBitmap bm;
> +    bm.allocN32Pixels(bounds.width(), bounds.height());
> +    bm.eraseColor(SK_ColorTRANSPARENT);
> +
> +    SkCanvas* canvas = new SkCanvas(bm);
> +    canvas->translate(-SkIntToScalar(bounds.fLeft),
> -SkIntToScalar(bounds.fTop));
> +    return canvas;
> +}
> +
> +#ifdef SK_DEBUG
> +static void GetBitmap(const SkCanvas* canvas, SkBitmap* bm) {
> +    *bm = canvas->getDevice()->accessBitmap(false);
> +}
> +#endif
> +
> +static void compare_canvas(const SkCanvas* a, const SkCanvas* b) {
> +#ifdef SK_DEBUG
> +    SkBitmap bma, bmb;
> +    GetBitmap(a, &bma);
> +    GetBitmap(b, &bmb);
> +
> +    SkASSERT(bma.width() == bmb.width());
> +    SkASSERT(bma.height() == bmb.height());
> +
> +    bma.lockPixels();
> +    bmb.lockPixels();
> +    for (int y = 0; y < bma.height(); ++y) {
> +        const SkPMColor* rowa = bma.getAddr32(0, y);
> +        const SkPMColor* rowb = bmb.getAddr32(0, y);
> +        SkASSERT(!memcmp(rowa, rowb, bma.width() << 2));
> +
> +        for (int x = 1; x < bma.width() - 1; ++x) {
> +            SkASSERT(0xFF000000 == rowa[x]);
> +            SkASSERT(0xFF000000 == rowb[x]);
> +        }
> +    }
> +#endif
> +}
> +
> +static void drawRectAsPath(SkCanvas* canvas, const SkRect& r, const SkPaint&
p)
> {
> +    SkPath path;
> +    path.addRect(r);
> +    canvas->drawPath(path, p);
> +}
> +
> +static void test_maskFromPath(const SkPath& path) {
> +    SkIRect bounds;
> +    path.getBounds().roundOut(&bounds);
> +
> +    SkPaint paint;
> +    paint.setAntiAlias(true);
> +
> +    SkAutoTUnref<SkCanvas> path_canvas(MakeCanvas(bounds));
> +    path_canvas->drawPath(path, paint);
> +
> +    SkAutoTUnref<SkCanvas> rect_canvas(MakeCanvas(bounds));
> +    drawRectAsPath(rect_canvas, path.getBounds(), paint);
> +
> +    compare_canvas(path_canvas, rect_canvas);
> +}
> +
> +static void test_mask() {
> +    for (int i = 1; i <= 20; ++i) {
> +        const SkScalar dx = SK_Scalar1 / i;
> +        const SkRect constr = SkRect::MakeWH(dx, SkIntToScalar(2));
> +        for (int n = 2; n < 20; ++n) {
> +            SkPath path;
> +            path.setFillType(SkPath::kEvenOdd_FillType);
> +            SkRect r = constr;
> +            while (r.fRight < SkIntToScalar(4)) {
> +                path.addRect(r);
> +                r.offset(dx, 0);
> +            }
> +            test_maskFromPath(path);
> +        }
> +    }
> +}
> +
>  /** Draw a 2px border around the target, then red behind the target;
>      set the clip to match the target, then draw >> the target in blue.
>  */
>  
> -static void draw(SkCanvas* canvas, SkRect& target, int x, int y) {
> +static void draw (SkCanvas* canvas, SkRect& target, int x, int y) {
>      SkPaint borderPaint;
>      borderPaint.setColor(SkColorSetRGB(0x0, 0xDD, 0x0));
>      borderPaint.setAntiAlias(true);
> @@ -36,22 +228,22 @@
>      canvas->restore();
>  }
>  
> -static void draw_square(SkCanvas* canvas, int x, int y) {
> +static void draw_square (SkCanvas* canvas, int x, int y) {
>      SkRect target (SkRect::MakeWH(10 * SK_Scalar1, 10 * SK_Scalar1));
>      draw(canvas, target, x, y);
>  }
>  
> -static void draw_column(SkCanvas* canvas, int x, int y) {
> +static void draw_column (SkCanvas* canvas, int x, int y) {
>      SkRect target (SkRect::MakeWH(1 * SK_Scalar1, 10 * SK_Scalar1));
>      draw(canvas, target, x, y);
>  }
>  
> -static void draw_bar(SkCanvas* canvas, int x, int y) {
> +static void draw_bar (SkCanvas* canvas, int x, int y) {
>      SkRect target (SkRect::MakeWH(10 * SK_Scalar1, 1 * SK_Scalar1));
>      draw(canvas, target, x, y);
>  }
>  
> -static void draw_rect_tests(SkCanvas* canvas) {
> +static void draw_rect_tests (SkCanvas* canvas) {
>      draw_square(canvas, 10, 10);
>      draw_column(canvas, 30, 10);
>      draw_bar(canvas, 10, 30);
> @@ -80,6 +272,23 @@
>      }
>  
>      virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
> +        if (false) { test_quadstroke(canvas); return; }
> +        if (false) { test_conic(canvas); return; }
> +        if (false) {
> +            SkRect bounds;
> +            canvas->getClipBounds(&bounds);
> +            test_shallow_gradient(canvas, bounds.width(), bounds.height());
> return;
> +        }
> +        if (false) {
> +            test_giant_dash(canvas); return;
> +        }
> +        if (false) {
> +            test_grad(canvas); return;
> +        }
> +        if (false) { // avoid bit rot, suppress warning
> +            test_mask();
> +        }
> +
>          // Initial pixel-boundary-aligned draw
>          draw_rect_tests(canvas);

This failed to apply because the 1st revert went through after Jim's LGTM:
https://codereview.chromium.org/163823002/

Can probably delete this CL now.

Powered by Google App Engine
This is Rietveld 408576698