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

Side by Side Diff: src/gpu/gl/GrGLGpu.h

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Fixing rebase errors and cleaning up. 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 #ifndef GrGLGpu_DEFINED 8 #ifndef GrGLGpu_DEFINED
9 #define GrGLGpu_DEFINED 9 #define GrGLGpu_DEFINED
10 10
11 #include "GrGLContext.h" 11 #include "GrGLContext.h"
12 #include "GrGLIRect.h" 12 #include "GrGLIRect.h"
13 #include "GrGLIndexBuffer.h" 13 #include "GrGLIndexBuffer.h"
14 #include "GrGLPathRendering.h" 14 #include "GrGLPathRendering.h"
15 #include "GrGLProgram.h" 15 #include "GrGLProgram.h"
16 #include "GrGLRenderTarget.h" 16 #include "GrGLRenderTarget.h"
17 #include "GrGLStencilAttachment.h" 17 #include "GrGLStencilAttachment.h"
18 #include "GrGLTexture.h" 18 #include "GrGLTexture.h"
19 #include "GrGLTransferBuffer.h" 19 #include "GrGLTransferBuffer.h"
20 #include "GrGLVertexArray.h" 20 #include "GrGLVertexArray.h"
21 #include "GrGLVertexBuffer.h" 21 #include "GrGLVertexBuffer.h"
22 #include "GrGpu.h" 22 #include "GrGpu.h"
23 #include "GrPipelineBuilder.h" 23 #include "GrPipelineBuilder.h"
24 #include "GrTypes.h"
24 #include "GrXferProcessor.h" 25 #include "GrXferProcessor.h"
26 #include "SkTArray.h"
25 #include "SkTypes.h" 27 #include "SkTypes.h"
26 28
27 class GrPipeline; 29 class GrPipeline;
28 class GrNonInstancedVertices; 30 class GrNonInstancedVertices;
29 class GrSwizzle; 31 class GrSwizzle;
30 32
31 #ifdef SK_DEVELOPER 33 #ifdef SK_DEVELOPER
32 #define PROGRAM_CACHE_STATS 34 #define PROGRAM_CACHE_STATS
33 #endif 35 #endif
34 36
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 140
139 private: 141 private:
140 GrGLGpu(GrGLContext* ctx, GrContext* context); 142 GrGLGpu(GrGLContext* ctx, GrContext* context);
141 143
142 // GrGpu overrides 144 // GrGpu overrides
143 void onResetContext(uint32_t resetBits) override; 145 void onResetContext(uint32_t resetBits) override;
144 146
145 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; 147 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override;
146 148
147 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc le lifeCycle, 149 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc le lifeCycle,
148 const void* srcData, size_t rowBytes) override; 150 const SkTArray<GrMipLevel>& texels) override;
149 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, 151 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
150 GrGpuResource::LifeCycle lifeCycle, 152 GrGpuResource::LifeCycle lifeCycle,
151 const void* srcData) override; 153 const SkTArray<GrMipLevel>& texels) ove rride;
154
152 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; 155 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override;
153 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; 156 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override;
154 GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType type) ove rride; 157 GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType type) ove rride;
155 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership ) override; 158 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership ) override;
156 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, 159 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
157 GrWrapOwnership) override; 160 GrWrapOwnership) override;
158 // Given a GrPixelConfig return the index into the stencil format array on G rGLCaps to a 161 // Given a GrPixelConfig return the index into the stencil format array on G rGLCaps to a
159 // compatible stencil format, or negative if there is no compatible stencil format. 162 // compatible stencil format, or negative if there is no compatible stencil format.
160 int getCompatibleStencilIndex(GrPixelConfig config); 163 int getCompatibleStencilIndex(GrPixelConfig config);
161 164
162 // If |desc.fTextureStorageAllocator| exists, use that to create the 165 // If |desc.fTextureStorageAllocator| exists, use that to create the
163 // texture. Otherwise, create the texture directly. 166 // texture. Otherwise, create the texture directly.
164 // Returns whether the texture is successfully created. On success, the 167 // Returns whether the texture is successfully created. On success, the
165 // result is stored in |info|. 168 // result is stored in |info|.
166 // The texture is populated with |srcData|, if it exists. 169 // The texture is populated with |texels|, if it exists.
167 // The texture parameters are cached in |initialTexParams|. 170 // The texture parameters are cached in |initialTexParams|.
168 bool createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info, 171 bool createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info,
169 bool renderTarget, const void* srcData, 172 bool renderTarget, GrGLTexture::TexParams* initialTex Params,
170 GrGLTexture::TexParams* initialTexParams, size_t rowB ytes); 173 const SkTArray<GrMipLevel>& texels);
171 bool createTextureExternalAllocatorImpl(const GrSurfaceDesc& desc, GrGLTextu reInfo* info, 174 bool createTextureExternalAllocatorImpl(const GrSurfaceDesc& desc, GrGLTextu reInfo* info,
172 const void* srcData, size_t rowBytes ); 175 const SkTArray<GrMipLevel>& texels);
173 176
174 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; 177 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override;
175 178
176 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli p) override; 179 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli p) override;
177 180
178 bool onMakeCopyForTextureParams(GrTexture*, const GrTextureParams&, 181 bool onMakeCopyForTextureParams(GrTexture*, const GrTextureParams&,
179 GrTextureProducer::CopyParams*) const overri de; 182 GrTextureProducer::CopyParams*) const overri de;
180 183
181 // Checks whether glReadPixels can be called to get pixel values in readConf ig from the 184 // Checks whether glReadPixels can be called to get pixel values in readConf ig from the
182 // render target. 185 // render target.
(...skipping 11 matching lines...) Expand all
194 197
195 bool onReadPixels(GrSurface*, 198 bool onReadPixels(GrSurface*,
196 int left, int top, 199 int left, int top,
197 int width, int height, 200 int width, int height,
198 GrPixelConfig, 201 GrPixelConfig,
199 void* buffer, 202 void* buffer,
200 size_t rowBytes) override; 203 size_t rowBytes) override;
201 204
202 bool onWritePixels(GrSurface*, 205 bool onWritePixels(GrSurface*,
203 int left, int top, int width, int height, 206 int left, int top, int width, int height,
204 GrPixelConfig config, const void* buffer, 207 GrPixelConfig config,
205 size_t rowBytes) override; 208 const SkTArray<GrMipLevel>& texels) override;
206 209
207 bool onTransferPixels(GrSurface*, 210 bool onTransferPixels(GrSurface*,
208 int left, int top, int width, int height, 211 int left, int top, int width, int height,
209 GrPixelConfig config, GrTransferBuffer* buffer, 212 GrPixelConfig config, GrTransferBuffer* buffer,
210 size_t offset, size_t rowBytes) override; 213 size_t offset, size_t rowBytes) override;
211 214
212 void onResolveRenderTarget(GrRenderTarget* target) override; 215 void onResolveRenderTarget(GrRenderTarget* target) override;
213 216
214 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; 217 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override;
215 218
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 enum UploadType { 338 enum UploadType {
336 kNewTexture_UploadType, // we are creating a new texture 339 kNewTexture_UploadType, // we are creating a new texture
337 kWrite_UploadType, // we are using TexSubImage2D to copy data to an existing texture 340 kWrite_UploadType, // we are using TexSubImage2D to copy data to an existing texture
338 kTransfer_UploadType, // we are using a transfer buffer to copy dat a 341 kTransfer_UploadType, // we are using a transfer buffer to copy dat a
339 }; 342 };
340 bool uploadTexData(const GrSurfaceDesc& desc, 343 bool uploadTexData(const GrSurfaceDesc& desc,
341 GrGLenum target, 344 GrGLenum target,
342 UploadType uploadType, 345 UploadType uploadType,
343 int left, int top, int width, int height, 346 int left, int top, int width, int height,
344 GrPixelConfig dataConfig, 347 GrPixelConfig dataConfig,
345 const void* data, 348 const SkTArray<GrMipLevel>& texels);
346 size_t rowBytes);
347 349
348 // helper for onCreateCompressedTexture. If width and height are 350 // helper for onCreateCompressedTexture. If width and height are
349 // set to -1, then this function will use desc.fWidth and desc.fHeight 351 // set to -1, then this function will use desc.fWidth and desc.fHeight
350 // for the size of the data. The isNewTexture flag should be set to true 352 // for the size of the data. The isNewTexture flag should be set to true
351 // whenever a new texture needs to be created. Otherwise, we assume that 353 // whenever a new texture needs to be created. Otherwise, we assume that
352 // the texture is already in GPU memory and that it's going to be updated 354 // the texture is already in GPU memory and that it's going to be updated
353 // with new data. 355 // with new data.
354 bool uploadCompressedTexData(const GrSurfaceDesc& desc, 356 bool uploadCompressedTexData(const GrSurfaceDesc& desc,
355 GrGLenum target, 357 GrGLenum target,
356 const void* data, 358 const SkTArray<GrMipLevel>& texels,
357 UploadType uploadType = kNewTexture_UploadType, 359 UploadType uploadType = kNewTexture_UploadType,
358 int left = 0, int top = 0, 360 int left = 0, int top = 0,
359 int width = -1, int height = -1); 361 int width = -1, int height = -1);
360 362
361 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl e lifeCycle, 363 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl e lifeCycle,
362 const GrGLTextureInfo& texInfo, GrGLRenderTar get::IDDesc*); 364 const GrGLTextureInfo& texInfo, GrGLRenderTar get::IDDesc*);
363 365
364 enum TempFBOTarget { 366 enum TempFBOTarget {
365 kSrc_TempFBOTarget, 367 kSrc_TempFBOTarget,
366 kDst_TempFBOTarget 368 kDst_TempFBOTarget
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } fPLSSetupProgram; 606 } fPLSSetupProgram;
605 607
606 bool fHWPLSEnabled; 608 bool fHWPLSEnabled;
607 bool fPLSHasBeenUsed; 609 bool fPLSHasBeenUsed;
608 610
609 typedef GrGpu INHERITED; 611 typedef GrGpu INHERITED;
610 friend class GrGLPathRendering; // For accessing setTextureUnit. 612 friend class GrGLPathRendering; // For accessing setTextureUnit.
611 }; 613 };
612 614
613 #endif 615 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698