| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_GFX_COMPOSITOR_COMPOSITOR_CC_H_ | |
| 6 #define UI_GFX_COMPOSITOR_COMPOSITOR_CC_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/memory/singleton.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "ui/gfx/compositor/compositor.h" | |
| 13 #include "ui/gfx/size.h" | |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebLayer.h" | |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebLayerTree
View.h" | |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebLayerTree
ViewClient.h" | |
| 17 | |
| 18 namespace gfx { | |
| 19 class Rect; | |
| 20 class GLContext; | |
| 21 class GLSurface; | |
| 22 class GLShareGroup; | |
| 23 } | |
| 24 | |
| 25 namespace ui { | |
| 26 | |
| 27 class COMPOSITOR_EXPORT SharedResourcesCC | |
| 28 : NON_EXPORTED_BASE(public SharedResources) { | |
| 29 public: | |
| 30 static SharedResourcesCC* GetInstance(); | |
| 31 | |
| 32 virtual gfx::ScopedMakeCurrent* GetScopedMakeCurrent() OVERRIDE; | |
| 33 | |
| 34 virtual void* GetDisplay() OVERRIDE; | |
| 35 | |
| 36 gfx::GLShareGroup* GetShareGroup(); | |
| 37 | |
| 38 private: | |
| 39 friend struct DefaultSingletonTraits<SharedResourcesCC>; | |
| 40 | |
| 41 SharedResourcesCC(); | |
| 42 virtual ~SharedResourcesCC(); | |
| 43 | |
| 44 bool Initialize(); | |
| 45 void Destroy(); | |
| 46 | |
| 47 bool initialized_; | |
| 48 | |
| 49 scoped_refptr<gfx::GLContext> context_; | |
| 50 scoped_refptr<gfx::GLSurface> surface_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(SharedResourcesCC); | |
| 53 }; | |
| 54 | |
| 55 class COMPOSITOR_EXPORT TextureCC : public Texture { | |
| 56 public: | |
| 57 TextureCC(); | |
| 58 | |
| 59 // Texture implementation. | |
| 60 virtual void SetCanvas(const SkCanvas& canvas, | |
| 61 const gfx::Point& origin, | |
| 62 const gfx::Size& overall_size) OVERRIDE; | |
| 63 | |
| 64 virtual void Draw(const ui::TextureDrawParams& params, | |
| 65 const gfx::Rect& clip_bounds_in_texture) OVERRIDE; | |
| 66 | |
| 67 virtual void Update() = 0; | |
| 68 unsigned int texture_id() const { return texture_id_; } | |
| 69 bool flipped() const { return flipped_; } | |
| 70 const gfx::Size& size() const { return size_; } | |
| 71 | |
| 72 protected: | |
| 73 unsigned int texture_id_; | |
| 74 bool flipped_; | |
| 75 gfx::Size size_; | |
| 76 DISALLOW_COPY_AND_ASSIGN(TextureCC); | |
| 77 }; | |
| 78 | |
| 79 class COMPOSITOR_EXPORT CompositorCC | |
| 80 : public Compositor, | |
| 81 NON_EXPORTED_BASE(public WebKit::WebLayerTreeViewClient) { | |
| 82 public: | |
| 83 CompositorCC(CompositorDelegate* delegate, | |
| 84 gfx::AcceleratedWidget widget, | |
| 85 const gfx::Size& size); | |
| 86 virtual ~CompositorCC(); | |
| 87 | |
| 88 static void Initialize(bool useThread); | |
| 89 static void Terminate(); | |
| 90 | |
| 91 protected: | |
| 92 // Compositor implementation. | |
| 93 virtual Texture* CreateTexture() OVERRIDE; | |
| 94 virtual void Blur(const gfx::Rect& bounds) OVERRIDE; | |
| 95 virtual void ScheduleDraw() OVERRIDE; | |
| 96 virtual void OnNotifyStart(bool clear) OVERRIDE; | |
| 97 virtual void OnNotifyEnd() OVERRIDE; | |
| 98 virtual void OnWidgetSizeChanged() OVERRIDE; | |
| 99 virtual void OnRootLayerChanged() OVERRIDE; | |
| 100 virtual void DrawTree() OVERRIDE; | |
| 101 virtual bool CompositesAsynchronously() OVERRIDE; | |
| 102 virtual bool ReadPixels(SkBitmap* bitmap, const gfx::Rect& bounds) OVERRIDE; | |
| 103 | |
| 104 // WebLayerTreeViewClient implementation. | |
| 105 // TODO(jamesr): Remove this override once upstream declaration is removed and | |
| 106 // rolled into DEPS | |
| 107 virtual void animateAndLayout(double frameBeginTime); | |
| 108 | |
| 109 virtual void updateAnimations(double frameBeginTime); | |
| 110 virtual void layout(); | |
| 111 virtual void applyScrollAndScale(const WebKit::WebSize& scrollDelta, | |
| 112 float scaleFactor); | |
| 113 virtual void applyScrollDelta(const WebKit::WebSize&); | |
| 114 virtual WebKit::WebGraphicsContext3D* createContext3D(); | |
| 115 virtual void didCompleteSwapBuffers(); | |
| 116 virtual void didRebindGraphicsContext(bool success); | |
| 117 virtual void scheduleComposite(); | |
| 118 | |
| 119 private: | |
| 120 gfx::AcceleratedWidget widget_; | |
| 121 WebKit::WebLayer root_web_layer_; | |
| 122 WebKit::WebLayerTreeView host_; | |
| 123 | |
| 124 DISALLOW_COPY_AND_ASSIGN(CompositorCC); | |
| 125 }; | |
| 126 | |
| 127 } // namespace ui | |
| 128 | |
| 129 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_CC_H_ | |
| OLD | NEW |