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

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

Issue 1260293004: Revert of Move draw on upload decision in GrGpu (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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/GrContext.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
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 * 126 *
127 * @return The index buffer if successful, otherwise NULL. 127 * @return The index buffer if successful, otherwise NULL.
128 */ 128 */
129 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); 129 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic);
130 130
131 /** 131 /**
132 * Resolves MSAA. 132 * Resolves MSAA.
133 */ 133 */
134 void resolveRenderTarget(GrRenderTarget* target); 134 void resolveRenderTarget(GrRenderTarget* target);
135 135
136 /** Info struct returned by getReadPixelsInfo about performing intermediate draws before 136 /** Info struct returned by getReadPixelsInfo about performing intermediate draws before
137 reading pixels for performance or correctness. */ 137 reading pixels for performance or correctness. */
138 struct ReadPixelTempDrawInfo { 138 struct ReadPixelTempDrawInfo {
139 /** If the GrGpu is requesting that the caller do a draw to an intermedi ate surface then 139 /** If the GrGpu is requesting that the caller do a draw to an intermedi ate surface then
140 this is descriptor for the temp surface. The draw should always be a rect with 140 this is descriptor for the temp surface. The draw should always be a rect with
141 dst 0,0,w,h. */ 141 dst 0,0,w,h. */
142 GrSurfaceDesc fTempSurfaceDesc; 142 GrSurfaceDesc fTempSurfaceDesc;
143 /** Indicates whether there is a performance advantage to using an exact match texture 143 /** Indicates whether there is a performance advantage to using an exact match texture
144 (in terms of width and height) for the intermediate texture instead of approximate. */ 144 (in terms of width and height) for the intermediate texture instead of approximate. */
145 bool fUseExactScratch; 145 bool fUseExactScratch;
146 /** The caller should swap the R and B channel in the temp draw and then instead of reading 146 /** The caller should swap the R and B channel in the temp draw and then instead of reading
(...skipping 19 matching lines...) Expand all
166 caller of getReadPixelsInfo should never specify this on intput. */ 166 caller of getReadPixelsInfo should never specify this on intput. */
167 kGpuPrefersDraw_DrawPreference, 167 kGpuPrefersDraw_DrawPreference,
168 /** On input means that the caller requires a draw to do a transformatio n and there is no 168 /** On input means that the caller requires a draw to do a transformatio n and there is no
169 CPU fallback. 169 CPU fallback.
170 On output means that GrGpu can only satisfy the readPixels request i f the intermediate 170 On output means that GrGpu can only satisfy the readPixels request i f the intermediate
171 draw is performed. 171 draw is performed.
172 */ 172 */
173 kRequireDraw_DrawPreference 173 kRequireDraw_DrawPreference
174 }; 174 };
175 175
176 /** 176 /** Used to negotiates whether and how an intermediate draw should or must b e performed before
177 * Used to negotiate whether and how an intermediate draw should or must be performed before 177 a readPixels call. If this returns false then GrGpu could not deduce an intermediate draw
178 * a readPixels call. If this returns false then GrGpu could not deduce an i ntermediate draw 178 that would allow a successful readPixels call. */
179 * that would allow a successful readPixels call. The passed width, height, and rowBytes, 179 virtual bool getReadPixelsInfo(GrSurface* srcSurface, int readWidth, int rea dHeight,
180 * must be non-zero and already reflect clipping to the src bounds. 180 size_t rowBytes, GrPixelConfig readConfig, Dr awPreference*,
181 */ 181 ReadPixelTempDrawInfo *) = 0;
182 bool getReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes,
183 GrPixelConfig readConfig, DrawPreference*, ReadPixelT empDrawInfo*);
184
185 /** Info struct returned by getWritePixelsInfo about performing an intermedi ate draw in order
186 to write pixels to a GrSurface for either performance or correctness rea sons. */
187 struct WritePixelTempDrawInfo {
188 /** If the GrGpu is requesting that the caller upload to an intermediate surface and draw
189 that to the dst then this is the descriptor for the intermediate sur face. The caller
190 should upload the pixels such that the upper left pixel of the uploa d rect is at 0,0 in
191 the intermediate surface.*/
192 GrSurfaceDesc fTempSurfaceDesc;
193 /** If set, fTempSurfaceDesc's config will be a R/B swap of the src pixe l config. The caller
194 should upload the pixels as is such that R and B will be swapped in the intermediate
195 surface. When the intermediate is drawn to the dst the shader should swap R/B again
196 such that the correct swizzle results in the dst. This is done to wo rk around either
197 performance or API restrictions in the backend 3D API implementation . */
198 bool fSwapRAndB;
199 };
200 182
201 /** 183 /**
202 * Used to negotiate whether and how an intermediate surface should be used to write pixels to 184 * Gets a preferred 8888 config to use for writing pixel data to a surface w ith
203 * a GrSurface. If this returns false then GrGpu could not deduce an interme diate draw 185 * config surfaceConfig. The returned config must have at least as many bits per channel as the
204 * that would allow a successful transfer of the src pixels to the dst. The passed width, 186 * writeConfig param.
205 * height, and rowBytes, must be non-zero and already reflect clipping to th e dst bounds.
206 */ 187 */
207 bool getWritePixelsInfo(GrSurface* dstSurface, int width, int height, size_t rowBytes, 188 virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig,
208 GrPixelConfig srcConfig, DrawPreference*, WritePixel TempDrawInfo*); 189 GrPixelConfig surfaceConfig ) const {
190 return writeConfig;
191 }
192
193 /**
194 * Called before uploading writing pixels to a GrTexture when the src pixel config doesn't
195 * match the texture's config.
196 */
197 virtual bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig ) const = 0;
209 198
210 /** 199 /**
211 * Reads a rectangle of pixels from a render target. 200 * Reads a rectangle of pixels from a render target.
212 * 201 *
213 * @param renderTarget the render target to read from. NULL means the 202 * @param renderTarget the render target to read from. NULL means the
214 * current render target. 203 * current render target.
215 * @param left left edge of the rectangle to read (inclusive) 204 * @param left left edge of the rectangle to read (inclusive)
216 * @param top top edge of the rectangle to read (inclusive) 205 * @param top top edge of the rectangle to read (inclusive)
217 * @param width width of rectangle to read in pixels. 206 * @param width width of rectangle to read in pixels.
218 * @param height height of rectangle to read in pixels. 207 * @param height height of rectangle to read in pixels.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // stencil funcs supported by GPUs. 394 // stencil funcs supported by GPUs.
406 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, 395 static GrStencilFunc ConvertStencilFunc(bool stencilInClip,
407 GrStencilFunc func); 396 GrStencilFunc func);
408 static void ConvertStencilFuncAndMask(GrStencilFunc func, 397 static void ConvertStencilFuncAndMask(GrStencilFunc func,
409 bool clipInStencil, 398 bool clipInStencil,
410 unsigned int clipBit, 399 unsigned int clipBit,
411 unsigned int userBits, 400 unsigned int userBits,
412 unsigned int* ref, 401 unsigned int* ref,
413 unsigned int* mask); 402 unsigned int* mask);
414 403
415 static void ElevateDrawPreference(GrGpu::DrawPreference* preference,
416 GrGpu::DrawPreference elevation) {
417 GR_STATIC_ASSERT(GrGpu::kCallerPrefersDraw_DrawPreference > GrGpu::kNoDr aw_DrawPreference);
418 GR_STATIC_ASSERT(GrGpu::kGpuPrefersDraw_DrawPreference >
419 GrGpu::kCallerPrefersDraw_DrawPreference);
420 GR_STATIC_ASSERT(GrGpu::kRequireDraw_DrawPreference >
421 GrGpu::kGpuPrefersDraw_DrawPreference);
422 *preference = SkTMax(*preference, elevation);
423 }
424
425 const GrTraceMarkerSet& getActiveTraceMarkers() const { return fActiveTraceM arkers; } 404 const GrTraceMarkerSet& getActiveTraceMarkers() const { return fActiveTraceM arkers; }
426 405
427 Stats fStats; 406 Stats fStats;
428 SkAutoTDelete<GrPathRendering> fPathRendering; 407 SkAutoTDelete<GrPathRendering> fPathRendering;
429 // Subclass must initialize this in its constructor. 408 // Subclass must initialize this in its constructor.
430 SkAutoTUnref<const GrCaps> fCaps; 409 SkAutoTUnref<const GrCaps> fCaps;
431 410
432 private: 411 private:
433 // called when the 3D context state is unknown. Subclass should emit any 412 // called when the 3D context state is unknown. Subclass should emit any
434 // assumed 3D context state and dirty any state cache. 413 // assumed 3D context state and dirty any state cache.
(...skipping 19 matching lines...) Expand all
454 bool canIgnoreRect) = 0; 433 bool canIgnoreRect) = 0;
455 434
456 435
457 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is 436 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is
458 // ONLY used by the the clip target 437 // ONLY used by the the clip target
459 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0; 438 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0;
460 439
461 // overridden by backend-specific derived class to perform the draw call. 440 // overridden by backend-specific derived class to perform the draw call.
462 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; 441 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0;
463 442
464 virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int r eadHeight,
465 size_t rowBytes, GrPixelConfig readConfig, DrawPreference*,
466 ReadPixelTempDrawInfo*) = 0;
467 virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int heig ht, size_t rowBytes,
468 GrPixelConfig srcConfig, DrawPreference*,
469 WritePixelTempDrawInfo*) = 0;
470
471 virtual bool onReadPixels(GrRenderTarget* target, 443 virtual bool onReadPixels(GrRenderTarget* target,
472 int left, int top, int width, int height, 444 int left, int top, int width, int height,
473 GrPixelConfig, 445 GrPixelConfig,
474 void* buffer, 446 void* buffer,
475 size_t rowBytes) = 0; 447 size_t rowBytes) = 0;
476 448
477 // overridden by backend-specific derived class to perform the texture updat e 449 // overridden by backend-specific derived class to perform the texture updat e
478 virtual bool onWriteTexturePixels(GrTexture* texture, 450 virtual bool onWriteTexturePixels(GrTexture* texture,
479 int left, int top, int width, int height, 451 int left, int top, int width, int height,
480 GrPixelConfig config, const void* buffer, 452 GrPixelConfig config, const void* buffer,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 GrTraceMarkerSet fActiveT raceMarkers; 488 GrTraceMarkerSet fActiveT raceMarkers;
517 GrTraceMarkerSet fStoredT raceMarkers; 489 GrTraceMarkerSet fStoredT raceMarkers;
518 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. 490 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu.
519 GrContext* fContext ; 491 GrContext* fContext ;
520 492
521 friend class GrPathRendering; 493 friend class GrPathRendering;
522 typedef SkRefCnt INHERITED; 494 typedef SkRefCnt INHERITED;
523 }; 495 };
524 496
525 #endif 497 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698