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

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: Rebase (merge) to master 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"
15 #include "GrTHashTable.h"
mtklein 2014/07/11 17:08:08 Do you still need this?
Rémi Piotaix 2014/07/11 17:45:01 This one is not needed: "GrTHashTable.h" Deleted.
14 #include "SkTArray.h" 16 #include "SkTArray.h"
15 #include "SkTDArray.h"
16 17
17 class GrGLContextInfo; 18 class GrGLContextInfo;
18 19
19 /** 20 /**
20 * Stores some capabilities of a GL context. Most are determined by the GL 21 * 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 22 * version and the extensions string. It also tracks formats that have passed
22 * the FBO completeness test. 23 * the FBO completeness test.
23 */ 24 */
24 class GrGLCaps : public GrDrawTargetCaps { 25 class GrGLCaps : public GrDrawTargetCaps {
25 public: 26 public:
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; } 247 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; }
247 248
248 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic conte nt. 249 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic conte nt.
249 bool useNonVBOVertexAndIndexDynamicData() const { 250 bool useNonVBOVertexAndIndexDynamicData() const {
250 return fUseNonVBOVertexAndIndexDynamicData; 251 return fUseNonVBOVertexAndIndexDynamicData;
251 } 252 }
252 253
253 /// Does ReadPixels support the provided format/type combo? 254 /// Does ReadPixels support the provided format/type combo?
254 bool readPixelsSupported(const GrGLInterface* intf, 255 bool readPixelsSupported(const GrGLInterface* intf,
255 GrGLenum format, 256 GrGLenum format,
256 GrGLenum type) const; 257 GrGLenum type,
258 GrGLenum currFboFormat) const;
257 259
258 bool isCoreProfile() const { return fIsCoreProfile; } 260 bool isCoreProfile() const { return fIsCoreProfile; }
259 261
260 262
261 bool fullClearIsFree() const { return fFullClearIsFree; } 263 bool fullClearIsFree() const { return fFullClearIsFree; }
262 264
263 bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; } 265 bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
264 266
265 /** 267 /**
266 * Returns a string containing the caps info. 268 * 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)); 319 return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx));
318 } 320 }
319 }; 321 };
320 322
321 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); 323 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
322 void initStencilFormats(const GrGLContextInfo&); 324 void initStencilFormats(const GrGLContextInfo&);
323 // This must be called after initFSAASupport(). 325 // This must be called after initFSAASupport().
324 void initConfigRenderableTable(const GrGLContextInfo&); 326 void initConfigRenderableTable(const GrGLContextInfo&);
325 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*) ; 327 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*) ;
326 328
329 bool doReadPixelsSupported(const GrGLInterface* intf,
330 GrGLenum format,
331 GrGLenum type) const;
332
327 // tracks configs that have been verified to pass the FBO completeness when 333 // tracks configs that have been verified to pass the FBO completeness when
328 // used as a color attachment 334 // used as a color attachment
329 VerifiedColorConfigs fVerifiedColorConfigs; 335 VerifiedColorConfigs fVerifiedColorConfigs;
330 336
331 SkTArray<StencilFormat, true> fStencilFormats; 337 SkTArray<StencilFormat, true> fStencilFormats;
332 // tracks configs that have been verified to pass the FBO completeness when 338 // 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 339 // used as a color attachment when a particular stencil format is used
334 // as a stencil attachment. 340 // as a stencil attachment.
335 SkTArray<VerifiedColorConfigs, true> fStencilVerifiedColorConfigs; 341 SkTArray<VerifiedColorConfigs, true> fStencilVerifiedColorConfigs;
336 342
(...skipping 20 matching lines...) Expand all
357 bool fTextureRedSupport : 1; 363 bool fTextureRedSupport : 1;
358 bool fImagingSupport : 1; 364 bool fImagingSupport : 1;
359 bool fTwoFormatLimit : 1; 365 bool fTwoFormatLimit : 1;
360 bool fFragCoordsConventionSupport : 1; 366 bool fFragCoordsConventionSupport : 1;
361 bool fVertexArrayObjectSupport : 1; 367 bool fVertexArrayObjectSupport : 1;
362 bool fUseNonVBOVertexAndIndexDynamicData : 1; 368 bool fUseNonVBOVertexAndIndexDynamicData : 1;
363 bool fIsCoreProfile : 1; 369 bool fIsCoreProfile : 1;
364 bool fFullClearIsFree : 1; 370 bool fFullClearIsFree : 1;
365 bool fDropsTileOnZeroDivide : 1; 371 bool fDropsTileOnZeroDivide : 1;
366 372
373 class ReadPixelsSupportedFormats {
374 public:
375 struct Key {
376 GrGLenum fFormat;
377 GrGLenum fType;
378 GrGLenum fFboFormat;
379
380 bool operator==(const Key& rhs) const {
381 return fFormat == rhs.fFormat
382 && fType == rhs.fType
383 && fFboFormat == rhs.fFboFormat;
384 }
385
386 uint32_t getHash() const {
387 // fFormat has different values like 0x190X or 0x8XXX: 16 bits a re required
388 uint32_t hash = ((static_cast<uint32_t> (fFormat) & 0xFFFF) << 1 6);
389 // fType is 0x14XX: 8 lower bits are enough
390 hash |= ((static_cast<uint32_t> (fType) & 0xFF) << 8);
391 // fFboFormat is enum GrPixelConfig which has less than 15 value s: 8 bits OK
392 hash |= (static_cast<uint32_t> (fFboFormat) & 0xFF);
393
394 return hash;
395 }
396 };
397
398 ReadPixelsSupportedFormats(Key key,
399 bool value)
400 : fKey(key), fValue(value) {
401 }
402
403 static const Key& GetKey(const ReadPixelsSupportedFormats& element) {
404 return element.fKey;
405 }
406
407 static uint32_t Hash(const Key& key) {
408 return key.getHash();
409 }
410
411 bool value() const {
412 return fValue;
413 }
414 private:
415 Key fKey;
416 bool fValue;
417 };
418
419 mutable SkTHashCache<ReadPixelsSupportedFormats,
420 ReadPixelsSupportedFormats::Key> fReadPixelsSupportedCa che;
421
367 typedef GrDrawTargetCaps INHERITED; 422 typedef GrDrawTargetCaps INHERITED;
368 }; 423 };
369 424
370 #endif 425 #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