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 #include "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "cc/base/util.h" | 15 #include "cc/base/util.h" |
16 #include "cc/output/gl_renderer.h" // For the GLC() macro. | 16 #include "cc/output/gl_renderer.h" // For the GLC() macro. |
17 #include "cc/resources/platform_color.h" | 17 #include "cc/resources/platform_color.h" |
18 #include "cc/resources/returned_resource.h" | 18 #include "cc/resources/returned_resource.h" |
19 #include "cc/resources/shared_bitmap_manager.h" | 19 #include "cc/resources/shared_bitmap_manager.h" |
20 #include "cc/resources/transferable_resource.h" | 20 #include "cc/resources/transferable_resource.h" |
21 #include "cc/scheduler/texture_uploader.h" | 21 #include "cc/scheduler/texture_uploader.h" |
22 #include "gpu/GLES2/gl2extchromium.h" | 22 #include "gpu/GLES2/gl2extchromium.h" |
23 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 23 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
24 #include "third_party/khronos/GLES2/gl2.h" | 24 #include "third_party/khronos/GLES2/gl2.h" |
25 #include "third_party/khronos/GLES2/gl2ext.h" | 25 #include "third_party/khronos/GLES2/gl2ext.h" |
26 #include "ui/gfx/rect.h" | 26 #include "ui/gfx/rect.h" |
27 #include "ui/gfx/vector2d.h" | 27 #include "ui/gfx/vector2d.h" |
28 | 28 |
29 using WebKit::WebGraphicsContext3D; | 29 using blink::WebGraphicsContext3D; |
30 | 30 |
31 namespace cc { | 31 namespace cc { |
32 | 32 |
33 class IdAllocator { | 33 class IdAllocator { |
34 public: | 34 public: |
35 virtual ~IdAllocator() {} | 35 virtual ~IdAllocator() {} |
36 | 36 |
37 virtual unsigned NextId() = 0; | 37 virtual unsigned NextId() = 0; |
38 | 38 |
39 protected: | 39 protected: |
40 IdAllocator(WebGraphicsContext3D* context3d, size_t id_allocation_chunk_size) | 40 IdAllocator(WebGraphicsContext3D* context3d, size_t id_allocation_chunk_size) |
41 : context3d_(context3d), | 41 : context3d_(context3d), |
42 id_allocation_chunk_size_(id_allocation_chunk_size), | 42 id_allocation_chunk_size_(id_allocation_chunk_size), |
43 ids_(new WebKit::WebGLId[id_allocation_chunk_size]), | 43 ids_(new blink::WebGLId[id_allocation_chunk_size]), |
44 next_id_index_(id_allocation_chunk_size) { | 44 next_id_index_(id_allocation_chunk_size) { |
45 DCHECK(id_allocation_chunk_size_); | 45 DCHECK(id_allocation_chunk_size_); |
46 } | 46 } |
47 | 47 |
48 WebGraphicsContext3D* context3d_; | 48 WebGraphicsContext3D* context3d_; |
49 const size_t id_allocation_chunk_size_; | 49 const size_t id_allocation_chunk_size_; |
50 scoped_ptr<WebKit::WebGLId[]> ids_; | 50 scoped_ptr<blink::WebGLId[]> ids_; |
51 size_t next_id_index_; | 51 size_t next_id_index_; |
52 }; | 52 }; |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 // Measured in seconds. | 56 // Measured in seconds. |
57 const double kSoftwareUploadTickRate = 0.000250; | 57 const double kSoftwareUploadTickRate = 0.000250; |
58 const double kTextureUploadTickRate = 0.004; | 58 const double kTextureUploadTickRate = 0.004; |
59 | 59 |
60 GLenum TextureToStorageFormat(ResourceFormat format) { | 60 GLenum TextureToStorageFormat(ResourceFormat format) { |
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 return NULL; | 1803 return NULL; |
1804 return resource->shared_bitmap->memory(); | 1804 return resource->shared_bitmap->memory(); |
1805 } | 1805 } |
1806 | 1806 |
1807 GLint ResourceProvider::GetActiveTextureUnit(WebGraphicsContext3D* context) { | 1807 GLint ResourceProvider::GetActiveTextureUnit(WebGraphicsContext3D* context) { |
1808 GLint active_unit = 0; | 1808 GLint active_unit = 0; |
1809 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 1809 context->getIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
1810 return active_unit; | 1810 return active_unit; |
1811 } | 1811 } |
1812 | 1812 |
1813 WebKit::WebGraphicsContext3D* ResourceProvider::Context3d() const { | 1813 blink::WebGraphicsContext3D* ResourceProvider::Context3d() const { |
1814 ContextProvider* context_provider = output_surface_->context_provider(); | 1814 ContextProvider* context_provider = output_surface_->context_provider(); |
1815 return context_provider ? context_provider->Context3d() : NULL; | 1815 return context_provider ? context_provider->Context3d() : NULL; |
1816 } | 1816 } |
1817 | 1817 |
1818 } // namespace cc | 1818 } // namespace cc |
OLD | NEW |