| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "CCLayerTreeHost.h" | 9 #include "CCLayerTreeHost.h" |
| 10 #include "CCRenderPass.h" | 10 #include "CCRenderPass.h" |
| 11 #include "FloatQuad.h" | 11 #include "FloatQuad.h" |
| 12 #include "IntRect.h" | 12 #include "IntRect.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 class CCScopedTexture; | 16 class ScopedTexture; |
| 17 | 17 |
| 18 class CCRendererClient { | 18 class RendererClient { |
| 19 public: | 19 public: |
| 20 virtual const IntSize& deviceViewportSize() const = 0; | 20 virtual const IntSize& deviceViewportSize() const = 0; |
| 21 virtual const CCLayerTreeSettings& settings() const = 0; | 21 virtual const LayerTreeSettings& settings() const = 0; |
| 22 virtual void didLoseContext() = 0; | 22 virtual void didLoseContext() = 0; |
| 23 virtual void onSwapBuffersComplete() = 0; | 23 virtual void onSwapBuffersComplete() = 0; |
| 24 virtual void setFullRootLayerDamage() = 0; | 24 virtual void setFullRootLayerDamage() = 0; |
| 25 virtual void setMemoryAllocationLimitBytes(size_t) = 0; | 25 virtual void setMemoryAllocationLimitBytes(size_t) = 0; |
| 26 protected: | 26 protected: |
| 27 virtual ~CCRendererClient() { } | 27 virtual ~RendererClient() { } |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 class CCRenderer { | 30 class Renderer { |
| 31 public: | 31 public: |
| 32 // This enum defines the various resource pools for the CCResourceProvider | 32 // This enum defines the various resource pools for the ResourceProvider |
| 33 // where textures get allocated. | 33 // where textures get allocated. |
| 34 enum ResourcePool { | 34 enum ResourcePool { |
| 35 ImplPool = 1, // This pool is for textures that get allocated on the impl
thread (e.g. RenderSurfaces). | 35 ImplPool = 1, // This pool is for textures that get allocated on the impl
thread (e.g. RenderSurfaces). |
| 36 ContentPool // This pool is for textures that get allocated on the main th
read (e.g. tiles). | 36 ContentPool // This pool is for textures that get allocated on the main th
read (e.g. tiles). |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 virtual ~CCRenderer() { } | 39 virtual ~Renderer() { } |
| 40 | 40 |
| 41 virtual const RendererCapabilities& capabilities() const = 0; | 41 virtual const RendererCapabilities& capabilities() const = 0; |
| 42 | 42 |
| 43 const CCLayerTreeSettings& settings() const { return m_client->settings(); } | 43 const LayerTreeSettings& settings() const { return m_client->settings(); } |
| 44 | 44 |
| 45 const IntSize& viewportSize() { return m_client->deviceViewportSize(); } | 45 const IntSize& viewportSize() { return m_client->deviceViewportSize(); } |
| 46 int viewportWidth() { return viewportSize().width(); } | 46 int viewportWidth() { return viewportSize().width(); } |
| 47 int viewportHeight() { return viewportSize().height(); } | 47 int viewportHeight() { return viewportSize().height(); } |
| 48 | 48 |
| 49 virtual void viewportChanged() { } | 49 virtual void viewportChanged() { } |
| 50 | 50 |
| 51 virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) {
} | 51 virtual void decideRenderPassAllocationsForFrame(const RenderPassList&) { } |
| 52 virtual bool haveCachedResourcesForRenderPassId(CCRenderPass::Id) const; | 52 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id) const; |
| 53 | 53 |
| 54 virtual void drawFrame(const CCRenderPassList&, const CCRenderPassIdHashMap&
) = 0; | 54 virtual void drawFrame(const RenderPassList&, const RenderPassIdHashMap&) =
0; |
| 55 | 55 |
| 56 // waits for rendering to finish | 56 // waits for rendering to finish |
| 57 virtual void finish() = 0; | 57 virtual void finish() = 0; |
| 58 | 58 |
| 59 virtual void doNoOp() { } | 59 virtual void doNoOp() { } |
| 60 // puts backbuffer onscreen | 60 // puts backbuffer onscreen |
| 61 virtual bool swapBuffers() = 0; | 61 virtual bool swapBuffers() = 0; |
| 62 | 62 |
| 63 virtual void getFramebufferPixels(void *pixels, const IntRect&) = 0; | 63 virtual void getFramebufferPixels(void *pixels, const IntRect&) = 0; |
| 64 | 64 |
| 65 virtual bool isContextLost(); | 65 virtual bool isContextLost(); |
| 66 | 66 |
| 67 virtual void setVisible(bool) = 0; | 67 virtual void setVisible(bool) = 0; |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 explicit CCRenderer(CCRendererClient* client) | 70 explicit Renderer(RendererClient* client) |
| 71 : m_client(client) | 71 : m_client(client) |
| 72 { | 72 { |
| 73 } | 73 } |
| 74 | 74 |
| 75 CCRendererClient* m_client; | 75 RendererClient* m_client; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(CCRenderer); | 77 DISALLOW_COPY_AND_ASSIGN(Renderer); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } | 80 } |
| 81 | 81 |
| 82 #endif // CCRenderer_h | 82 #endif // CCRenderer_h |
| OLD | NEW |