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

Side by Side Diff: src/gpu/GrGpu.h

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Rebasing. Created 4 years, 9 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/effects/SkColorCubeFilter.cpp ('k') | src/gpu/GrGpu.cpp » ('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 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 GrGpu_DEFINED 8 #ifndef GrGpu_DEFINED
9 #define GrGpu_DEFINED 9 #define GrGpu_DEFINED
10 10
11 #include "GrPipelineBuilder.h" 11 #include "GrPipelineBuilder.h"
12 #include "GrProgramDesc.h" 12 #include "GrProgramDesc.h"
13 #include "GrStencil.h" 13 #include "GrStencil.h"
14 #include "GrSwizzle.h" 14 #include "GrSwizzle.h"
15 #include "GrTextureParamsAdjuster.h" 15 #include "GrTextureParamsAdjuster.h"
16 #include "GrTypes.h"
16 #include "GrXferProcessor.h" 17 #include "GrXferProcessor.h"
17 #include "SkPath.h" 18 #include "SkPath.h"
19 #include "SkTArray.h"
18 20
19 class GrBatchTracker; 21 class GrBatchTracker;
20 class GrContext; 22 class GrContext;
21 class GrGLContext; 23 class GrGLContext;
22 class GrIndexBuffer; 24 class GrIndexBuffer;
23 class GrNonInstancedVertices; 25 class GrNonInstancedVertices;
24 class GrPath; 26 class GrPath;
25 class GrPathRange; 27 class GrPathRange;
26 class GrPathRenderer; 28 class GrPathRenderer;
27 class GrPathRendererChain; 29 class GrPathRendererChain;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |= state; } 77 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |= state; }
76 78
77 /** 79 /**
78 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can 80 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can
79 * be used as a render target by calling GrTexture::asRenderTarget(). Not al l 81 * be used as a render target by calling GrTexture::asRenderTarget(). Not al l
80 * pixel configs can be used as render targets. Support for configs as textu res 82 * pixel configs can be used as render targets. Support for configs as textu res
81 * or render targets can be checked using GrCaps. 83 * or render targets can be checked using GrCaps.
82 * 84 *
83 * @param desc describes the texture to be created. 85 * @param desc describes the texture to be created.
84 * @param budgeted does this texture count against the resource cache bud get? 86 * @param budgeted does this texture count against the resource cache bud get?
85 * @param srcData texel data to load texture. Begins with full-size 87 * @param texels array of mipmap levels containing texel data to load.
86 * palette data for paletted textures. For compressed 88 * Each level begins with full-size palette data for pale tted textures.
87 * formats it contains the compressed pixel data. Otherwi se, 89 * For compressed formats the level contains the compress ed pixel data.
88 * it contains width*height texels. If nullptr texture da ta 90 * Otherwise, it contains width*height texels. If there i s only one
89 * is uninitialized. 91 * element and it contains nullptr fPixels, texture data is
90 * @param rowBytes the number of bytes between consecutive rows. Zero 92 * uninitialized.
91 * means rows are tightly packed. This field is ignored 93 * @return The texture object if successful, otherwise nullptr.
92 * for compressed formats. 94 */
95 GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
96 const SkTArray<GrMipLevel>& texels);
97
98 /**
99 * This function is a shim which creates a SkTArGrMipLevell> of size 1.
100 * It then calls createTexture with that SkTArray.
93 * 101 *
94 * @return The texture object if successful, otherwise nullptr. 102 * @param srcData texel data to load texture. Begins with full-size
103 * palette data for paletted texture. For compressed
104 * formats it contains the compressed pixel data. Otherwise,
105 * it contains width*height texels. If nullptr texture data
106 * is uninitialized.
107 * @param rowBytes the number of bytes between consecutive rows. Zero
108 * means rows are tightly packed. This field is ignored
109 * for compressed pixel formats.
110 * @return The texture object if successful, otherwise, nullptr.
95 */ 111 */
96 GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, 112 GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
97 const void* srcData, size_t rowBytes); 113 const void* srcData, size_t rowBytes);
98 114
99 /** 115 /**
100 * Implements GrTextureProvider::wrapBackendTexture 116 * Implements GrTextureProvider::wrapBackendTexture
101 */ 117 */
102 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); 118 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership);
103 119
104 /** 120 /**
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 269
254 /** 270 /**
255 * Updates the pixels in a rectangle of a surface. 271 * Updates the pixels in a rectangle of a surface.
256 * 272 *
257 * @param surface The surface to write to. 273 * @param surface The surface to write to.
258 * @param left left edge of the rectangle to write (inclusive) 274 * @param left left edge of the rectangle to write (inclusive)
259 * @param top top edge of the rectangle to write (inclusive) 275 * @param top top edge of the rectangle to write (inclusive)
260 * @param width width of rectangle to write in pixels. 276 * @param width width of rectangle to write in pixels.
261 * @param height height of rectangle to write in pixels. 277 * @param height height of rectangle to write in pixels.
262 * @param config the pixel config of the source buffer 278 * @param config the pixel config of the source buffer
263 * @param buffer memory to read pixels from 279 * @param texels array of mipmap levels containing texture data
264 * @param rowBytes number of bytes between consecutive rows. Zero
265 * means rows are tightly packed.
266 */ 280 */
267 bool writePixels(GrSurface* surface, 281 bool writePixels(GrSurface* surface,
268 int left, int top, int width, int height, 282 int left, int top, int width, int height,
283 GrPixelConfig config,
284 const SkTArray<GrMipLevel>& texels);
285
286 /**
287 * This function is a shim which creates a SkTArray<GrMipLevel> of size 1.
288 * It then calls writePixels with that SkTArray.
289 *
290 * @param buffer memory to read pixels from.
291 * @param rowBytes number of bytes between consecutive rows. Zero
292 * means rows are tightly packed.
293 */
294 bool writePixels(GrSurface* surface,
295 int left, int top, int width, int height,
269 GrPixelConfig config, const void* buffer, 296 GrPixelConfig config, const void* buffer,
270 size_t rowBytes); 297 size_t rowBytes);
271 298
272 /** 299 /**
273 * Updates the pixels in a rectangle of a surface using a GrTransferBuffer 300 * Updates the pixels in a rectangle of a surface using a GrTransferBuffer
274 * 301 *
275 * @param surface The surface to write to. 302 * @param surface The surface to write to.
276 * @param left left edge of the rectangle to write (inclusive) 303 * @param left left edge of the rectangle to write (inclusive)
277 * @param top top edge of the rectangle to write (inclusive) 304 * @param top top edge of the rectangle to write (inclusive)
278 * @param width width of rectangle to write in pixels. 305 * @param width width of rectangle to write in pixels.
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 virtual void onResetContext(uint32_t resetBits) = 0; 530 virtual void onResetContext(uint32_t resetBits) = 0;
504 531
505 // Called before certain draws in order to guarantee coherent results from d st reads. 532 // Called before certain draws in order to guarantee coherent results from d st reads.
506 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; 533 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0;
507 534
508 // overridden by backend-specific derived class to create objects. 535 // overridden by backend-specific derived class to create objects.
509 // Texture size and sample size will have already been validated in base cla ss before 536 // Texture size and sample size will have already been validated in base cla ss before
510 // onCreateTexture/CompressedTexture are called. 537 // onCreateTexture/CompressedTexture are called.
511 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, 538 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc,
512 GrGpuResource::LifeCycle lifeCycle, 539 GrGpuResource::LifeCycle lifeCycle,
513 const void* srcData, size_t rowBytes) = 0 ; 540 const SkTArray<GrMipLevel>& texels) = 0;
514 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, 541 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
515 GrGpuResource::LifeCycle lifeCy cle, 542 GrGpuResource::LifeCycle lifeCy cle,
516 const void* srcData) = 0; 543 const SkTArray<GrMipLevel>& tex els) = 0;
544
517 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO wnership) = 0; 545 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO wnership) = 0;
518 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&, 546 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&,
519 GrWrapOwnership) = 0; 547 GrWrapOwnership) = 0;
520 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe xtureDesc&, 548 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe xtureDesc&,
521 GrWrapOwnership) = 0; 549 GrWrapOwnership) = 0;
522 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; 550 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0;
523 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; 551 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0;
524 virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType t ype) = 0; 552 virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType t ype) = 0;
525 553
526 // overridden by backend-specific derived class to perform the clear. 554 // overridden by backend-specific derived class to perform the clear.
(...skipping 21 matching lines...) Expand all
548 virtual bool onReadPixels(GrSurface*, 576 virtual bool onReadPixels(GrSurface*,
549 int left, int top, 577 int left, int top,
550 int width, int height, 578 int width, int height,
551 GrPixelConfig, 579 GrPixelConfig,
552 void* buffer, 580 void* buffer,
553 size_t rowBytes) = 0; 581 size_t rowBytes) = 0;
554 582
555 // overridden by backend-specific derived class to perform the surface write 583 // overridden by backend-specific derived class to perform the surface write
556 virtual bool onWritePixels(GrSurface*, 584 virtual bool onWritePixels(GrSurface*,
557 int left, int top, int width, int height, 585 int left, int top, int width, int height,
558 GrPixelConfig config, const void* buffer, 586 GrPixelConfig config,
559 size_t rowBytes) = 0; 587 const SkTArray<GrMipLevel>& texels) = 0;
560 588
561 // overridden by backend-specific derived class to perform the surface write 589 // overridden by backend-specific derived class to perform the surface write
562 virtual bool onTransferPixels(GrSurface*, 590 virtual bool onTransferPixels(GrSurface*,
563 int left, int top, int width, int height, 591 int left, int top, int width, int height,
564 GrPixelConfig config, GrTransferBuffer* buffer , 592 GrPixelConfig config, GrTransferBuffer* buffer ,
565 size_t offset, size_t rowBytes) = 0; 593 size_t offset, size_t rowBytes) = 0;
566 594
567 // overridden by backend-specific derived class to perform the resolve 595 // overridden by backend-specific derived class to perform the resolve
568 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; 596 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0;
569 597
(...skipping 12 matching lines...) Expand all
582 ResetTimestamp fResetTi mestamp; 610 ResetTimestamp fResetTi mestamp;
583 uint32_t fResetBi ts; 611 uint32_t fResetBi ts;
584 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. 612 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu.
585 GrContext* fContext ; 613 GrContext* fContext ;
586 614
587 friend class GrPathRendering; 615 friend class GrPathRendering;
588 typedef SkRefCnt INHERITED; 616 typedef SkRefCnt INHERITED;
589 }; 617 };
590 618
591 #endif 619 #endif
OLDNEW
« no previous file with comments | « src/effects/SkColorCubeFilter.cpp ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698