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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 108 } |
109 canvas->restore(); | 109 canvas->restore(); |
110 canvas->translate(W * 5 / 4, 0); | 110 canvas->translate(W * 5 / 4, 0); |
111 } | 111 } |
112 } | 112 } |
113 canvas->restore(); | 113 canvas->restore(); |
114 canvas->translate(0, (H * 5 / 4) * SK_ARRAY_COUNT(procs)); | 114 canvas->translate(0, (H * 5 / 4) * SK_ARRAY_COUNT(procs)); |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size, bool
skipGPU) { | 118 static sk_sp<SkSurface> compat_surface(SkCanvas* canvas, const SkISize& size
, bool skipGPU) { |
119 SkImageInfo info = SkImageInfo::MakeN32Premul(size); | 119 SkImageInfo info = SkImageInfo::MakeN32Premul(size); |
120 | 120 |
121 bool callNewSurface = true; | 121 bool callNewSurface = true; |
122 #if SK_SUPPORT_GPU | 122 #if SK_SUPPORT_GPU |
123 if (canvas->getGrContext() && skipGPU) { | 123 if (canvas->getGrContext() && skipGPU) { |
124 callNewSurface = false; | 124 callNewSurface = false; |
125 } | 125 } |
126 #endif | 126 #endif |
127 SkSurface* surface = callNewSurface ? canvas->newSurface(info) : nullptr
; | 127 sk_sp<SkSurface> surface = callNewSurface ? canvas->makeSurface(info) :
nullptr; |
128 if (nullptr == surface) { | 128 if (nullptr == surface) { |
129 // picture canvas will return null, so fall-back to raster | 129 // picture canvas will return null, so fall-back to raster |
130 surface = SkSurface::NewRaster(info); | 130 surface = SkSurface::MakeRaster(info); |
131 } | 131 } |
132 return surface; | 132 return surface; |
133 } | 133 } |
134 | 134 |
135 virtual void onDraw(SkCanvas* canvas) { | 135 virtual void onDraw(SkCanvas* canvas) { |
136 SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize(), | 136 auto surf(compat_surface(canvas, this->getISize(), this->isCanvasDeferre
d())); |
137 this->isCanvasDeferred())); | |
138 surf->getCanvas()->drawColor(SK_ColorWHITE); | 137 surf->getCanvas()->drawColor(SK_ColorWHITE); |
139 this->drawContent(surf->getCanvas()); | 138 this->drawContent(surf->getCanvas()); |
140 surf->draw(canvas, 0, 0, nullptr); | 139 surf->draw(canvas, 0, 0, nullptr); |
141 } | 140 } |
142 | 141 |
143 private: | 142 private: |
144 typedef skiagm::GM INHERITED; | 143 typedef skiagm::GM INHERITED; |
145 }; | 144 }; |
146 | 145 |
147 /////////////////////////////////////////////////////////////////////////////// | 146 /////////////////////////////////////////////////////////////////////////////// |
148 | 147 |
149 DEF_GM(return new SrcModeGM;) | 148 DEF_GM(return new SrcModeGM;) |
OLD | NEW |