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

Side by Side Diff: Source/core/platform/chromium/support/GraphicsContext3DPrivate.h

Issue 15301006: Merged GraphicsContext3DPrivate into GraphicsContext3D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed ExtractWebGraphicsContext3D Created 7 years, 7 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
(Empty)
1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef GraphicsContext3DPrivate_h
27 #define GraphicsContext3DPrivate_h
28
29 #include "SkBitmap.h"
30 #include "core/platform/graphics/Extensions3D.h"
31 #include "core/platform/graphics/GraphicsContext3D.h"
32 #include <wtf/HashSet.h>
33 #include <wtf/OwnArrayPtr.h>
34 #include <wtf/OwnPtr.h>
35
36 class GrContext;
37
38 namespace WebKit {
39 class WebGraphicsContext3D;
40 class WebGraphicsContext3DProvider;
41 }
42
43 namespace WebCore {
44
45 class DrawingBuffer;
46 class Extensions3D;
47 class GraphicsContext3DContextLostCallbackAdapter;
48 class GraphicsContext3DErrorMessageCallbackAdapter;
49 class GrMemoryAllocationChangedCallbackAdapter;
50
51 class GraphicsContext3DPrivate {
52 public:
53 // Callers must make the context current before using it AND check that the context was created successfully
54 // via ContextLost before using the context in any way. Once made current on a thread, the context cannot
55 // be used on any other thread.
56 static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(Pas sOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDrawingBuffer = false);
57
58 static PassRefPtr<GraphicsContext3D> createGraphicsContextFromProvider(PassO wnPtr<WebKit::WebGraphicsContext3DProvider>, bool preserveDrawingBuffer = false) ;
59
60 // Helper function to provide access to the lower-level WebGraphicsContext3D ,
61 // which is needed for subordinate contexts like WebGL's to share resources
62 // with the compositor's context.
63 static WebKit::WebGraphicsContext3D* extractWebGraphicsContext3D(GraphicsCon text3D*);
64
65 virtual ~GraphicsContext3DPrivate();
66
67 WebKit::WebGraphicsContext3D* webContext() const { return m_impl; }
68
69 GrContext* grContext();
70
71 void markContextChanged();
72 bool layerComposited() const;
73 void markLayerComposited();
74
75 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p remultiplyAlpha, ImageBuffer*);
76
77 void setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallbac k>);
78 void setErrorMessageCallback(PassOwnPtr<GraphicsContext3D::ErrorMessageCallb ack>);
79
80 // Extensions3D support.
81 Extensions3D* getExtensions();
82 bool supportsExtension(const String& name);
83 bool ensureExtensionEnabled(const String& name);
84 bool isExtensionEnabled(const String& name);
85
86 bool isResourceSafe();
87
88 bool preserveDrawingBuffer() const { return m_preserveDrawingBuffer; }
89
90 private:
91 GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool pres erveDrawingBuffer);
92 GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphicsContext3DProvider>, b ool preserveDrawingBuffer);
93
94 void initializeExtensions();
95
96 OwnPtr<WebKit::WebGraphicsContext3DProvider> m_provider;
97 WebKit::WebGraphicsContext3D* m_impl;
98 OwnPtr<WebKit::WebGraphicsContext3D> m_ownedWebContext;
99 OwnPtr<Extensions3D> m_extensions;
100 OwnPtr<GraphicsContext3DContextLostCallbackAdapter> m_contextLostCallbackAda pter;
101 OwnPtr<GraphicsContext3DErrorMessageCallbackAdapter> m_errorMessageCallbackA dapter;
102 OwnPtr<GrMemoryAllocationChangedCallbackAdapter> m_grContextMemoryAllocation CallbackAdapter;
103 bool m_initializedAvailableExtensions;
104 HashSet<String> m_enabledExtensions;
105 HashSet<String> m_requestableExtensions;
106 bool m_layerComposited;
107 bool m_preserveDrawingBuffer;
108
109 enum ResourceSafety {
110 ResourceSafetyUnknown,
111 ResourceSafe,
112 ResourceUnsafe
113 };
114 ResourceSafety m_resourceSafety;
115
116 // If the width and height of the Canvas's backing store don't
117 // match those that we were given in the most recent call to
118 // reshape(), then we need an intermediate bitmap to read back the
119 // frame buffer into. This seems to happen when CSS styles are
120 // used to resize the Canvas.
121 SkBitmap m_resizingBitmap;
122
123 GrContext* m_grContext;
124 SkAutoTUnref<GrContext> m_ownedGrContext;
125 };
126
127 } // namespace WebCore
128
129 #endif // GraphicsContext3DPrivate_h
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.cpp ('k') | Source/core/platform/chromium/support/GraphicsContext3DPrivate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698