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

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: Fix bug Created 6 years, 2 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/core/SkTHashCache.h ('k') | src/gpu/gl/GrGLCaps.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 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 "SkChecksum.h"
15 #include "SkTHashCache.h"
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; } 246 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; }
246 247
247 /// 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.
248 bool useNonVBOVertexAndIndexDynamicData() const { 249 bool useNonVBOVertexAndIndexDynamicData() const {
249 return fUseNonVBOVertexAndIndexDynamicData; 250 return fUseNonVBOVertexAndIndexDynamicData;
250 } 251 }
251 252
252 /// Does ReadPixels support the provided format/type combo? 253 /// Does ReadPixels support the provided format/type combo?
253 bool readPixelsSupported(const GrGLInterface* intf, 254 bool readPixelsSupported(const GrGLInterface* intf,
254 GrGLenum format, 255 GrGLenum format,
255 GrGLenum type) const; 256 GrGLenum type,
257 GrGLenum currFboFormat) const;
256 258
257 bool isCoreProfile() const { return fIsCoreProfile; } 259 bool isCoreProfile() const { return fIsCoreProfile; }
258 260
259 261
260 bool fullClearIsFree() const { return fFullClearIsFree; } 262 bool fullClearIsFree() const { return fFullClearIsFree; }
261 263
262 bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; } 264 bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
263 265
264 /** 266 /**
265 * 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
316 return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx)); 318 return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx));
317 } 319 }
318 }; 320 };
319 321
320 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); 322 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
321 void initStencilFormats(const GrGLContextInfo&); 323 void initStencilFormats(const GrGLContextInfo&);
322 // This must be called after initFSAASupport(). 324 // This must be called after initFSAASupport().
323 void initConfigRenderableTable(const GrGLContextInfo&); 325 void initConfigRenderableTable(const GrGLContextInfo&);
324 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*) ; 326 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*) ;
325 327
328 bool doReadPixelsSupported(const GrGLInterface* intf,
329 GrGLenum format,
330 GrGLenum type) const;
331
326 // 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
327 // used as a color attachment 333 // used as a color attachment
328 VerifiedColorConfigs fVerifiedColorConfigs; 334 VerifiedColorConfigs fVerifiedColorConfigs;
329 335
330 SkTArray<StencilFormat, true> fStencilFormats; 336 SkTArray<StencilFormat, true> fStencilFormats;
331 // 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
332 // 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
333 // as a stencil attachment. 339 // as a stencil attachment.
334 SkTArray<VerifiedColorConfigs, true> fStencilVerifiedColorConfigs; 340 SkTArray<VerifiedColorConfigs, true> fStencilVerifiedColorConfigs;
335 341
(...skipping 23 matching lines...) Expand all
359 bool fVertexArrayObjectSupport : 1; 365 bool fVertexArrayObjectSupport : 1;
360 bool fUseNonVBOVertexAndIndexDynamicData : 1; 366 bool fUseNonVBOVertexAndIndexDynamicData : 1;
361 bool fIsCoreProfile : 1; 367 bool fIsCoreProfile : 1;
362 bool fFullClearIsFree : 1; 368 bool fFullClearIsFree : 1;
363 bool fDropsTileOnZeroDivide : 1; 369 bool fDropsTileOnZeroDivide : 1;
364 bool fFBFetchSupport : 1; 370 bool fFBFetchSupport : 1;
365 371
366 const char* fFBFetchColorName; 372 const char* fFBFetchColorName;
367 const char* fFBFetchExtensionString; 373 const char* fFBFetchExtensionString;
368 374
375 class ReadPixelsSupportedFormats {
376 public:
377 struct Key {
378 GrGLenum fFormat;
379 GrGLenum fType;
380 GrGLenum fFboFormat;
381
382 bool operator==(const Key& rhs) const {
383 return fFormat == rhs.fFormat
384 && fType == rhs.fType
385 && fFboFormat == rhs.fFboFormat;
386 }
387
388 uint32_t getHash() const {
389 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(thi s), sizeof(*this));
390 }
391 };
392
393 ReadPixelsSupportedFormats(Key key, bool value) : fKey(key), fValue(valu e) {
394 }
395
396 static const Key& GetKey(const ReadPixelsSupportedFormats& element) {
397 return element.fKey;
398 }
399
400 static uint32_t Hash(const Key& key) {
401 return key.getHash();
402 }
403
404 bool value() const {
405 return fValue;
406 }
407 private:
408 Key fKey;
409 bool fValue;
410 };
411
412 mutable SkTHashCache<ReadPixelsSupportedFormats,
413 ReadPixelsSupportedFormats::Key> fReadPixelsSupportedCa che;
414
369 typedef GrDrawTargetCaps INHERITED; 415 typedef GrDrawTargetCaps INHERITED;
370 }; 416 };
371 417
372 #endif 418 #endif
OLDNEW
« no previous file with comments | « 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