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

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

Issue 1144433002: Move copy-surface-as-draw fallback to GrGLGpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@vares
Patch Set: remove incorrect assert Created 5 years, 7 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/gpu/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLGpu.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 GrGLGpu_DEFINED 8 #ifndef GrGLGpu_DEFINED
9 #define GrGLGpu_DEFINED 9 #define GrGLGpu_DEFINED
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 void notifyIndexBufferDelete(GrGLuint id) { 95 void notifyIndexBufferDelete(GrGLuint id) {
96 fHWGeometryState.notifyIndexBufferDelete(id); 96 fHWGeometryState.notifyIndexBufferDelete(id);
97 } 97 }
98 98
99 bool copySurface(GrSurface* dst, 99 bool copySurface(GrSurface* dst,
100 GrSurface* src, 100 GrSurface* src,
101 const SkIRect& srcRect, 101 const SkIRect& srcRect,
102 const SkIPoint& dstPoint) override; 102 const SkIPoint& dstPoint) override;
103 103
104 bool canCopySurface(const GrSurface* dst,
105 const GrSurface* src,
106 const SkIRect& srcRect,
107 const SkIPoint& dstPoint) override;
108
109 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; 104 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override;
110 105
111 void buildProgramDesc(GrProgramDesc*, 106 void buildProgramDesc(GrProgramDesc*,
112 const GrPrimitiveProcessor&, 107 const GrPrimitiveProcessor&,
113 const GrPipeline&, 108 const GrPipeline&,
114 const GrBatchTracker&) const override; 109 const GrBatchTracker&) const override;
115 110
116 private: 111 private:
117 // GrGpu overrides 112 // GrGpu overrides
118 void onResetContext(uint32_t resetBits) override; 113 void onResetContext(uint32_t resetBits) override;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt es gives the offset 171 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt es gives the offset
177 // an into the index buffer. It does not account for vertices.startIndex() b ut rather the start 172 // an into the index buffer. It does not account for vertices.startIndex() b ut rather the start
178 // index is relative to the returned offset. 173 // index is relative to the returned offset.
179 void setupGeometry(const GrPrimitiveProcessor&, 174 void setupGeometry(const GrPrimitiveProcessor&,
180 const GrNonInstancedVertices& vertices, 175 const GrNonInstancedVertices& vertices,
181 size_t* indexOffsetInBytes); 176 size_t* indexOffsetInBytes);
182 177
183 // Subclasses should call this to flush the blend state. 178 // Subclasses should call this to flush the blend state.
184 void flushBlend(const GrXferProcessor::BlendInfo& blendInfo); 179 void flushBlend(const GrXferProcessor::BlendInfo& blendInfo);
185 180
181 void copySurfaceAsDraw(GrSurface* dst,
182 GrSurface* src,
183 const SkIRect& srcRect,
184 const SkIPoint& dstPoint);
185 void copySurfaceAsCopyTexSubImage(GrSurface* dst,
186 GrSurface* src,
187 const SkIRect& srcRect,
188 const SkIPoint& dstPoint);
189 bool copySurfaceAsBlitFramebuffer(GrSurface* dst,
190 GrSurface* src,
191 const SkIRect& srcRect,
192 const SkIPoint& dstPoint);
193
186 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex t); } 194 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex t); }
187 195
188 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); 196 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
189 197
190 class ProgramCache : public ::SkNoncopyable { 198 class ProgramCache : public ::SkNoncopyable {
191 public: 199 public:
192 ProgramCache(GrGLGpu* gpu); 200 ProgramCache(GrGLGpu* gpu);
193 ~ProgramCache(); 201 ~ProgramCache();
194 202
195 void abandon(); 203 void abandon();
196 GrGLProgram* getProgram(const DrawArgs&); 204 GrGLProgram* refProgram(const DrawArgs&);
197 205
198 private: 206 private:
199 enum { 207 enum {
200 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new 208 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new
201 // shader before evicting from the cache. 209 // shader before evicting from the cache.
202 kMaxEntries = 128, 210 kMaxEntries = 128,
203 kHashBits = 6, 211 kHashBits = 6,
204 }; 212 };
205 213
206 struct Entry; 214 struct Entry;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 enum TempFBOTarget { 295 enum TempFBOTarget {
288 kSrc_TempFBOTarget, 296 kSrc_TempFBOTarget,
289 kDst_TempFBOTarget 297 kDst_TempFBOTarget
290 }; 298 };
291 299
292 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport, 300 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport,
293 TempFBOTarget tempFBOTarget); 301 TempFBOTarget tempFBOTarget);
294 302
295 void unbindTextureFromFBO(GrGLenum fboTarget); 303 void unbindTextureFromFBO(GrGLenum fboTarget);
296 304
305 void createCopyProgram();
306
297 GrGLContext fGLContext; 307 GrGLContext fGLContext;
298 308
299 // GL program-related state 309 // GL program-related state
300 ProgramCache* fProgramCache; 310 ProgramCache* fProgramCache;
301 SkAutoTUnref<GrGLProgram> fCurrentProgram;
302 311
303 /////////////////////////////////////////////////////////////////////////// 312 ///////////////////////////////////////////////////////////////////////////
304 ///@name Caching of GL State 313 ///@name Caching of GL State
305 ///@{ 314 ///@{
306 int fHWActiveTextureUnitIdx; 315 int fHWActiveTextureUnitIdx;
307 GrGLuint fHWProgramID; 316 GrGLuint fHWProgramID;
308 317
309 enum TriState { 318 enum TriState {
310 kNo_TriState, 319 kNo_TriState,
311 kYes_TriState, 320 kYes_TriState,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 /** 422 /**
414 * Binds the vertex array object that should be used to render from the vertex buffer. 423 * Binds the vertex array object that should be used to render from the vertex buffer.
415 * The vertex array is bound and its attrib array state object is return ed. The vertex 424 * The vertex array is bound and its attrib array state object is return ed. The vertex
416 * buffer is bound. The index buffer (if non-NULL) is bound to the verte x array. The 425 * buffer is bound. The index buffer (if non-NULL) is bound to the verte x array. The
417 * returned GrGLAttribArrayState should be used to set vertex attribute arrays. 426 * returned GrGLAttribArrayState should be used to set vertex attribute arrays.
418 */ 427 */
419 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, 428 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu,
420 const GrGLVertexBuffer* vbuffer, 429 const GrGLVertexBuffer* vbuffer,
421 const GrGLIndexBuffer* i buffer); 430 const GrGLIndexBuffer* i buffer);
422 431
432 /** Variants of the above that takes GL buffer IDs. Note that 0 does not imply that a
433 buffer won't be bound. The "default buffer" will be bound, which is used for client-side
434 array rendering. */
435 GrGLAttribArrayState* bindArrayAndBufferToDraw(GrGLGpu* gpu, GrGLuint vb ufferID);
436 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu,
437 GrGLuint vbufferID,
438 GrGLuint ibufferID);
439
423 private: 440 private:
441 GrGLAttribArrayState* internalBind(GrGLGpu* gpu, GrGLuint vbufferID, GrG Luint* ibufferID);
442
424 GrGLuint fBoundVertexArrayID; 443 GrGLuint fBoundVertexArrayID;
425 GrGLuint fBoundVertexBufferID; 444 GrGLuint fBoundVertexBufferID;
426 bool fBoundVertexArrayIDIsValid; 445 bool fBoundVertexArrayIDIsValid;
427 bool fBoundVertexBufferIDIsValid; 446 bool fBoundVertexBufferIDIsValid;
428 447
429 GrGLuint fDefaultVertexArrayBoundIndexBufferID; 448 GrGLuint fDefaultVertexArrayBoundIndexBufferID;
430 bool fDefaultVertexArrayBoundIndexBufferIDIsValid; 449 bool fDefaultVertexArrayBoundIndexBufferIDIsValid;
431 // We return a non-const pointer to this from bindArrayAndBuffersToDraw when vertex array 0 450 // We return a non-const pointer to this from bindArrayAndBuffersToDraw when vertex array 0
432 // is bound. However, this class is internal to GrGLGpu and this object never leaks out of 451 // is bound. However, this class is internal to GrGLGpu and this object never leaks out of
433 // GrGLGpu. 452 // GrGLGpu.
(...skipping 13 matching lines...) Expand all
447 466
448 void invalidate() { 467 void invalidate() {
449 fEquation = static_cast<GrBlendEquation>(-1); 468 fEquation = static_cast<GrBlendEquation>(-1);
450 fSrcCoeff = static_cast<GrBlendCoeff>(-1); 469 fSrcCoeff = static_cast<GrBlendCoeff>(-1);
451 fDstCoeff = static_cast<GrBlendCoeff>(-1); 470 fDstCoeff = static_cast<GrBlendCoeff>(-1);
452 fConstColorValid = false; 471 fConstColorValid = false;
453 fEnabled = kUnknown_TriState; 472 fEnabled = kUnknown_TriState;
454 } 473 }
455 } fHWBlendState; 474 } fHWBlendState;
456 475
476 /** IDs for copy surface program. */
477 struct {
478 GrGLuint fProgram;
479 GrGLint fTextureUniform;
480 GrGLint fTexCoordXformUniform;
481 GrGLint fPosXformUniform;
482 GrGLuint fArrayBuffer;
483 } fCopyProgram;
484
457 TriState fMSAAEnabled; 485 TriState fMSAAEnabled;
458 486
459 GrStencilSettings fHWStencilSettings; 487 GrStencilSettings fHWStencilSettings;
460 TriState fHWStencilTestEnabled; 488 TriState fHWStencilTestEnabled;
461 489
462 490
463 GrPipelineBuilder::DrawFace fHWDrawFace; 491 GrPipelineBuilder::DrawFace fHWDrawFace;
464 TriState fHWWriteToColor; 492 TriState fHWWriteToColor;
465 TriState fHWDitherEnabled; 493 TriState fHWDitherEnabled;
466 uint32_t fHWBoundRenderTargetUniqueID; 494 uint32_t fHWBoundRenderTargetUniqueID;
467 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; 495 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs;
468 496
469 ///@} 497 ///@}
470 498
471 // we record what stencil format worked last time to hopefully exit early 499 // we record what stencil format worked last time to hopefully exit early
472 // from our loop that tries stencil formats and calls check fb status. 500 // from our loop that tries stencil formats and calls check fb status.
473 int fLastSuccessfulStencilFmtIdx; 501 int fLastSuccessfulStencilFmtIdx;
474 502
475 typedef GrGpu INHERITED; 503 typedef GrGpu INHERITED;
476 friend class GrGLPathRendering; // For accessing setTextureUnit. 504 friend class GrGLPathRendering; // For accessing setTextureUnit.
477 }; 505 };
478 506
479 #endif 507 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698