| OLD | NEW | 
|    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 "gm.h" |    8 #include "gm.h" | 
|    9  |    9  | 
|   10 #include "SkArithmeticMode.h" |   10 #include "SkArithmeticMode.h" | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  103  |  103  | 
|  104 protected: |  104 protected: | 
|  105  |  105  | 
|  106     virtual SkString onShortName() { |  106     virtual SkString onShortName() { | 
|  107         return SkString("imagefiltersgraph"); |  107         return SkString("imagefiltersgraph"); | 
|  108     } |  108     } | 
|  109  |  109  | 
|  110     void make_bitmap() { |  110     void make_bitmap() { | 
|  111         fBitmap.allocN32Pixels(100, 100); |  111         fBitmap.allocN32Pixels(100, 100); | 
|  112         SkCanvas canvas(fBitmap); |  112         SkCanvas canvas(fBitmap); | 
|  113         canvas.clear(0x00000000); |  113         canvas.clear(SK_ColorTRANSPARENT); | 
|  114         SkPaint paint; |  114         SkPaint paint; | 
|  115         paint.setAntiAlias(true); |  115         paint.setAntiAlias(true); | 
|  116         sk_tool_utils::set_portable_typeface(&paint); |  116         sk_tool_utils::set_portable_typeface(&paint); | 
|  117         paint.setColor(0xFFFFFFFF); |  117         paint.setColor(SK_ColorWHITE); | 
|  118         paint.setTextSize(SkIntToScalar(96)); |  118         paint.setTextSize(SkIntToScalar(96)); | 
|  119         const char* str = "e"; |  119         const char* str = "e"; | 
|  120         canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), 
     paint); |  120         canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), 
     paint); | 
|  121     } |  121     } | 
|  122  |  122  | 
|  123     void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPai
     nt& paint) { |  123     void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPai
     nt& paint) { | 
|  124         canvas->save(); |  124         canvas->save(); | 
|  125         canvas->clipRect(SkRect::MakeXYWH(0, 0, |  125         canvas->clipRect(SkRect::MakeXYWH(0, 0, | 
|  126             SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); |  126             SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); | 
|  127         canvas->drawBitmap(bitmap, 0, 0, &paint); |  127         canvas->drawBitmap(bitmap, 0, 0, &paint); | 
|  128         canvas->restore(); |  128         canvas->restore(); | 
|  129     } |  129     } | 
|  130  |  130  | 
|  131     virtual SkISize onISize() { return SkISize::Make(500, 150); } |  131     virtual SkISize onISize() { return SkISize::Make(500, 150); } | 
|  132  |  132  | 
|  133     virtual void onOnceBeforeDraw() { |  133     virtual void onOnceBeforeDraw() { | 
|  134         this->make_bitmap(); |  134         this->make_bitmap(); | 
|  135     } |  135     } | 
|  136  |  136  | 
|  137     virtual void onDraw(SkCanvas* canvas) { |  137     virtual void onDraw(SkCanvas* canvas) { | 
|  138         canvas->clear(0x00000000); |  138         canvas->clear(SK_ColorBLACK); | 
|  139         { |  139         { | 
|  140             SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit
     map)); |  140             SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit
     map)); | 
|  141             SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_Co
     lorRED, |  141             SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_Co
     lorRED, | 
|  142                                                          SkXfermode::kSrcIn_Mode
     )); |  142                                                          SkXfermode::kSrcIn_Mode
     )); | 
|  143             SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0
     f, bitmapSource)); |  143             SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0
     f, bitmapSource)); | 
|  144             SkAutoTUnref<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, b
     lur)); |  144             SkAutoTUnref<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, b
     lur)); | 
|  145             SkAutoTUnref<SkImageFilter> color(SkColorFilterImageFilter::Create(c
     f, erode)); |  145             SkAutoTUnref<SkImageFilter> color(SkColorFilterImageFilter::Create(c
     f, erode)); | 
|  146             SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(blur, c
     olor)); |  146             SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(blur, c
     olor)); | 
|  147  |  147  | 
|  148             SkPaint paint; |  148             SkPaint paint; | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  209                                                                             SkXf
     ermode::kSrcIn_Mode)); |  209                                                                             SkXf
     ermode::kSrcIn_Mode)); | 
|  210             SkImageFilter::CropRect outerRect(SkRect::MakeXYWH(SkIntToScalar(10)
     , SkIntToScalar(10), |  210             SkImageFilter::CropRect outerRect(SkRect::MakeXYWH(SkIntToScalar(10)
     , SkIntToScalar(10), | 
|  211                                                                SkIntToScalar(80)
     , SkIntToScalar(80))); |  211                                                                SkIntToScalar(80)
     , SkIntToScalar(80))); | 
|  212             SkImageFilter::CropRect innerRect(SkRect::MakeXYWH(SkIntToScalar(20)
     , SkIntToScalar(20), |  212             SkImageFilter::CropRect innerRect(SkRect::MakeXYWH(SkIntToScalar(20)
     , SkIntToScalar(20), | 
|  213                                                                SkIntToScalar(60)
     , SkIntToScalar(60))); |  213                                                                SkIntToScalar(60)
     , SkIntToScalar(60))); | 
|  214             SkAutoTUnref<SkImageFilter> color1(SkColorFilterImageFilter::Create(
     cf1, NULL, &outerRect)); |  214             SkAutoTUnref<SkImageFilter> color1(SkColorFilterImageFilter::Create(
     cf1, NULL, &outerRect)); | 
|  215             SkAutoTUnref<SkImageFilter> color2(SkColorFilterImageFilter::Create(
     cf2, color1, &innerRect)); |  215             SkAutoTUnref<SkImageFilter> color2(SkColorFilterImageFilter::Create(
     cf2, color1, &innerRect)); | 
|  216  |  216  | 
|  217             SkPaint paint; |  217             SkPaint paint; | 
|  218             paint.setImageFilter(color2); |  218             paint.setImageFilter(color2); | 
|  219             paint.setColor(0xFFFF0000); |  219             paint.setColor(SK_ColorRED); | 
|  220             canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint); |  220             canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint); | 
|  221             canvas->translate(SkIntToScalar(100), 0); |  221             canvas->translate(SkIntToScalar(100), 0); | 
|  222         } |  222         } | 
|  223     } |  223     } | 
|  224  |  224  | 
|  225 private: |  225 private: | 
|  226     typedef GM INHERITED; |  226     typedef GM INHERITED; | 
|  227     SkBitmap fBitmap; |  227     SkBitmap fBitmap; | 
|  228 }; |  228 }; | 
|  229  |  229  | 
|  230 /////////////////////////////////////////////////////////////////////////////// |  230 /////////////////////////////////////////////////////////////////////////////// | 
|  231  |  231  | 
|  232 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } |  232 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } | 
|  233 static skiagm::GMRegistry reg(MyFactory); |  233 static skiagm::GMRegistry reg(MyFactory); | 
| OLD | NEW |