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

Side by Side Diff: include/gpu/GrSurface.h

Issue 596053002: Make "priv" classes for GrTexure and GrSurface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add SK_API Created 6 years, 2 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 | « include/gpu/GrContext.h ('k') | include/gpu/GrTexture.h » ('j') | 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 2012 Google Inc. 2 * Copyright 2012 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 8
9 #ifndef GrSurface_DEFINED 9 #ifndef GrSurface_DEFINED
10 #define GrSurface_DEFINED 10 #define GrSurface_DEFINED
11 11
12 #include "GrTypes.h" 12 #include "GrTypes.h"
13 #include "GrGpuResource.h" 13 #include "GrGpuResource.h"
14 #include "SkImageInfo.h"
14 #include "SkRect.h" 15 #include "SkRect.h"
15 16
17 class GrRenderTarget;
18 class GrSurfacePriv;
16 class GrTexture; 19 class GrTexture;
17 class GrRenderTarget;
18 struct SkImageInfo;
19 20
20 class GrSurface : public GrGpuResource { 21 class GrSurface : public GrGpuResource {
21 public: 22 public:
22 SK_DECLARE_INST_COUNT(GrSurface); 23 SK_DECLARE_INST_COUNT(GrSurface);
23 24
24 /** 25 /**
25 * Retrieves the width of the surface. 26 * Retrieves the width of the surface.
26 * 27 *
27 * @return the width in texels 28 * @return the width in texels
28 */ 29 */
(...skipping 23 matching lines...) Expand all
52 * if client asked us to render to a target that has a pixel 53 * if client asked us to render to a target that has a pixel
53 * config that isn't equivalent with one of our configs. 54 * config that isn't equivalent with one of our configs.
54 */ 55 */
55 GrPixelConfig config() const { return fDesc.fConfig; } 56 GrPixelConfig config() const { return fDesc.fConfig; }
56 57
57 /** 58 /**
58 * Return the descriptor describing the surface 59 * Return the descriptor describing the surface
59 */ 60 */
60 const GrTextureDesc& desc() const { return fDesc; } 61 const GrTextureDesc& desc() const { return fDesc; }
61 62
62 SkImageInfo info() const;
63
64 /** 63 /**
65 * @return the texture associated with the surface, may be NULL. 64 * @return the texture associated with the surface, may be NULL.
66 */ 65 */
67 virtual GrTexture* asTexture() = 0; 66 virtual GrTexture* asTexture() = 0;
68 virtual const GrTexture* asTexture() const = 0; 67 virtual const GrTexture* asTexture() const = 0;
69 68
70 /** 69 /**
71 * @return the render target underlying this surface, may be NULL. 70 * @return the render target underlying this surface, may be NULL.
72 */ 71 */
73 virtual GrRenderTarget* asRenderTarget() = 0; 72 virtual GrRenderTarget* asRenderTarget() = 0;
74 virtual const GrRenderTarget* asRenderTarget() const = 0; 73 virtual const GrRenderTarget* asRenderTarget() const = 0;
75 74
76 /** 75 /**
77 * Checks whether this GrSurface refers to the same GPU object as other. Thi s
78 * catches the case where a GrTexture and GrRenderTarget refer to the same
79 * GPU memory.
80 */
81 bool isSameAs(const GrSurface* other) const {
82 const GrRenderTarget* thisRT = this->asRenderTarget();
83 if (thisRT) {
84 return thisRT == other->asRenderTarget();
85 } else {
86 const GrTexture* thisTex = this->asTexture();
87 SkASSERT(thisTex); // We must be one or the other
88 return thisTex == other->asTexture();
89 }
90 }
91
92 /**
93 * Reads a rectangle of pixels from the surface. 76 * Reads a rectangle of pixels from the surface.
94 * @param left left edge of the rectangle to read (inclusive) 77 * @param left left edge of the rectangle to read (inclusive)
95 * @param top top edge of the rectangle to read (inclusive) 78 * @param top top edge of the rectangle to read (inclusive)
96 * @param width width of rectangle to read in pixels. 79 * @param width width of rectangle to read in pixels.
97 * @param height height of rectangle to read in pixels. 80 * @param height height of rectangle to read in pixels.
98 * @param config the pixel config of the destination buffer 81 * @param config the pixel config of the destination buffer
99 * @param buffer memory to read the rectangle into. 82 * @param buffer memory to read the rectangle into.
100 * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly 83 * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
101 * packed. 84 * packed.
102 * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum. 85 * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
(...skipping 19 matching lines...) Expand all
122 * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly 105 * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
123 * packed. 106 * packed.
124 * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum. 107 * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
125 */ 108 */
126 virtual void writePixels(int left, int top, int width, int height, 109 virtual void writePixels(int left, int top, int width, int height,
127 GrPixelConfig config, 110 GrPixelConfig config,
128 const void* buffer, 111 const void* buffer,
129 size_t rowBytes = 0, 112 size_t rowBytes = 0,
130 uint32_t pixelOpsFlags = 0) = 0; 113 uint32_t pixelOpsFlags = 0) = 0;
131 114
132 /** 115 /** Access methods that are only to be used within Skia code. */
133 * Write the contents of the surface to a PNG. Returns true if successful. 116 inline GrSurfacePriv surfacePriv();
134 * @param filename Full path to desired file 117 inline const GrSurfacePriv surfacePriv() const;
135 */ 118
119 protected:
120 // Methods made available via GrSurfacePriv
121 SkImageInfo info() const;
136 bool savePixels(const char* filename); 122 bool savePixels(const char* filename);
137
138 bool hasPendingRead() const; 123 bool hasPendingRead() const;
139 bool hasPendingWrite() const; 124 bool hasPendingWrite() const;
140 bool hasPendingIO() const; 125 bool hasPendingIO() const;
126 bool isSameAs(const GrSurface* other) const;
141 127
142 protected: 128 // Provides access to methods that should be public within Skia code.
129 friend class GrSurfacePriv;
130
143 GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc) 131 GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
144 : INHERITED(gpu, isWrapped) 132 : INHERITED(gpu, isWrapped)
145 , fDesc(desc) { 133 , fDesc(desc) {
146 } 134 }
147 135
148 GrTextureDesc fDesc; 136 GrTextureDesc fDesc;
149 137
150 private: 138 private:
151 typedef GrGpuResource INHERITED; 139 typedef GrGpuResource INHERITED;
152 }; 140 };
153 141
154 #endif // GrSurface_DEFINED 142 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | include/gpu/GrTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698