| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CCRenderer_h | 5 #ifndef CCRenderer_h |
| 6 #define CCRenderer_h | 6 #define CCRenderer_h |
| 7 | 7 |
| 8 #include "CCLayerTreeHost.h" | 8 #include "CCLayerTreeHost.h" |
| 9 #include "CCRenderPass.h" | 9 #include "CCRenderPass.h" |
| 10 #include "FloatQuad.h" | 10 #include "FloatQuad.h" |
| 11 #include "IntRect.h" | |
| 12 #include <wtf/Noncopyable.h> | 11 #include <wtf/Noncopyable.h> |
| 13 #include <wtf/PassRefPtr.h> | 12 #include <wtf/PassRefPtr.h> |
| 14 | 13 |
| 15 namespace cc { | 14 namespace cc { |
| 16 | 15 |
| 17 class CCScopedTexture; | 16 class CCScopedTexture; |
| 18 | 17 |
| 19 class CCRendererClient { | 18 class CCRendererClient { |
| 20 public: | 19 public: |
| 21 virtual const IntSize& deviceViewportSize() const = 0; | 20 virtual const cc::IntSize& deviceViewportSize() const = 0; |
| 22 virtual const CCLayerTreeSettings& settings() const = 0; | 21 virtual const CCLayerTreeSettings& settings() const = 0; |
| 23 virtual void didLoseContext() = 0; | 22 virtual void didLoseContext() = 0; |
| 24 virtual void onSwapBuffersComplete() = 0; | 23 virtual void onSwapBuffersComplete() = 0; |
| 25 virtual void releaseContentsTextures() = 0; | 24 virtual void releaseContentsTextures() = 0; |
| 26 virtual void setFullRootLayerDamage() = 0; | 25 virtual void setFullRootLayerDamage() = 0; |
| 27 virtual void setMemoryAllocationLimitBytes(size_t) = 0; | 26 virtual void setMemoryAllocationLimitBytes(size_t) = 0; |
| 28 protected: | 27 protected: |
| 29 virtual ~CCRendererClient() { } | 28 virtual ~CCRendererClient() { } |
| 30 }; | 29 }; |
| 31 | 30 |
| 32 class CCRenderer { | 31 class CCRenderer { |
| 33 WTF_MAKE_NONCOPYABLE(CCRenderer); | 32 WTF_MAKE_NONCOPYABLE(CCRenderer); |
| 34 public: | 33 public: |
| 35 // This enum defines the various resource pools for the CCResourceProvider | 34 // This enum defines the various resource pools for the CCResourceProvider |
| 36 // where textures get allocated. | 35 // where textures get allocated. |
| 37 enum ResourcePool { | 36 enum ResourcePool { |
| 38 ImplPool = 1, // This pool is for textures that get allocated on the impl
thread (e.g. RenderSurfaces). | 37 ImplPool = 1, // This pool is for textures that get allocated on the impl
thread (e.g. RenderSurfaces). |
| 39 ContentPool // This pool is for textures that get allocated on the main th
read (e.g. tiles). | 38 ContentPool // This pool is for textures that get allocated on the main th
read (e.g. tiles). |
| 40 }; | 39 }; |
| 41 | 40 |
| 42 virtual ~CCRenderer() { } | 41 virtual ~CCRenderer() { } |
| 43 | 42 |
| 44 virtual const RendererCapabilities& capabilities() const = 0; | 43 virtual const RendererCapabilities& capabilities() const = 0; |
| 45 | 44 |
| 46 const CCLayerTreeSettings& settings() const { return m_client->settings(); } | 45 const CCLayerTreeSettings& settings() const { return m_client->settings(); } |
| 47 | 46 |
| 48 const IntSize& viewportSize() { return m_client->deviceViewportSize(); } | 47 ccmath::IntSize viewportSize() { return m_client->deviceViewportSize(); } |
| 49 int viewportWidth() { return viewportSize().width(); } | 48 int viewportWidth() { return viewportSize().width(); } |
| 50 int viewportHeight() { return viewportSize().height(); } | 49 int viewportHeight() { return viewportSize().height(); } |
| 51 | 50 |
| 52 virtual void viewportChanged() { } | 51 virtual void viewportChanged() { } |
| 53 | 52 |
| 54 virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) {
} | 53 virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) {
} |
| 55 virtual bool haveCachedResourcesForRenderPassId(CCRenderPass::Id) const; | 54 virtual bool haveCachedResourcesForRenderPassId(CCRenderPass::Id) const; |
| 56 | 55 |
| 57 virtual void drawFrame(const CCRenderPassList&, const CCRenderPassIdHashMap&
) = 0; | 56 virtual void drawFrame(const CCRenderPassList&, const CCRenderPassIdHashMap&
) = 0; |
| 58 | 57 |
| 59 // waits for rendering to finish | 58 // waits for rendering to finish |
| 60 virtual void finish() = 0; | 59 virtual void finish() = 0; |
| 61 | 60 |
| 62 virtual void doNoOp() { } | 61 virtual void doNoOp() { } |
| 63 // puts backbuffer onscreen | 62 // puts backbuffer onscreen |
| 64 virtual bool swapBuffers() = 0; | 63 virtual bool swapBuffers() = 0; |
| 65 | 64 |
| 66 virtual void getFramebufferPixels(void *pixels, const IntRect&) = 0; | 65 virtual void getFramebufferPixels(void *pixels, const cc::IntRect&) = 0; |
| 67 | 66 |
| 68 virtual bool isContextLost(); | 67 virtual bool isContextLost(); |
| 69 | 68 |
| 70 virtual void setVisible(bool) = 0; | 69 virtual void setVisible(bool) = 0; |
| 71 | 70 |
| 72 protected: | 71 protected: |
| 73 explicit CCRenderer(CCRendererClient* client) | 72 explicit CCRenderer(CCRendererClient* client) |
| 74 : m_client(client) | 73 : m_client(client) |
| 75 { | 74 { |
| 76 } | 75 } |
| 77 | 76 |
| 78 CCRendererClient* m_client; | 77 CCRendererClient* m_client; |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 } | 80 } |
| 82 | 81 |
| 83 #endif // CCRenderer_h | 82 #endif // CCRenderer_h |
| OLD | NEW |