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

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

Issue 1815823002: Move SkGLContext and some GrGLInterface implementations to skgputest module (Closed) Base URL: https://chromium.googlesource.com/skia.git@debugobject
Patch Set: fix windows and android? Created 4 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 | « tools/skiaserve/Request.h ('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"
11 #include "SkPixelSerializer.h" 11 #include "SkPixelSerializer.h"
12 12
13 using namespace sk_gpu_test;
14
13 static int kDefaultWidth = 1920; 15 static int kDefaultWidth = 1920;
14 static int kDefaultHeight = 1080; 16 static int kDefaultHeight = 1080;
15 17
16 18
17 Request::Request(SkString rootUrl) 19 Request::Request(SkString rootUrl)
18 : fUploadContext(nullptr) 20 : fUploadContext(nullptr)
19 , fUrlDataManager(rootUrl) 21 , fUrlDataManager(rootUrl)
20 , fGPUEnabled(false) { 22 , fGPUEnabled(false) {
21 // create surface 23 // create surface
22 #if SK_SUPPORT_GPU 24 #if SK_SUPPORT_GPU
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // write to png 58 // write to png
57 SkDynamicMemoryWStream buffer; 59 SkDynamicMemoryWStream buffer;
58 SkDrawCommand::WritePNG((const png_bytep) bmp->getPixels(), bmp->width(), bm p->height(), 60 SkDrawCommand::WritePNG((const png_bytep) bmp->getPixels(), bmp->width(), bm p->height(),
59 buffer); 61 buffer);
60 return buffer.copyToData(); 62 return buffer.copyToData();
61 } 63 }
62 64
63 SkCanvas* Request::getCanvas() { 65 SkCanvas* Request::getCanvas() {
64 #if SK_SUPPORT_GPU 66 #if SK_SUPPORT_GPU
65 GrContextFactory* factory = fContextFactory; 67 GrContextFactory* factory = fContextFactory;
66 SkGLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContex tType, 68 GLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextT ype,
67 GrContextFactory::kNone_GLContextO ptions).fGLContext; 69 GrContextFactory::kNone_GLContextOpt ions).fGLContext;
68 gl->makeCurrent(); 70 gl->makeCurrent();
69 #endif 71 #endif
70 SkASSERT(fDebugCanvas); 72 SkASSERT(fDebugCanvas);
71 73
72 // create the appropriate surface if necessary 74 // create the appropriate surface if necessary
73 if (!fSurface) { 75 if (!fSurface) {
74 this->enableGPU(fGPUEnabled); 76 this->enableGPU(fGPUEnabled);
75 } 77 }
76 SkCanvas* target = fSurface->getCanvas(); 78 SkCanvas* target = fSurface->getCanvas();
77 return target; 79 return target;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 SkCanvas* canvas = this->getCanvas(); 249 SkCanvas* canvas = this->getCanvas();
248 canvas->flush(); 250 canvas->flush();
249 SkAutoTDelete<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas)); 251 SkAutoTDelete<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas));
250 SkASSERT(bitmap); 252 SkASSERT(bitmap);
251 bitmap->lockPixels(); 253 bitmap->lockPixels();
252 uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * bitmap->width() + x ) * 4; 254 uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * bitmap->width() + x ) * 4;
253 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); 255 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]);
254 bitmap->unlockPixels(); 256 bitmap->unlockPixels();
255 return result; 257 return result;
256 } 258 }
OLDNEW
« no previous file with comments | « tools/skiaserve/Request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698