OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "Request.h" | 8 #include "Request.h" |
9 | 9 |
10 #include "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // TODO make this configurable | 133 // TODO make this configurable |
134 bounds = SkIRect::MakeWH(SkTMin(bounds.width(), kDefaultWidth), | 134 bounds = SkIRect::MakeWH(SkTMin(bounds.width(), kDefaultWidth), |
135 SkTMin(bounds.height(), kDefaultHeight)); | 135 SkTMin(bounds.height(), kDefaultHeight)); |
136 return bounds; | 136 return bounds; |
137 } | 137 } |
138 | 138 |
139 SkSurface* Request::createCPUSurface() { | 139 SkSurface* Request::createCPUSurface() { |
140 SkIRect bounds = this->getBounds(); | 140 SkIRect bounds = this->getBounds(); |
141 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), kN32_S
kColorType, | 141 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), kN32_S
kColorType, |
142 kPremul_SkAlphaType); | 142 kPremul_SkAlphaType); |
143 return SkSurface::NewRaster(info); | 143 return SkSurface::MakeRaster(info).release(); |
144 } | 144 } |
145 | 145 |
146 SkSurface* Request::createGPUSurface() { | 146 SkSurface* Request::createGPUSurface() { |
147 GrContext* context = this->getContext(); | 147 GrContext* context = this->getContext(); |
148 SkIRect bounds = this->getBounds(); | 148 SkIRect bounds = this->getBounds(); |
149 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), | 149 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), |
150 kN32_SkColorType, kPremul_SkAlphaType); | 150 kN32_SkColorType, kPremul_SkAlphaType); |
151 uint32_t flags = 0; | 151 uint32_t flags = 0; |
152 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); | 152 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
153 SkSurface* surface = SkSurface::NewRenderTarget(context, SkBudgeted::kNo, in
fo, 0, | 153 SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, i
nfo, 0, |
154 &props); | 154 &props).release(); |
155 return surface; | 155 return surface; |
156 } | 156 } |
157 | 157 |
158 bool Request::enableGPU(bool enable) { | 158 bool Request::enableGPU(bool enable) { |
159 if (enable) { | 159 if (enable) { |
160 SkSurface* surface = this->createGPUSurface(); | 160 SkSurface* surface = this->createGPUSurface(); |
161 if (surface) { | 161 if (surface) { |
162 fSurface.reset(surface); | 162 fSurface.reset(surface); |
163 fGPUEnabled = true; | 163 fGPUEnabled = true; |
164 | 164 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 canvas->flush(); | 248 canvas->flush(); |
249 SkAutoTDelete<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas)); | 249 SkAutoTDelete<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas)); |
250 SkASSERT(bitmap); | 250 SkASSERT(bitmap); |
251 bitmap->lockPixels(); | 251 bitmap->lockPixels(); |
252 uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * bitmap->width() + x
) * 4; | 252 uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * bitmap->width() + x
) * 4; |
253 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); | 253 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); |
254 bitmap->unlockPixels(); | 254 bitmap->unlockPixels(); |
255 return result; | 255 return result; |
256 } | 256 } |
257 | 257 |
OLD | NEW |