From e22495903bd60a251c8cad8abc5302d22c095c17 Mon Sep 17 00:00:00 2001 From: "reveman@chromium.org" Date: Fri, 19 Oct 2012 06:59:09 +0000 Subject: cc: Remove all but one texture uploader class. This reduces the number of texture uploader classes from 4 to 1. - TextureUploader - ThrottledTextureUploader - UnthrottledTextureUploader - LayerTextureSubImage becomes - TextureUploader and it lives behind the CCResourceProvider interface where the LayerTextureSubImage instance used to be. This also makes the call stack when performing a texture upload less awkward. It used to look like this: CCTextureUpdateController::updateMoreTexturesNow() -> ThrottledTextureUploader::updateTexture() -> CCPrioritizedTexture::upload() -> CCResourceProvider::upload() -> LayerTextureSubImage::upload() -> glTexSubImage2D() but now looks like this: CCTextureUpdateController::updateMoreTexturesNow() -> CCPrioritizedTexture::upload() -> CCResourceProvider::upload() -> TextureUploader::upload() -> glTexSubImage2D() which makes a lot more sense considering that CCTextureUpdateController::updateMoreTexturesNow() should really be called CCResourceUpdateController::updateMoreResourcesNow() and CCPrioritizedTexture::upload() should be CCPrioritizedResource::update(). This is only refactoring and should not change the behavior of the compositor in any way. BUG= TEST=cc_unittests Review URL: https://chromiumcodereview.appspot.com/11188055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162951 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/texture_uploader.h | 104 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 82 insertions(+), 22 deletions(-) (limited to 'cc/texture_uploader.h') diff --git a/cc/texture_uploader.h b/cc/texture_uploader.h index 967eb23..a78b4c1 100644 --- a/cc/texture_uploader.h +++ b/cc/texture_uploader.h @@ -2,36 +2,96 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef TextureUploader_h -#define TextureUploader_h +#ifndef CC_TEXTURE_UPLOADER_H_ +#define CC_TEXTURE_UPLOADER_H_ #include "IntRect.h" +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "cc/scoped_ptr_deque.h" +#include +#include "third_party/khronos/GLES2/gl2.h" -class SkBitmap; -class SkPicture; +namespace WebKit { +class WebGraphicsContext3D; +} namespace cc { -class CCPrioritizedTexture; -class CCResourceProvider; - class TextureUploader { public: - virtual ~TextureUploader() { } - - virtual size_t numBlockingUploads() = 0; - virtual void markPendingUploadsAsNonBlocking() = 0; - - // Returns our throughput on the GPU process - virtual double estimatedTexturesPerSecond() = 0; - virtual void uploadTexture(CCResourceProvider*, - CCPrioritizedTexture*, - const SkBitmap*, - IntRect content_rect, - IntRect source_rect, - IntSize dest_offset) = 0; + static scoped_ptr create( + WebKit::WebGraphicsContext3D* context, bool useMapTexSubImage) + { + return make_scoped_ptr(new TextureUploader(context, useMapTexSubImage)); + } + ~TextureUploader(); + + size_t numBlockingUploads(); + void markPendingUploadsAsNonBlocking(); + double estimatedTexturesPerSecond(); + void upload(const uint8_t* image, + const IntRect& content_rect, + const IntRect& source_rect, + const IntSize& dest_offset, + GLenum format, + IntSize size); + +private: + class Query { + public: + static scoped_ptr create(WebKit::WebGraphicsContext3D* context) { return make_scoped_ptr(new Query(context)); } + + virtual ~Query(); + + void begin(); + void end(); + bool isPending(); + unsigned value(); + size_t texturesUploaded(); + void markAsNonBlocking(); + bool isNonBlocking(); + + private: + explicit Query(WebKit::WebGraphicsContext3D*); + + WebKit::WebGraphicsContext3D* m_context; + unsigned m_queryId; + unsigned m_value; + bool m_hasValue; + bool m_isNonBlocking; + }; + + TextureUploader(WebKit::WebGraphicsContext3D*, bool useMapTexSubImage); + + void beginQuery(); + void endQuery(); + void processQueries(); + + void uploadWithTexSubImage(const uint8_t* image, + const IntRect& image_rect, + const IntRect& source_rect, + const IntSize& dest_offset, + GLenum format); + void uploadWithMapTexSubImage(const uint8_t* image, + const IntRect& image_rect, + const IntRect& source_rect, + const IntSize& dest_offset, + GLenum format); + + WebKit::WebGraphicsContext3D* m_context; + ScopedPtrDeque m_pendingQueries; + ScopedPtrDeque m_availableQueries; + std::deque m_texturesPerSecondHistory; + size_t m_numBlockingTextureUploads; + + bool m_useMapTexSubImage; + size_t m_subImageSize; + scoped_array m_subImage; + + DISALLOW_COPY_AND_ASSIGN(TextureUploader); }; -} +} // namespace cc -#endif +#endif // CC_TEXTURE_UPLOADER_H_ -- cgit v1.1