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

Side by Side Diff: tools/skiaserve/Request.cpp

Issue 1817383002: switch surface to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « tools/skhello.cpp ('k') | no next file » | 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 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
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
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
OLDNEW
« no previous file with comments | « tools/skhello.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698