| Index: gpu/tools/compositor_model_bench/render_model_utils.h
|
| diff --git a/gpu/tools/compositor_model_bench/render_model_utils.h b/gpu/tools/compositor_model_bench/render_model_utils.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8880b42596dd9c073d22b1e5b037bdb5c1442f7d
|
| --- /dev/null
|
| +++ b/gpu/tools/compositor_model_bench/render_model_utils.h
|
| @@ -0,0 +1,62 @@
|
| +// Copyright (c) 2011 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.
|
| +
|
| +// Whole-tree processing that's likely to be helpful in multiple render models.
|
| +
|
| +#ifndef GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_MODEL_UTILS_H_
|
| +#define GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_MODEL_UTILS_H_
|
| +
|
| +#include <map>
|
| +#include <set>
|
| +#include <vector>
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "gpu/tools/compositor_model_bench/render_tree.h"
|
| +
|
| +// This is a visitor that runs over the tree structure that was built from the
|
| +// configuration file. It creates OpenGL textures (random checkerboards) that
|
| +// match the specifications of the original textures and overwrites the old
|
| +// texture ID's in the tree, replacing them with the matching new textures.
|
| +class TextureGenerator : public RenderNodeVisitor {
|
| + public:
|
| + typedef scoped_array<uint8> ImagePtr;
|
| + typedef std::vector<Tile>::iterator tile_iter;
|
| +
|
| + explicit TextureGenerator(RenderNode* root);
|
| + virtual ~TextureGenerator() OVERRIDE;
|
| +
|
| + // RenderNodeVisitor functions look for textures and pass them
|
| + // off to HandleTexture (which behaves appropriately depending
|
| + // on which pass we are in.)
|
| + virtual void BeginVisitRenderNode(RenderNode* node) OVERRIDE;
|
| + virtual void BeginVisitCCNode(CCNode* node) OVERRIDE;
|
| +
|
| + private:
|
| + enum TextureGenStage {
|
| + DiscoveryStage,
|
| + RemappingStage,
|
| + ImageGenerationStage
|
| + };
|
| +
|
| + void DiscoverInputIDs(RenderNode* root);
|
| + void GenerateGLTexIDs();
|
| + void AssignIDMapping();
|
| + void WriteOutNewIDs(RenderNode* root);
|
| + void AllocateImageArray();
|
| + void BuildTextureImages(RenderNode* root);
|
| + void HandleTexture(int* texID, int width, int height, GLenum format);
|
| + void GenerateImageForTexture(int texID, int width, int height, GLenum format);
|
| +
|
| + TextureGenStage stage_;
|
| + std::set<int> discovered_ids_;
|
| + scoped_array<GLuint> tex_ids_;
|
| + std::map<int, int> remapped_ids_;
|
| + scoped_array<ImagePtr> image_data_;
|
| + int images_generated_;
|
| + std::set<int> ids_for_completed_textures_;
|
| +};
|
| +
|
| +#endif // GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_MODEL_UTILS_H_
|
| +
|
|
|