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

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

Issue 364193004: Reopened: Caching the result of readPixelsSupported (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Correcting code as suggested in the comments Created 6 years, 5 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 2012 Google Inc. 2 * Copyright 2012 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 8
9 #ifndef GrGLCaps_DEFINED 9 #ifndef GrGLCaps_DEFINED
10 #define GrGLCaps_DEFINED 10 #define GrGLCaps_DEFINED
11 11
12 #include "GrDrawTargetCaps.h" 12 #include "GrDrawTargetCaps.h"
13 #include "GrGLStencilBuffer.h" 13 #include "GrGLStencilBuffer.h"
14 #include "SkTHashCache.h"
14 #include "SkTArray.h" 15 #include "SkTArray.h"
15 #include "SkTDArray.h"
16 16
17 class GrGLContextInfo; 17 class GrGLContextInfo;
18 18
19 /** 19 /**
20 * Stores some capabilities of a GL context. Most are determined by the GL 20 * Stores some capabilities of a GL context. Most are determined by the GL
21 * version and the extensions string. It also tracks formats that have passed 21 * version and the extensions string. It also tracks formats that have passed
22 * the FBO completeness test. 22 * the FBO completeness test.
23 */ 23 */
24 class GrGLCaps : public GrDrawTargetCaps { 24 class GrGLCaps : public GrDrawTargetCaps {
25 public: 25 public:
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; } 246 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; }
247 247
248 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic conte nt. 248 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic conte nt.
249 bool useNonVBOVertexAndIndexDynamicData() const { 249 bool useNonVBOVertexAndIndexDynamicData() const {
250 return fUseNonVBOVertexAndIndexDynamicData; 250 return fUseNonVBOVertexAndIndexDynamicData;
251 } 251 }
252 252
253 /// Does ReadPixels support the provided format/type combo? 253 /// Does ReadPixels support the provided format/type combo?
254 bool readPixelsSupported(const GrGLInterface* intf, 254 bool readPixelsSupported(const GrGLInterface* intf,
255 GrGLenum format, 255 GrGLenum format,
256 GrGLenum type) const; 256 GrGLenum type,
257 GrGLenum currFboFormat) const;
257 258
258 bool isCoreProfile() const { return fIsCoreProfile; } 259 bool isCoreProfile() const { return fIsCoreProfile; }
259 260
260 261
261 bool fullClearIsFree() const { return fFullClearIsFree; } 262 bool fullClearIsFree() const { return fFullClearIsFree; }
262 263
263 bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; } 264 bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
264 265
265 /** 266 /**
266 * Returns a string containing the caps info. 267 * Returns a string containing the caps info.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx)); 318 return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx));
318 } 319 }
319 }; 320 };
320 321
321 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); 322 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
322 void initStencilFormats(const GrGLContextInfo&); 323 void initStencilFormats(const GrGLContextInfo&);
323 // This must be called after initFSAASupport(). 324 // This must be called after initFSAASupport().
324 void initConfigRenderableTable(const GrGLContextInfo&); 325 void initConfigRenderableTable(const GrGLContextInfo&);
325 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*) ; 326 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*) ;
326 327
328 bool doReadPixelsSupported(const GrGLInterface* intf,
329 GrGLenum format,
330 GrGLenum type) const;
331
327 // tracks configs that have been verified to pass the FBO completeness when 332 // tracks configs that have been verified to pass the FBO completeness when
328 // used as a color attachment 333 // used as a color attachment
329 VerifiedColorConfigs fVerifiedColorConfigs; 334 VerifiedColorConfigs fVerifiedColorConfigs;
330 335
331 SkTArray<StencilFormat, true> fStencilFormats; 336 SkTArray<StencilFormat, true> fStencilFormats;
332 // tracks configs that have been verified to pass the FBO completeness when 337 // tracks configs that have been verified to pass the FBO completeness when
333 // used as a color attachment when a particular stencil format is used 338 // used as a color attachment when a particular stencil format is used
334 // as a stencil attachment. 339 // as a stencil attachment.
335 SkTArray<VerifiedColorConfigs, true> fStencilVerifiedColorConfigs; 340 SkTArray<VerifiedColorConfigs, true> fStencilVerifiedColorConfigs;
336 341
(...skipping 20 matching lines...) Expand all
357 bool fTextureRedSupport : 1; 362 bool fTextureRedSupport : 1;
358 bool fImagingSupport : 1; 363 bool fImagingSupport : 1;
359 bool fTwoFormatLimit : 1; 364 bool fTwoFormatLimit : 1;
360 bool fFragCoordsConventionSupport : 1; 365 bool fFragCoordsConventionSupport : 1;
361 bool fVertexArrayObjectSupport : 1; 366 bool fVertexArrayObjectSupport : 1;
362 bool fUseNonVBOVertexAndIndexDynamicData : 1; 367 bool fUseNonVBOVertexAndIndexDynamicData : 1;
363 bool fIsCoreProfile : 1; 368 bool fIsCoreProfile : 1;
364 bool fFullClearIsFree : 1; 369 bool fFullClearIsFree : 1;
365 bool fDropsTileOnZeroDivide : 1; 370 bool fDropsTileOnZeroDivide : 1;
366 371
372 struct ReadPixelsSupportedFormatsKey {
373 GrGLenum fFormat;
374 GrGLenum fType;
375 GrGLenum fFboFormat;
376
377 bool operator==(const ReadPixelsSupportedFormatsKey& rhs) const {
378 return fFormat == rhs.fFormat
379 && fType == rhs.fType
380 && fFboFormat == rhs.fFboFormat;
381 }
382 };
383
384 class ReadPixelsSupportedFormats {
385 public:
386 ReadPixelsSupportedFormats(ReadPixelsSupportedFormatsKey key,
387 bool value)
388 :fKey(key), fValue(value) {
389 }
390
391 static const ReadPixelsSupportedFormatsKey& GetKey(const ReadPixelsSuppo rtedFormats& element) {
392 return element.fKey;
393 }
394 static uint32_t Hash(const ReadPixelsSupportedFormatsKey&);
395
396 bool value() const { return fValue; }
397 private:
398 ReadPixelsSupportedFormatsKey fKey;
399 bool fValue;
400 };
401
402 mutable SkTHashCache<ReadPixelsSupportedFormats, ReadPixelsSupportedFormatsK ey> fReadPixelsSupportedCache;
403
367 typedef GrDrawTargetCaps INHERITED; 404 typedef GrDrawTargetCaps INHERITED;
368 }; 405 };
369 406
370 #endif 407 #endif
OLDNEW
« src/core/SkTHashCache.h ('K') | « src/core/SkTHashCache.h ('k') | src/gpu/gl/GrGLCaps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698