summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/resource.h
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer/service/resource.h')
-rw-r--r--gpu/command_buffer/service/resource.h240
1 files changed, 0 insertions, 240 deletions
diff --git a/gpu/command_buffer/service/resource.h b/gpu/command_buffer/service/resource.h
deleted file mode 100644
index 90bcb0f..0000000
--- a/gpu/command_buffer/service/resource.h
+++ /dev/null
@@ -1,240 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This file contains the definition for resource classes and the resource map.
-
-#ifndef GPU_COMMAND_BUFFER_SERVICE_RESOURCE_H_
-#define GPU_COMMAND_BUFFER_SERVICE_RESOURCE_H_
-
-#include <vector>
-#include "base/scoped_ptr.h"
-#include "gpu/command_buffer/common/resource.h"
-
-namespace gpu {
-
-// Base class for resources, just providing a common Destroy function.
-class Resource {
- public:
- Resource() {}
- virtual ~Resource() {}
- private:
- DISALLOW_COPY_AND_ASSIGN(Resource);
-};
-
-// VertexBuffer class, representing a vertex buffer resource.
-class VertexBuffer: public Resource {
- public:
- VertexBuffer(unsigned int size, unsigned int flags)
- : size_(size),
- flags_(flags) {}
- virtual ~VertexBuffer() {}
-
- // Returns the vertex buffer flags.
- unsigned int flags() const { return flags_; }
- // Sets the vertex buffer flags.
- void set_flags(unsigned int flags) { flags_ = flags; }
- // Returns the vertex buffer size.
- unsigned int size() const { return size_; }
- // Sets the vertex buffer size.
- void set_size(unsigned int size) { size_ = size; }
- protected:
- unsigned int size_;
- unsigned int flags_;
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexBuffer);
-};
-
-// IndexBuffer class, representing an index buffer resource.
-class IndexBuffer: public Resource {
- public:
- IndexBuffer(unsigned int size, unsigned int flags)
- : size_(size),
- flags_(flags) {}
- virtual ~IndexBuffer() {}
-
- // Returns the index buffer flags.
- unsigned int flags() const { return flags_; }
- // Sets the index buffer flags.
- void set_flags(unsigned int flags) { flags_ = flags; }
- // Returns the index buffer size.
- unsigned int size() const { return size_; }
- // Sets the index buffer size.
- void set_size(unsigned int size) { size_ = size; }
- protected:
- unsigned int size_;
- unsigned int flags_;
- private:
- DISALLOW_COPY_AND_ASSIGN(IndexBuffer);
-};
-
-// VertexStruct class, representing a vertex struct resource.
-class VertexStruct: public Resource {
- public:
- // The representation of an input data stream.
- struct Element {
- ResourceId vertex_buffer;
- unsigned int offset;
- unsigned int stride;
- vertex_struct::Type type;
- vertex_struct::Semantic semantic;
- unsigned int semantic_index;
- };
-
- explicit VertexStruct(unsigned int count)
- : count_(count),
- elements_(new Element[count]) {
- memset(elements_.get(), 0, count * sizeof(Element)); // NOLINT
- }
-
- // Returns the number of inputs in this struct.
- unsigned int count() const { return count_; }
- // Returns an element by index.
- Element &GetElement(unsigned int i) {
- DCHECK_GT(count_, i);
- return elements_[i];
- }
- protected:
- unsigned int count_;
- scoped_array<Element> elements_;
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexStruct);
-};
-
-// Effect class, representing an effect.
-class Effect: public Resource {
- public:
- Effect() {}
- private:
- DISALLOW_COPY_AND_ASSIGN(Effect);
-};
-
-// EffectParam class, representing an effect parameter.
-class EffectParam: public Resource {
- public:
- explicit EffectParam(effect_param::DataType data_type)
- : data_type_(data_type) {
- }
-
- // Gets the data type of this parameter.
- effect_param::DataType data_type() const { return data_type_; }
- private:
- effect_param::DataType data_type_;
- DISALLOW_COPY_AND_ASSIGN(EffectParam);
-};
-
-// Texture class, representing a texture resource.
-class Texture: public Resource {
- public:
- Texture(texture::Type type,
- unsigned int levels,
- texture::Format format,
- bool enable_render_surfaces,
- unsigned int flags)
- : type_(type),
- levels_(levels),
- format_(format),
- render_surfaces_enabled_(enable_render_surfaces),
- flags_(flags) {}
- virtual ~Texture() {}
-
- // Returns the type of the texture.
- texture::Type type() const { return type_; }
- // Returns the texture flags.
- unsigned int flags() const { return flags_; }
- // Returns the texture format.
- texture::Format format() const { return format_; }
- // Returns whether the texture supports render surfaces
- bool render_surfaces_enabled() const { return render_surfaces_enabled_; }
- // Returns the number of mipmap levels in the texture.
- unsigned int levels() const { return levels_; }
- private:
- texture::Type type_;
- unsigned int levels_;
- texture::Format format_;
- bool render_surfaces_enabled_;
- unsigned int flags_;
- DISALLOW_COPY_AND_ASSIGN(Texture);
-};
-
-// RenderSurface class, representing a render surface/target
-class RenderSurface: public Resource {
- public:
- RenderSurface() {}
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderSurface);
-};
-
-// RenderSurface class, representing a render surface/target
-class RenderDepthStencilSurface: public Resource {
- public:
- RenderDepthStencilSurface() {}
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderDepthStencilSurface);
-};
-
-
-// Texture class, representing a sampler resource.
-class Sampler: public Resource {
- public:
- Sampler() {}
- private:
- DISALLOW_COPY_AND_ASSIGN(Sampler);
-};
-
-// Base of ResourceMap. Contains most of the implementation of ResourceMap, to
-// avoid template bloat.
-class ResourceMapBase {
- public:
- ResourceMapBase() : resources_() {}
- ~ResourceMapBase() {}
-
- // Assigns a resource to a resource ID. Assigning a resource to an ID that
- // already has an existing resource will destroy that existing resource. The
- // map takes ownership of the resource.
- void Assign(ResourceId id, Resource* resource);
- // Destroys a resource.
- bool Destroy(ResourceId id);
- // Destroy all resources.
- void DestroyAllResources();
- // Gets a resource by ID.
- Resource *Get(ResourceId id) {
- return (id < resources_.size()) ? resources_[id] : NULL;
- }
- private:
- typedef std::vector<Resource *> Container;
- Container resources_;
-};
-
-// Resource Map class, allowing resource ID <-> Resource association. This is a
-// dense map, optimized for retrieval (O(1)).
-template<class T> class ResourceMap {
- public:
- ResourceMap() : container_() {}
- ~ResourceMap() {}
-
- // Assigns a resource to a resource ID. Assigning a resource to an ID that
- // already has an existing resource will destroy that existing resource. The
- // map takes ownership of the resource.
- void Assign(ResourceId id, T* resource) {
- container_.Assign(id, resource);
- }
- // Destroys a resource.
- bool Destroy(ResourceId id) {
- return container_.Destroy(id);
- }
- // Destroy all resources.
- void DestroyAllResources() {
- return container_.DestroyAllResources();
- }
- // Gets a resource by ID.
- T *Get(ResourceId id) {
- return static_cast<T*>(container_.Get(id));
- }
- private:
- ResourceMapBase container_;
-};
-
-} // namespace gpu
-
-#endif // GPU_COMMAND_BUFFER_SERVICE_RESOURCE_H_