Home | History | Annotate | Download | only in skiaserve
      1 /*
      2  * Copyright 2016 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef Request_DEFINED
      9 #define Request_DEFINED
     10 
     11 #include "GrContextFactory.h"
     12 
     13 #include "SkDebugCanvas.h"
     14 #include "SkPicture.h"
     15 #include "SkStream.h"
     16 #include "SkSurface.h"
     17 
     18 #include "UrlDataManager.h"
     19 
     20 struct MHD_Connection;
     21 struct MHD_PostProcessor;
     22 
     23 struct UploadContext {
     24     SkDynamicMemoryWStream fStream;
     25     MHD_PostProcessor* fPostProcessor;
     26     MHD_Connection* connection;
     27 };
     28 
     29 struct Request {
     30     Request(SkString rootUrl)
     31     : fUploadContext(nullptr)
     32     , fUrlDataManager(rootUrl)
     33     , fGPUEnabled(false) {}
     34 
     35     SkSurface* createCPUSurface();
     36     SkSurface* createGPUSurface();
     37     SkData* drawToPng(int n);
     38     void drawToCanvas(int n);
     39     SkCanvas* getCanvas();
     40     SkData* writeCanvasToPng(SkCanvas* canvas);
     41     SkBitmap* getBitmapFromCanvas(SkCanvas* canvas);
     42 
     43     // TODO probably want to make this configurable
     44     static const int kImageWidth;
     45     static const int kImageHeight;
     46 
     47     UploadContext* fUploadContext;
     48     SkAutoTUnref<SkPicture> fPicture;
     49     SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
     50     SkAutoTDelete<GrContextFactory> fContextFactory;
     51     SkAutoTUnref<SkSurface> fSurface;
     52     UrlDataManager fUrlDataManager;
     53     bool fGPUEnabled;
     54 };
     55 
     56 #endif
     57 
     58