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

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 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 class ReadPixelsSupportedFormats {
373 public:
374 struct Key {
375 GrGLenum fFormat;
376 GrGLenum fType;
377 GrGLenum fFboFormat;
378
379 bool operator==(const Key& rhs) const {
380 return fFormat == rhs.fFormat
381 && fType == rhs.fType
382 && fFboFormat == rhs.fFboFormat;
383 }
384
385 uint32_t getHash() const {
386 // fFormat has different values like 0x190X or 0x8XXX: 16 bits a re required
387 uint32_t hash = ((static_cast<uint32_t> (fFormat) & 0xFFFF) << 1 6);
388 // fType is 0x14XX: 8 lower bits are enough
389 hash |= ((static_cast<uint32_t> (fType) & 0xFF) << 8);
390 // fFboFormat is enum GrPixelConfig which has less than 15 value s: 8 bits OK
391 hash |= (static_cast<uint32_t> (fFboFormat) & 0xFF);
392
393 return hash;
mtklein 2014/07/11 18:11:39 You may have better results if you mix these bits.
Rémi Piotaix 2014/07/14 20:38:59 Done.
394 }
395 };
396
397 ReadPixelsSupportedFormats(Key key,
mtklein 2014/07/11 18:11:39 Strange formatting?
Rémi Piotaix 2014/07/14 20:38:59 Done.
398 bool value)
399 : fKey(key), fValue(value) {
400 }
401
402 static const Key& GetKey(const ReadPixelsSupportedFormats& element) {
403 return element.fKey;
404 }
405
406 static uint32_t Hash(const Key& key) {
407 return key.getHash();
408 }
409
410 bool value() const {
411 return fValue;
412 }
413 private:
414 Key fKey;
415 bool fValue;
416 };
417
418 mutable SkTHashCache<ReadPixelsSupportedFormats,
419 ReadPixelsSupportedFormats::Key> fReadPixelsSupportedCa che;
420
367 typedef GrDrawTargetCaps INHERITED; 421 typedef GrDrawTargetCaps INHERITED;
368 }; 422 };
369 423
370 #endif 424 #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