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

Side by Side Diff: Source/platform/graphics/GraphicsContext3D.h

Issue 127493002: Removed most calls to GraphicsContext3D from DrawingBuffer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 bool antialias; 94 bool antialias;
95 bool premultipliedAlpha; 95 bool premultipliedAlpha;
96 bool preserveDrawingBuffer; 96 bool preserveDrawingBuffer;
97 bool noExtensions; 97 bool noExtensions;
98 bool shareResources; 98 bool shareResources;
99 bool preferDiscreteGPU; 99 bool preferDiscreteGPU;
100 bool failIfMajorPerformanceCaveat; 100 bool failIfMajorPerformanceCaveat;
101 KURL topDocumentURL; 101 KURL topDocumentURL;
102 }; 102 };
103 103
104 class ContextLostCallback {
105 public:
106 virtual void onContextLost() = 0;
107 virtual ~ContextLostCallback() {}
108 };
109
110 class ErrorMessageCallback {
111 public:
112 virtual void onErrorMessage(const String& message, GLint id) = 0;
113 virtual ~ErrorMessageCallback() { }
114 };
115
116 void setContextLostCallback(PassOwnPtr<ContextLostCallback>);
117 void setErrorMessageCallback(PassOwnPtr<ErrorMessageCallback>);
118
119 // This is the preferred method for creating an instance of this class. When created this way the webContext 104 // This is the preferred method for creating an instance of this class. When created this way the webContext
120 // is not owned by the GraphicsContext3D 105 // is not owned by the GraphicsContext3D
121 static PassRefPtr<GraphicsContext3D> createContextSupport(blink::WebGraphics Context3D* webContext); 106 static PassRefPtr<GraphicsContext3D> createContextSupport(blink::WebGraphics Context3D* webContext);
122 107
123 // The following three creation methods are obsolete and should not be used by new code. They will be removed soon. 108 // The following three creation methods are obsolete and should not be used by new code. They will be removed soon.
124 109
125 // Callers must make the context current before using it AND check that the context was created successfully 110 // Callers must make the context current before using it AND check that the context was created successfully
126 // via ContextLost before using the context in any way. Once made current on a thread, the context cannot 111 // via ContextLost before using the context in any way. Once made current on a thread, the context cannot
127 // be used on any other thread. 112 // be used on any other thread.
128 static PassRefPtr<GraphicsContext3D> create(Attributes); 113 static PassRefPtr<GraphicsContext3D> create(Attributes);
129 static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(Pas sOwnPtr<blink::WebGraphicsContext3D>, bool preserveDrawingBuffer = false); 114 static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(Pas sOwnPtr<blink::WebGraphicsContext3D>, bool preserveDrawingBuffer = false);
130 static PassRefPtr<GraphicsContext3D> createGraphicsContextFromProvider(PassO wnPtr<blink::WebGraphicsContext3DProvider>, bool preserveDrawingBuffer = false); 115 static PassRefPtr<GraphicsContext3D> createGraphicsContextFromProvider(PassO wnPtr<blink::WebGraphicsContext3DProvider>, bool preserveDrawingBuffer = false);
131 116
132 117
133 ~GraphicsContext3D(); 118 ~GraphicsContext3D();
134 119
135 GrContext* grContext(); 120 GrContext* grContext();
136 blink::WebGraphicsContext3D* webContext() const { return m_impl; } 121 blink::WebGraphicsContext3D* webContext() const { return m_impl; }
137 122
138 bool makeContextCurrent(); 123 bool makeContextCurrent();
139 124
140 uint32_t lastFlushID();
141
142 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. 125 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0.
143 // Return true if no GL error is synthesized. 126 // Return true if no GL error is synthesized.
144 // By default, alignment is 4, the OpenGL default setting. 127 // By default, alignment is 4, the OpenGL default setting.
145 bool texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin t alignment = 4); 128 bool texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin t alignment = 4);
146 129
147 //---------------------------------------------------------------------- 130 //----------------------------------------------------------------------
148 // Helpers for texture uploading and pixel readback. 131 // Helpers for texture uploading and pixel readback.
149 // 132 //
150 133
151 // Computes the components per pixel and bytes per component 134 // Computes the components per pixel and bytes per component
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // Helper function which does a readback from the currently-bound 379 // Helper function which does a readback from the currently-bound
397 // framebuffer into a buffer of a certain size with 4-byte pixels. 380 // framebuffer into a buffer of a certain size with 4-byte pixels.
398 void readBackFramebuffer(unsigned char* pixels, int width, int height, Readb ackOrder, AlphaOp); 381 void readBackFramebuffer(unsigned char* pixels, int width, int height, Readb ackOrder, AlphaOp);
399 382
400 void setPackAlignment(GLint param); 383 void setPackAlignment(GLint param);
401 384
402 // Extension support. 385 // Extension support.
403 bool supportsExtension(const String& name); 386 bool supportsExtension(const String& name);
404 bool ensureExtensionEnabled(const String& name); 387 bool ensureExtensionEnabled(const String& name);
405 bool isExtensionEnabled(const String& name); 388 bool isExtensionEnabled(const String& name);
406 bool canUseCopyTextureCHROMIUM(GLenum destFormat, GLenum destType, GLint lev el); 389
390 static bool canUseCopyTextureCHROMIUM(GLenum destFormat, GLenum destType, GL int level);
407 391
408 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p remultiplyAlpha, ImageBuffer*); 392 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p remultiplyAlpha, ImageBuffer*);
409 393
410 private: 394 private:
411 GraphicsContext3D(PassOwnPtr<blink::WebGraphicsContext3D>, bool preserveDraw ingBuffer); 395 GraphicsContext3D(PassOwnPtr<blink::WebGraphicsContext3D>, bool preserveDraw ingBuffer);
412 GraphicsContext3D(PassOwnPtr<blink::WebGraphicsContext3DProvider>, bool pres erveDrawingBuffer); 396 GraphicsContext3D(PassOwnPtr<blink::WebGraphicsContext3DProvider>, bool pres erveDrawingBuffer);
413 GraphicsContext3D(blink::WebGraphicsContext3D* webContext); 397 GraphicsContext3D(blink::WebGraphicsContext3D* webContext);
414 398
415 // Helper for packImageData/extractImageData/extractTextureData which implem ent packing of pixel 399 // Helper for packImageData/extractImageData/extractTextureData which implem ent packing of pixel
416 // data into the specified OpenGL destination format and type. 400 // data into the specified OpenGL destination format and type.
417 // A sourceUnpackAlignment of zero indicates that the source 401 // A sourceUnpackAlignment of zero indicates that the source
418 // data is tightly packed. Non-zero values may take a slow path. 402 // data is tightly packed. Non-zero values may take a slow path.
419 // Destination data will have no gaps between rows. 403 // Destination data will have no gaps between rows.
420 // Implemented in GraphicsContext3DImagePacking.cpp 404 // Implemented in GraphicsContext3DImagePacking.cpp
421 static bool packPixels(const uint8_t* sourceData, DataFormat sourceDataForma t, unsigned width, unsigned height, unsigned sourceUnpackAlignment, unsigned des tinationFormat, unsigned destinationType, AlphaOp, void* destinationData, bool f lipY); 405 static bool packPixels(const uint8_t* sourceData, DataFormat sourceDataForma t, unsigned width, unsigned height, unsigned sourceUnpackAlignment, unsigned des tinationFormat, unsigned destinationType, AlphaOp, void* destinationData, bool f lipY);
422 406
423 // Helper function to flip a bitmap vertically. 407 // Helper function to flip a bitmap vertically.
424 void flipVertically(uint8_t* data, int width, int height); 408 void flipVertically(uint8_t* data, int width, int height);
425 409
426 void initializeExtensions(); 410 void initializeExtensions();
427 411
428 bool preserveDrawingBuffer() const { return m_preserveDrawingBuffer; }
429
430 OwnPtr<blink::WebGraphicsContext3DProvider> m_provider; 412 OwnPtr<blink::WebGraphicsContext3DProvider> m_provider;
431 blink::WebGraphicsContext3D* m_impl; 413 blink::WebGraphicsContext3D* m_impl;
432 OwnPtr<GraphicsContext3DContextLostCallbackAdapter> m_contextLostCallbackAda pter;
433 OwnPtr<GraphicsContext3DErrorMessageCallbackAdapter> m_errorMessageCallbackA dapter;
434 OwnPtr<blink::WebGraphicsContext3D> m_ownedWebContext; 414 OwnPtr<blink::WebGraphicsContext3D> m_ownedWebContext;
435 bool m_initializedAvailableExtensions; 415 bool m_initializedAvailableExtensions;
436 HashSet<String> m_enabledExtensions; 416 HashSet<String> m_enabledExtensions;
437 HashSet<String> m_requestableExtensions; 417 HashSet<String> m_requestableExtensions;
438 bool m_layerComposited; 418 bool m_layerComposited;
439 bool m_preserveDrawingBuffer; 419 bool m_preserveDrawingBuffer;
440 int m_packAlignment; 420 int m_packAlignment;
441 421
442 // If the width and height of the Canvas's backing store don't 422 // If the width and height of the Canvas's backing store don't
443 // match those that we were given in the most recent call to 423 // match those that we were given in the most recent call to
444 // reshape(), then we need an intermediate bitmap to read back the 424 // reshape(), then we need an intermediate bitmap to read back the
445 // frame buffer into. This seems to happen when CSS styles are 425 // frame buffer into. This seems to happen when CSS styles are
446 // used to resize the Canvas. 426 // used to resize the Canvas.
447 SkBitmap m_resizingBitmap; 427 SkBitmap m_resizingBitmap;
448 428
449 GrContext* m_grContext; 429 GrContext* m_grContext;
450 430
451 // Used to flip a bitmap vertically. 431 // Used to flip a bitmap vertically.
452 Vector<uint8_t> m_scanline; 432 Vector<uint8_t> m_scanline;
453 }; 433 };
454 434
455 } // namespace WebCore 435 } // namespace WebCore
456 436
457 #endif // GraphicsContext3D_h 437 #endif // GraphicsContext3D_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698