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

Side by Side Diff: gm/surface.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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/techtalk1.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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() SK_OVERRIDE {
65 return SkString("surfaceprops"); 65 return SkString("surfaceprops");
66 } 66 }
67 67
68 virtual SkISize onISize() SK_OVERRIDE { 68 SkISize onISize() SK_OVERRIDE {
69 return SkISize::Make(W * 4, H * 5); 69 return SkISize::Make(W * 4, H * 5);
70 } 70 }
71 71
72 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 72 void onDraw(SkCanvas* canvas) SK_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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() SK_OVERRIDE {
122 return SkString("surfacenew"); 122 return SkString("surfacenew");
123 } 123 }
124 124
125 virtual SkISize onISize() SK_OVERRIDE { 125 SkISize onISize() SK_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 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 133 void onDraw(SkCanvas* canvas) SK_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/techtalk1.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698