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

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

Issue 13428004: Add GrDrawTarget::copySurface. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add asserts Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/gpu/GrDrawTarget.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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef GrDrawTarget_DEFINED 10 #ifndef GrDrawTarget_DEFINED
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 * GrVertexLayout. The data in the array is consumed at the time that 132 * GrVertexLayout. The data in the array is consumed at the time that
133 * set*SourceToArray is called and subsequent edits to the array will not 133 * set*SourceToArray is called and subsequent edits to the array will not
134 * be reflected in draws. 134 * be reflected in draws.
135 * 135 *
136 * 2. Reserve. This is most useful when the caller has data it must 136 * 2. Reserve. This is most useful when the caller has data it must
137 * transform before drawing and is not long-lived. The caller requests 137 * transform before drawing and is not long-lived. The caller requests
138 * that the draw target make room for some amount of vertex and/or index 138 * that the draw target make room for some amount of vertex and/or index
139 * data. The target provides ptrs to hold the vertex and/or index data. 139 * data. The target provides ptrs to hold the vertex and/or index data.
140 * 140 *
141 * The data is writable up until the next drawIndexed, drawNonIndexed, 141 * The data is writable up until the next drawIndexed, drawNonIndexed,
142 * drawIndexedInstances, or pushGeometrySource. At this point the data is 142 * drawIndexedInstances, drawRect, copySurface, or pushGeometrySource. At
143 * frozen and the ptrs are no longer valid. 143 * this point the data is frozen and the ptrs are no longer valid.
144 * 144 *
145 * Where the space is allocated and how it is uploaded to the GPU is 145 * Where the space is allocated and how it is uploaded to the GPU is
146 * subclass-dependent. 146 * subclass-dependent.
147 * 147 *
148 * 3. Vertex and Index Buffers. This is most useful for geometry that will 148 * 3. Vertex and Index Buffers. This is most useful for geometry that will
149 * is long-lived. When the data in the buffer is consumed depends on the 149 * is long-lived. When the data in the buffer is consumed depends on the
150 * GrDrawTarget subclass. For deferred subclasses the caller has to 150 * GrDrawTarget subclass. For deferred subclasses the caller has to
151 * guarantee that the data is still available in the buffers at playback. 151 * guarantee that the data is still available in the buffers at playback.
152 * (TODO: Make this more automatic as we have done for read/write pixels) 152 * (TODO: Make this more automatic as we have done for read/write pixels)
153 * 153 *
154 * The size of each vertex is determined by querying the current GrDrawState . 154 * The size of each vertex is determined by querying the current GrDrawState .
155 */ 155 */
156 156
157 /** 157 /**
158 * Reserves space for vertices and/or indices. Zero can be specifed as 158 * Reserves space for vertices and/or indices. Zero can be specifed as
159 * either the vertex or index count if the caller desires to only reserve 159 * either the vertex or index count if the caller desires to only reserve
160 * space for only indices or only vertices. If zero is specifed for 160 * space for only indices or only vertices. If zero is specifed for
161 * vertexCount then the vertex source will be unmodified and likewise for 161 * vertexCount then the vertex source will be unmodified and likewise for
162 * indexCount. 162 * indexCount.
163 * 163 *
164 * If the function returns true then the reserve suceeded and the vertices 164 * If the function returns true then the reserve suceeded and the vertices
165 * and indices pointers will point to the space created. 165 * and indices pointers will point to the space created.
166 * 166 *
167 * If the target cannot make space for the request then this function will 167 * If the target cannot make space for the request then this function will
168 * return false. If vertexCount was non-zero then upon failure the vertex 168 * return false. If vertexCount was non-zero then upon failure the vertex
169 * source is reset and likewise for indexCount. 169 * source is reset and likewise for indexCount.
170 * 170 *
171 * The pointers to the space allocated for vertices and indices remain valid 171 * The pointers to the space allocated for vertices and indices remain valid
172 * until a drawIndexed, drawNonIndexed, drawIndexedInstances, or push/ 172 * until a drawIndexed, drawNonIndexed, drawIndexedInstances, drawRect,
173 * popGeomtrySource is called. At that point logically a snapshot of the 173 * copySurface, or push/popGeomtrySource is called. At that point logically a
174 * data is made and the pointers are invalid. 174 * snapshot of the data is made and the pointers are invalid.
175 * 175 *
176 * @param vertexCount the number of vertices to reserve space for. Can be 176 * @param vertexCount the number of vertices to reserve space for. Can be
177 * 0. Vertex size is queried from the current GrDrawStat e. 177 * 0. Vertex size is queried from the current GrDrawStat e.
178 * @param indexCount the number of indices to reserve space for. Can be 0. 178 * @param indexCount the number of indices to reserve space for. Can be 0.
179 * @param vertices will point to reserved vertex space if vertexCount is 179 * @param vertices will point to reserved vertex space if vertexCount is
180 * non-zero. Illegal to pass NULL if vertexCount > 0. 180 * non-zero. Illegal to pass NULL if vertexCount > 0.
181 * @param indices will point to reserved index space if indexCount is 181 * @param indices will point to reserved index space if indexCount is
182 * non-zero. Illegal to pass NULL if indexCount > 0. 182 * non-zero. Illegal to pass NULL if indexCount > 0.
183 */ 183 */
184 bool reserveVertexAndIndexSpace(int vertexCount, 184 bool reserveVertexAndIndexSpace(int vertexCount,
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 const SkRect* devBounds = NULL); 399 const SkRect* devBounds = NULL);
400 400
401 /** 401 /**
402 * Clear the current render target if one isn't passed in. Ignores the 402 * Clear the current render target if one isn't passed in. Ignores the
403 * clip and all other draw state (blend mode, stages, etc). Clears the 403 * clip and all other draw state (blend mode, stages, etc). Clears the
404 * whole thing if rect is NULL, otherwise just the rect. 404 * whole thing if rect is NULL, otherwise just the rect.
405 */ 405 */
406 virtual void clear(const GrIRect* rect, 406 virtual void clear(const GrIRect* rect,
407 GrColor color, 407 GrColor color,
408 GrRenderTarget* renderTarget = NULL) = 0; 408 GrRenderTarget* renderTarget = NULL) = 0;
409
410 /**
411 * Copies a pixel rectangle from one surface to another. This call may final ize
412 * reserved vertex/index data (as though a draw call was made). The src pixe ls
413 * copied are specified by srcRect. They are copied to a rect of the same
414 * size in dst with top left at dstPoint. If the src rect is clipped by the
415 * src bounds then pixel values in the dst rect corresponding to area clipp ed
416 * by the src rect are not overwritten. This method can fail and return fals e
417 * depending on the type of surface, configs, etc, and the backend-specific
418 * limitations. If rect is clipped out entirely by the src or dst bounds the n
419 * true is returned since there is no actual copy necessary to succeed.
420 */
421 bool copySurface(GrSurface* dst,
422 GrSurface* src,
423 const SkIRect& srcRect,
424 const SkIPoint& dstPoint);
409 425
410 /** 426 /**
411 * Release any resources that are cached but not currently in use. This 427 * Release any resources that are cached but not currently in use. This
412 * is intended to give an application some recourse when resources are low. 428 * is intended to give an application some recourse when resources are low.
413 */ 429 */
414 virtual void purgeResources() {}; 430 virtual void purgeResources() {};
415 431
416 /** 432 /**
417 * For subclass internal use to invoke a call to onDraw(). See DrawInfo belo w. 433 * For subclass internal use to invoke a call to onDraw(). See DrawInfo belo w.
418 */ 434 */
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 case kArray_GeometrySrcType: 625 case kArray_GeometrySrcType:
610 return src.fIndexCount; 626 return src.fIndexCount;
611 case kBuffer_GeometrySrcType: 627 case kBuffer_GeometrySrcType:
612 return src.fIndexBuffer->sizeInBytes() / sizeof(uint16_t); 628 return src.fIndexBuffer->sizeInBytes() / sizeof(uint16_t);
613 default: 629 default:
614 GrCrash("Unexpected Index Source."); 630 GrCrash("Unexpected Index Source.");
615 return 0; 631 return 0;
616 } 632 }
617 } 633 }
618 634
635 // This method is called by copySurface The srcRect is guaranteed to be ent irely within the
636 // src bounds. Likewise, the dst rect implied by dstPoint and srcRect's widt h and height falls
637 // entirely within the dst. The default implementation will draw a rect from the src to the
638 // dst if the src is a texture and the dst is a render target and fail other wise.
639 virtual bool onCopySurface(GrSurface* dst,
640 GrSurface* src,
641 const SkIRect& srcRect,
642 const SkIPoint& dstPoint);
643
644 // Called to determine whether an onCopySurface call would succeed or not. T his is useful for
645 // proxy subclasses to test whether the copy would succeed without executing it yet. Derived
646 // classes must keep this consistent with their implementation of onCopySurf ace(). The inputs
647 // are the same as onCopySurface(), i.e. srcRect and dstPoint are clipped to be inside the src
648 // and dst bounds.
649 virtual bool canCopySurface(GrSurface* dst,
650 GrSurface* src,
651 const SkIRect& srcRect,
652 const SkIPoint& dstPoint);
653
619 GrContext* getContext() { return fContext; } 654 GrContext* getContext() { return fContext; }
620 const GrContext* getContext() const { return fContext; } 655 const GrContext* getContext() const { return fContext; }
621 656
622 // A subclass may override this function if it wishes to be notified when th e clip is changed. 657 // A subclass may override this function if it wishes to be notified when th e clip is changed.
623 // The override should call INHERITED::clipWillBeSet(). 658 // The override should call INHERITED::clipWillBeSet().
624 virtual void clipWillBeSet(const GrClipData* clipData); 659 virtual void clipWillBeSet(const GrClipData* clipData);
625 660
626 // subclasses must call this in their destructors to ensure all vertex 661 // subclasses must call this in their destructors to ensure all vertex
627 // and index sources have been released (including those held by 662 // and index sources have been released (including those held by
628 // pushGeometrySource()) 663 // pushGeometrySource())
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 const GrClipData* fClip; 812 const GrClipData* fClip;
778 GrDrawState* fDrawState; 813 GrDrawState* fDrawState;
779 GrDrawState fDefaultDraw State; 814 GrDrawState fDefaultDraw State;
780 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar get. 815 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar get.
781 GrContext* fContext; 816 GrContext* fContext;
782 817
783 typedef GrRefCnt INHERITED; 818 typedef GrRefCnt INHERITED;
784 }; 819 };
785 820
786 #endif 821 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698