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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h

Issue 2212163002: Add some plumbing for the color management of canvases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build and tests Created 4 years, 4 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 (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 16 matching lines...) Expand all
27 #define WebGLRenderingContextBase_h 27 #define WebGLRenderingContextBase_h
28 28
29 #include "bindings/core/v8/Nullable.h" 29 #include "bindings/core/v8/Nullable.h"
30 #include "bindings/core/v8/ScopedPersistent.h" 30 #include "bindings/core/v8/ScopedPersistent.h"
31 #include "bindings/core/v8/ScriptState.h" 31 #include "bindings/core/v8/ScriptState.h"
32 #include "bindings/core/v8/ScriptValue.h" 32 #include "bindings/core/v8/ScriptValue.h"
33 #include "bindings/core/v8/ScriptWrappable.h" 33 #include "bindings/core/v8/ScriptWrappable.h"
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include "core/dom/DOMTypedArray.h" 35 #include "core/dom/DOMTypedArray.h"
36 #include "core/dom/TypedFlexibleArrayBufferView.h" 36 #include "core/dom/TypedFlexibleArrayBufferView.h"
37 #include "core/html/canvas/CanvasContextCreationAttributes.h"
37 #include "core/html/canvas/CanvasRenderingContext.h" 38 #include "core/html/canvas/CanvasRenderingContext.h"
38 #include "core/layout/ContentChangeType.h" 39 #include "core/layout/ContentChangeType.h"
39 #include "modules/webgl/WebGLContextAttributes.h" 40 #include "modules/webgl/WebGLContextAttributes.h"
40 #include "modules/webgl/WebGLExtensionName.h" 41 #include "modules/webgl/WebGLExtensionName.h"
41 #include "modules/webgl/WebGLTexture.h" 42 #include "modules/webgl/WebGLTexture.h"
42 #include "modules/webgl/WebGLVertexArrayObjectBase.h" 43 #include "modules/webgl/WebGLVertexArrayObjectBase.h"
43 #include "platform/Timer.h" 44 #include "platform/Timer.h"
44 #include "platform/graphics/ImageBuffer.h" 45 #include "platform/graphics/ImageBuffer.h"
45 #include "platform/graphics/gpu/DrawingBuffer.h" 46 #include "platform/graphics/gpu/DrawingBuffer.h"
46 #include "platform/graphics/gpu/Extensions3DUtil.h" 47 #include "platform/graphics/gpu/Extensions3DUtil.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 public: 132 public:
132 ~WebGLRenderingContextBase() override; 133 ~WebGLRenderingContextBase() override;
133 134
134 virtual String contextName() const = 0; 135 virtual String contextName() const = 0;
135 virtual void registerContextExtensions() = 0; 136 virtual void registerContextExtensions() = 0;
136 137
137 virtual void initializeNewContext(); 138 virtual void initializeNewContext();
138 139
139 static unsigned getWebGLVersion(const CanvasRenderingContext*); 140 static unsigned getWebGLVersion(const CanvasRenderingContext*);
140 141
141 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex t3DProvider(HTMLCanvasElement*, WebGLContextAttributes, unsigned webGLVersion); 142 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex t3DProvider(HTMLCanvasElement*, const CanvasContextCreationAttributes&, unsigned webGLVersion);
142 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex t3DProvider(ScriptState*, WebGLContextAttributes, unsigned webGLVersion); 143 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex t3DProvider(ScriptState*, const CanvasContextCreationAttributes&, unsigned webGL Version);
143 static void forceNextWebGLContextCreationToFail(); 144 static void forceNextWebGLContextCreationToFail();
144 145
145 unsigned version() const { return m_version; } 146 unsigned version() const { return m_version; }
146 147
147 int drawingBufferWidth() const; 148 int drawingBufferWidth() const;
148 int drawingBufferHeight() const; 149 int drawingBufferHeight() const;
149 150
150 void activeTexture(GLenum texture); 151 void activeTexture(GLenum texture);
151 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*); 152 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*);
152 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); 153 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 friend class WebGLCompressedTextureASTC; 425 friend class WebGLCompressedTextureASTC;
425 friend class WebGLCompressedTextureATC; 426 friend class WebGLCompressedTextureATC;
426 friend class WebGLCompressedTextureETC1; 427 friend class WebGLCompressedTextureETC1;
427 friend class WebGLCompressedTexturePVRTC; 428 friend class WebGLCompressedTexturePVRTC;
428 friend class WebGLCompressedTextureS3TC; 429 friend class WebGLCompressedTextureS3TC;
429 friend class WebGLRenderingContextErrorMessageCallback; 430 friend class WebGLRenderingContextErrorMessageCallback;
430 friend class WebGLVertexArrayObjectBase; 431 friend class WebGLVertexArrayObjectBase;
431 friend class ScopedTexture2DRestorer; 432 friend class ScopedTexture2DRestorer;
432 friend class ScopedFramebufferRestorer; 433 friend class ScopedFramebufferRestorer;
433 434
434 WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsCon text3DProvider>, const WebGLContextAttributes&, unsigned); 435 WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsCon text3DProvider>, const CanvasContextCreationAttributes&, unsigned);
435 WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsConte xt3DProvider>, const WebGLContextAttributes&, unsigned); 436 WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsConte xt3DProvider>, const CanvasContextCreationAttributes&, unsigned);
436 PassRefPtr<DrawingBuffer> createDrawingBuffer(std::unique_ptr<WebGraphicsCon text3DProvider>); 437 PassRefPtr<DrawingBuffer> createDrawingBuffer(std::unique_ptr<WebGraphicsCon text3DProvider>);
437 void setupFlags(); 438 void setupFlags();
438 439
439 // CanvasRenderingContext implementation. 440 // CanvasRenderingContext implementation.
440 bool is3d() const override { return true; } 441 bool is3d() const override { return true; }
441 bool isAccelerated() const override { return true; } 442 bool isAccelerated() const override { return true; }
442 void setIsHidden(bool) override; 443 void setIsHidden(bool) override;
443 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override; 444 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override;
444 WebLayer* platformLayer() const override; 445 WebLayer* platformLayer() const override;
445 void stop() override; 446 void stop() override;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 bool m_drawBuffersWebGLRequirementsChecked; 559 bool m_drawBuffersWebGLRequirementsChecked;
559 bool m_drawBuffersSupported; 560 bool m_drawBuffersSupported;
560 561
561 GLenum m_readBufferOfDefaultFramebuffer; 562 GLenum m_readBufferOfDefaultFramebuffer;
562 563
563 GLint m_packAlignment; 564 GLint m_packAlignment;
564 GLint m_unpackAlignment; 565 GLint m_unpackAlignment;
565 bool m_unpackFlipY; 566 bool m_unpackFlipY;
566 bool m_unpackPremultiplyAlpha; 567 bool m_unpackPremultiplyAlpha;
567 GLenum m_unpackColorspaceConversion; 568 GLenum m_unpackColorspaceConversion;
568 WebGLContextAttributes m_requestedAttributes;
569 569
570 GLfloat m_clearColor[4]; 570 GLfloat m_clearColor[4];
571 bool m_scissorEnabled; 571 bool m_scissorEnabled;
572 GLfloat m_clearDepth; 572 GLfloat m_clearDepth;
573 GLint m_clearStencil; 573 GLint m_clearStencil;
574 GLboolean m_colorMask[4]; 574 GLboolean m_colorMask[4];
575 GLboolean m_depthMask; 575 GLboolean m_depthMask;
576 576
577 bool m_stencilEnabled; 577 bool m_stencilEnabled;
578 GLuint m_stencilMask, m_stencilMaskBack; 578 GLuint m_stencilMask, m_stencilMaskBack;
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 // Helper functions for tex(Sub)Image2D && texSubImage3D 1101 // Helper functions for tex(Sub)Image2D && texSubImage3D
1102 void texImageHelperDOMArrayBufferView(TexImageFunctionID, GLenum, GLint, GLi nt, GLsizei, GLsizei, GLint, GLenum, GLenum, GLsizei, GLint, GLint, GLint, DOMAr rayBufferView*); 1102 void texImageHelperDOMArrayBufferView(TexImageFunctionID, GLenum, GLint, GLi nt, GLsizei, GLsizei, GLint, GLenum, GLenum, GLsizei, GLint, GLint, GLint, DOMAr rayBufferView*);
1103 void texImageHelperImageData(TexImageFunctionID, GLenum, GLint, GLint, GLint , GLenum, GLenum, GLsizei, GLint, GLint, GLint, ImageData*); 1103 void texImageHelperImageData(TexImageFunctionID, GLenum, GLint, GLint, GLint , GLenum, GLenum, GLsizei, GLint, GLint, GLint, ImageData*);
1104 void texImageHelperHTMLImageElement(TexImageFunctionID, GLenum, GLint, GLint , GLenum, GLenum, GLint, GLint, GLint, HTMLImageElement*, ExceptionState&); 1104 void texImageHelperHTMLImageElement(TexImageFunctionID, GLenum, GLint, GLint , GLenum, GLenum, GLint, GLint, GLint, HTMLImageElement*, ExceptionState&);
1105 void texImageHelperHTMLCanvasElement(TexImageFunctionID, GLenum, GLint, GLin t, GLenum, GLenum, GLint, GLint, GLint, HTMLCanvasElement*, ExceptionState&); 1105 void texImageHelperHTMLCanvasElement(TexImageFunctionID, GLenum, GLint, GLin t, GLenum, GLenum, GLint, GLint, GLint, HTMLCanvasElement*, ExceptionState&);
1106 void texImageHelperHTMLVideoElement(TexImageFunctionID, GLenum, GLint, GLint , GLenum, GLenum, GLint, GLint, GLint, HTMLVideoElement*, ExceptionState&); 1106 void texImageHelperHTMLVideoElement(TexImageFunctionID, GLenum, GLint, GLint , GLenum, GLenum, GLint, GLint, GLint, HTMLVideoElement*, ExceptionState&);
1107 void texImageHelperImageBitmap(TexImageFunctionID, GLenum, GLint, GLint, GLe num, GLenum, GLint, GLint, GLint, ImageBitmap*, ExceptionState&); 1107 void texImageHelperImageBitmap(TexImageFunctionID, GLenum, GLint, GLint, GLe num, GLenum, GLint, GLint, GLint, ImageBitmap*, ExceptionState&);
1108 static const char* getTexImageFunctionName(TexImageFunctionID); 1108 static const char* getTexImageFunctionName(TexImageFunctionID);
1109 1109
1110 private: 1110 private:
1111 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, std::unique_ ptr<WebGraphicsContext3DProvider>, const WebGLContextAttributes&, unsigned); 1111 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, std::unique_ ptr<WebGraphicsContext3DProvider>, const CanvasContextCreationAttributes&, unsig ned);
1112 static std::unique_ptr<WebGraphicsContext3DProvider> createContextProviderIn ternal(HTMLCanvasElement*, ScriptState*, WebGLContextAttributes, unsigned); 1112 static std::unique_ptr<WebGraphicsContext3DProvider> createContextProviderIn ternal(HTMLCanvasElement*, ScriptState*, const CanvasContextCreationAttributes&, unsigned);
1113 void texImageCanvasByGPU(HTMLCanvasElement*, GLuint, GLenum, GLenum, GLint); 1113 void texImageCanvasByGPU(HTMLCanvasElement*, GLuint, GLenum, GLenum, GLint);
1114 void texImageBitmapByGPU(ImageBitmap*, GLuint, GLenum, GLenum, GLint, bool); 1114 void texImageBitmapByGPU(ImageBitmap*, GLuint, GLenum, GLenum, GLint, bool);
1115 1115
1116 const unsigned m_version; 1116 const unsigned m_version;
1117 }; 1117 };
1118 1118
1119 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 1119 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
1120 1120
1121 } // namespace blink 1121 } // namespace blink
1122 1122
1123 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState); 1123 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState);
1124 1124
1125 #endif // WebGLRenderingContextBase_h 1125 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698