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

Side by Side Diff: gm/surface.cpp

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 8 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 | « gm/stroketext.cpp ('k') | gm/tallstretchedbitmaps.cpp » ('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 2014 Google Inc. 2 * Copyright 2014 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 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkSurface.h" 10 #include "SkSurface.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 paint.setTextSize(32); 54 paint.setTextSize(32);
55 paint.setTextAlign(SkPaint::kCenter_Align); 55 paint.setTextAlign(SkPaint::kCenter_Align);
56 canvas->drawText(label, strlen(label), W / 2, H * 3 / 4, paint); 56 canvas->drawText(label, strlen(label), W / 2, H * 3 / 4, paint);
57 } 57 }
58 58
59 class SurfacePropsGM : public skiagm::GM { 59 class SurfacePropsGM : public skiagm::GM {
60 public: 60 public:
61 SurfacePropsGM() {} 61 SurfacePropsGM() {}
62 62
63 protected: 63 protected:
64 SkString onShortName() SK_OVERRIDE { 64 SkString onShortName() override {
65 return SkString("surfaceprops"); 65 return SkString("surfaceprops");
66 } 66 }
67 67
68 SkISize onISize() SK_OVERRIDE { 68 SkISize onISize() override {
69 return SkISize::Make(W * 4, H * 5); 69 return SkISize::Make(W * 4, H * 5);
70 } 70 }
71 71
72 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 72 void onDraw(SkCanvas* canvas) override {
73 GrContext* ctx = canvas->getGrContext(); 73 GrContext* ctx = canvas->getGrContext();
74 74
75 // must be opaque to have a hope of testing LCD text 75 // must be opaque to have a hope of testing LCD text
76 const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType) ; 76 const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType) ;
77 77
78 const struct { 78 const struct {
79 SkPixelGeometry fGeo; 79 SkPixelGeometry fGeo;
80 const char* fLabel; 80 const char* fLabel;
81 } rec[] = { 81 } rec[] = {
82 { kUnknown_SkPixelGeometry, "Unknown" }, 82 { kUnknown_SkPixelGeometry, "Unknown" },
(...skipping 28 matching lines...) Expand all
111 static bool equal(const SkSurfaceProps& a, const SkSurfaceProps& b) { 111 static bool equal(const SkSurfaceProps& a, const SkSurfaceProps& b) {
112 return a.flags() == b.flags() && a.pixelGeometry() == b.pixelGeometry(); 112 return a.flags() == b.flags() && a.pixelGeometry() == b.pixelGeometry();
113 } 113 }
114 #endif 114 #endif
115 115
116 class NewSurfaceGM : public skiagm::GM { 116 class NewSurfaceGM : public skiagm::GM {
117 public: 117 public:
118 NewSurfaceGM() {} 118 NewSurfaceGM() {}
119 119
120 protected: 120 protected:
121 SkString onShortName() SK_OVERRIDE { 121 SkString onShortName() override {
122 return SkString("surfacenew"); 122 return SkString("surfacenew");
123 } 123 }
124 124
125 SkISize onISize() SK_OVERRIDE { 125 SkISize onISize() override {
126 return SkISize::Make(300, 140); 126 return SkISize::Make(300, 140);
127 } 127 }
128 128
129 static void drawInto(SkCanvas* canvas) { 129 static void drawInto(SkCanvas* canvas) {
130 canvas->drawColor(SK_ColorRED); 130 canvas->drawColor(SK_ColorRED);
131 } 131 }
132 132
133 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 133 void onDraw(SkCanvas* canvas) override {
134 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); 134 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
135 135
136 SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, NULL)); 136 SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, NULL));
137 if (!surf.get()) { 137 if (!surf.get()) {
138 surf.reset(SkSurface::NewRaster(info)); 138 surf.reset(SkSurface::NewRaster(info));
139 } 139 }
140 drawInto(surf->getCanvas()); 140 drawInto(surf->getCanvas());
141 141
142 SkAutoTUnref<SkImage> image(surf->newImageSnapshot()); 142 SkAutoTUnref<SkImage> image(surf->newImageSnapshot());
143 canvas->drawImage(image, 10, 10, NULL); 143 canvas->drawImage(image, 10, 10, NULL);
144 144
145 SkAutoTUnref<SkSurface> surf2(image->newSurface(info, NULL)); 145 SkAutoTUnref<SkSurface> surf2(image->newSurface(info, NULL));
146 drawInto(surf2->getCanvas()); 146 drawInto(surf2->getCanvas());
147 147
148 // Assert that the props were communicated transitively through the firs t image 148 // Assert that the props were communicated transitively through the firs t image
149 SkASSERT(equal(surf->props(), surf2->props())); 149 SkASSERT(equal(surf->props(), surf2->props()));
150 150
151 SkAutoTUnref<SkImage> image2(surf2->newImageSnapshot()); 151 SkAutoTUnref<SkImage> image2(surf2->newImageSnapshot());
152 canvas->drawImage(image2, 10 + SkIntToScalar(image->width()) + 10, 10, N ULL); 152 canvas->drawImage(image2, 10 + SkIntToScalar(image->width()) + 10, 10, N ULL);
153 } 153 }
154 154
155 private: 155 private:
156 typedef GM INHERITED; 156 typedef GM INHERITED;
157 }; 157 };
158 DEF_GM( return new NewSurfaceGM ) 158 DEF_GM( return new NewSurfaceGM )
159 159
OLDNEW
« no previous file with comments | « gm/stroketext.cpp ('k') | gm/tallstretchedbitmaps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698