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

Unified Diff: content/common/gpu/client/gl_helper.h

Issue 149123008: Implement GLHelperReadbackSupport for GLHelper usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code changed as per review comments. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/client/gl_helper.h
diff --git a/content/common/gpu/client/gl_helper.h b/content/common/gpu/client/gl_helper.h
index 46db753207217ae13659920803008f68b739df8c..b885dbfd3c22d657e8b3762c95cecde6aab3a2fe 100644
--- a/content/common/gpu/client/gl_helper.h
+++ b/content/common/gpu/client/gl_helper.h
@@ -169,6 +169,12 @@ class CONTENT_EXPORT GLHelper {
SCALER_QUALITY_BEST = 3,
};
+ enum FormatSupport {
+ FORMAT_NOT_SUPPORTED = 0,
+ FORMAT_SUPPORTED,
+ FORMAT_SUPPORT_UNKNOWN,
+ };
+
// Copies the block of pixels specified with |src_subrect| from |src_texture|,
// scales it to |dst_size|, and writes it into |out|.
// |src_size| is the size of |src_texture|. The result is of format GL_BGRA
@@ -277,8 +283,12 @@ class CONTENT_EXPORT GLHelper {
// size of the framebuffer.
void CopyTextureFullImage(GLuint texture, const gfx::Size& size);
- // Check whether rgb565 readback is supported or not.
- bool CanUseRgb565Readback();
+ // Checks whether the readback (Color read format and type) is supported
+ // for the requested texture format by the hardware or not.
+ // For ex: some hardwares have rgb565 readback
+ // support when binded with the frame buffer for others it may fail.
+
+ bool IsReadbackConfigSupported(SkBitmap::Config bitmap_format);
// A scaler will cache all intermediate textures and programs
// needed to scale from a specified size to a destination size.
@@ -328,6 +338,18 @@ class CONTENT_EXPORT GLHelper {
// 0 if GL_EXT_draw_buffers is not available.
GLint MaxDrawBuffers();
+ private:
+ // IsReadbackConfigSupported does texture bind and attach operations,
+ // better do it in the constructor, and never do it again.
+ // This populates the readback support list at a time once.
+ void InitializeReadbackSupport();
+ void CheckForReadbackSupport(SkBitmap::Config bitmap_format);
+
+ // Helper functions for checking the supported texture formats.
+ // Avoid using this API in between texture operations, as this does some
+ // teture opertions (bind, attach) internally.
+ bool SupportsFormat(GLint format, GLint type);
+
protected:
class CopyTextureToImpl;
@@ -340,8 +362,7 @@ class CONTENT_EXPORT GLHelper {
gpu::ContextSupport* context_support_;
scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_;
scoped_ptr<GLHelperScaling> scaler_impl_;
- bool initialized_565_format_check_;
- bool support_565_format_;
+ FormatSupport format_support_table_[SkBitmap::kConfigCount];
DISALLOW_COPY_AND_ASSIGN(GLHelper);
};

Powered by Google App Engine
This is Rietveld 408576698