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

Side by Side Diff: src/core/SkSpecialSurface.h

Issue 1579323002: Add SkSpecialImage & SkSpecialSurface classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix another no-gpu issue Created 4 years, 10 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 | « src/core/SkSpecialImage.cpp ('k') | src/core/SkSpecialSurface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
32 int width() const { return fSubset.width(); }
33 int height() const { return fSubset.height(); }
34
35 /**
36 * Return a canvas that will draw into this surface. This will always
37 * return the same canvas for a given surface, and is managed/owned by the
38 * surface.
39 *
40 * The canvas will be invalid after 'newImageSnapshot' is called.
41 */
42 SkCanvas* getCanvas();
43
44 /**
45 * Returns an image of the current state of the surface pixels up to this
46 * point. The canvas returned by 'getCanvas' becomes invalidated by this
47 * call and no more drawing to this surface is allowed.
48 */
49 SkSpecialImage* newImageSnapshot();
50
51 /**
52 * Use an existing (renderTarget-capable) GrTexture as the backing store.
53 */
54 static SkSpecialSurface* NewFromTexture(const SkIRect& subset, GrTexture*,
55 const SkSurfaceProps* = nullptr);
56
57 /**
58 * Allocate a new GPU-backed SkSpecialSurface. If the requested surface can not
59 * be created, nullptr will be returned.
60 */
61 static SkSpecialSurface* NewRenderTarget(GrContext*, const GrSurfaceDesc&,
62 const SkSurfaceProps* = nullptr);
63
64 /**
65 * Use and existing SkBitmap as the backing store.
66 */
67 static SkSpecialSurface* NewFromBitmap(const SkIRect& subset, SkBitmap& bm,
68 const SkSurfaceProps* = nullptr);
69
70 /**
71 * Return a new CPU-backed surface, with the memory for the pixels automati cally
72 * allocated.
73 *
74 * If the requested surface cannot be created, or the request is not a
75 * supported configuration, nullptr will be returned.
76 */
77 static SkSpecialSurface* NewRaster(const SkImageInfo&, const SkSurfaceProps* = nullptr);
78
79 protected:
80 SkSpecialSurface(const SkIRect& subset, const SkSurfaceProps*);
81
82 // For testing only
83 friend class TestingSpecialSurfaceAccess;
84 const SkIRect& subset() const { return fSubset; }
85
86 private:
87 const SkSurfaceProps fProps;
88 const SkIRect fSubset;
89
90 typedef SkRefCnt INHERITED;
91 };
92
93 #endif
OLDNEW
« no previous file with comments | « src/core/SkSpecialImage.cpp ('k') | src/core/SkSpecialSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698