Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 SkSpecialSurface_DEFINED | |
| 9 #define SkSpecialSurface_DEFINED | |
| 10 | |
| 11 #include "SkRefCnt.h" | |
| 12 #include "SkSurfaceProps.h" | |
| 13 | |
| 14 class GrContext; | |
| 15 struct GrSurfaceDesc; | |
| 16 class SkCanvas; | |
| 17 struct SkImageInfo; | |
| 18 class SkSpecialImage; | |
| 19 | |
| 20 /** | |
| 21 * SkSpecialSurface is a restricted form of SkSurface solely for internal use. I t differs | |
| 22 * from SkSurface in that: | |
| 23 * - it can be backed by GrTextures larger than [ fWidth, fHeight ] | |
| 24 * - it can't be used for tiling | |
| 25 * - it becomes inactive once a snapshot of it is taken (i.e., no copy-on-wr ite) | |
| 26 * - it has no generation ID | |
| 27 */ | |
| 28 class SkSpecialSurface : public SkRefCnt { | |
| 29 public: | |
| 30 const SkSurfaceProps& props() const { return fProps; } | |
| 31 int width() const { return fWidth; } | |
| 32 int height() const { return fHeight; } | |
| 33 | |
| 34 /** | |
| 35 * Return a canvas that will draw into this surface. This will always | |
| 36 * return the same canvas for a given surface, and is managed/owned by the | |
| 37 * surface. | |
| 38 * | |
| 39 * The canvas will be invalid after 'newImageSnapshot' is called. | |
| 40 */ | |
| 41 SkCanvas* getCanvas(); | |
| 42 | |
| 43 /** | |
| 44 * Returns an image of the current state of the surface pixels up to this | |
| 45 * point. The canvas returned by 'getCanvas' becomes invalidated by this | |
| 46 * call and no more drawing to this surface is allowed. | |
| 47 */ | |
| 48 SkSpecialImage* newImageSnapshot(); | |
| 49 | |
| 50 /** | |
| 51 * Allocate a new GPU-backed SkSpecialSurface. If the requested surface can not | |
| 52 * be created, nullptr will be returned. | |
| 53 */ | |
| 54 static SkSpecialSurface* New(GrContext*, const GrSurfaceDesc&, const SkSurfa ceProps* = nullptr); | |
|
reed1
2016/01/14 13:52:55
I suggest we make the names back-end specific, jus
robertphillips
2016/01/14 19:58:55
Done.
| |
| 55 | |
| 56 /** | |
| 57 * Return a new CPU-backed surface, with the memory for the pixels automati cally | |
| 58 * allocated. | |
| 59 * | |
| 60 * If the requested surface cannot be created, or the request is not a | |
| 61 * supported configuration, nullptr will be returned. | |
| 62 */ | |
| 63 static SkSpecialSurface* New(const SkImageInfo&, const SkSurfaceProps* = nul lptr); | |
| 64 | |
| 65 protected: | |
| 66 SkSpecialSurface(int width, int height, const SkSurfaceProps*); | |
| 67 | |
| 68 private: | |
| 69 const SkSurfaceProps fProps; | |
| 70 const int fWidth; | |
| 71 const int fHeight; | |
| 72 | |
| 73 typedef SkRefCnt INHERITED; | |
| 74 }; | |
| 75 | |
| 76 #endif | |
| OLD | NEW |