| OLD | NEW | 
|   1  |   1  | 
|   2 /* |   2 /* | 
|   3  * Copyright 2012 Google Inc. |   3  * Copyright 2012 Google Inc. | 
|   4  * |   4  * | 
|   5  * Use of this source code is governed by a BSD-style license that can be |   5  * Use of this source code is governed by a BSD-style license that can be | 
|   6  * found in the LICENSE file. |   6  * found in the LICENSE file. | 
|   7  */ |   7  */ | 
|   8  |   8  | 
|   9 #include "gm.h" |   9 #include "gm.h" | 
|  10 #include "SkCanvas.h" |  10 #include "SkCanvas.h" | 
|  11 #include "SkPicture.h" |  11 #include "SkPicture.h" | 
|  12 #include "SkPictureRecorder.h" |  12 #include "SkPictureRecorder.h" | 
|  13  |  13  | 
|  14 namespace skiagm { |  14 namespace skiagm { | 
|  15  |  15  | 
|  16 class DistantClipGM : public GM { |  16 class DistantClipGM : public GM { | 
|  17 public: |  17 public: | 
|  18     DistantClipGM() { } |  18     DistantClipGM() { } | 
|  19  |  19  | 
|  20 protected: |  20 protected: | 
|  21  |  21  | 
|  22     SkString onShortName() { |  22     SkString onShortName() { | 
|  23         return SkString("distantclip"); |  23         return SkString("distantclip"); | 
|  24     } |  24     } | 
|  25  |  25  | 
|  26     SkISize onISize() { return SkISize::Make(100, 100); } |  26     SkISize onISize() { return SkISize::Make(100, 100); } | 
|  27  |  27  | 
|  28     virtual void onDraw(SkCanvas* canvas) { |  28     virtual void onDraw(SkCanvas* canvas) { | 
|  29         static const SkScalar kOffset = 35000.0f; |  29         constexpr SkScalar kOffset = 35000.0f; | 
|  30         static const SkScalar kExtents = 1000.0f; |  30         constexpr SkScalar kExtents = 1000.0f; | 
|  31  |  31  | 
|  32         SkPictureRecorder recorder; |  32         SkPictureRecorder recorder; | 
|  33         // We record a picture of huge vertical extents in which we clear the ca
    nvas to red, create |  33         // We record a picture of huge vertical extents in which we clear the ca
    nvas to red, create | 
|  34         // a 'extents' by 'extents' round rect clip at a vertical offset of 'off
    set', then draw |  34         // a 'extents' by 'extents' round rect clip at a vertical offset of 'off
    set', then draw | 
|  35         // green into that. |  35         // green into that. | 
|  36         SkCanvas* rec = recorder.beginRecording(kExtents, kOffset + kExtents, nu
    llptr, 0); |  36         SkCanvas* rec = recorder.beginRecording(kExtents, kOffset + kExtents, nu
    llptr, 0); | 
|  37         rec->drawColor(SK_ColorRED); |  37         rec->drawColor(SK_ColorRED); | 
|  38         rec->save(); |  38         rec->save(); | 
|  39         SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents,
     2 * kExtents); |  39         SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents,
     2 * kExtents); | 
|  40         SkPath p; |  40         SkPath p; | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|  63 private: |  63 private: | 
|  64     typedef GM INHERITED; |  64     typedef GM INHERITED; | 
|  65 }; |  65 }; | 
|  66  |  66  | 
|  67 /////////////////////////////////////////////////////////////////////////////// |  67 /////////////////////////////////////////////////////////////////////////////// | 
|  68  |  68  | 
|  69 static GM* MyFactory(void*) { return new DistantClipGM; } |  69 static GM* MyFactory(void*) { return new DistantClipGM; } | 
|  70 static GMRegistry reg(MyFactory); |  70 static GMRegistry reg(MyFactory); | 
|  71  |  71  | 
|  72 } |  72 } | 
| OLD | NEW |