diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 23:06:26 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 23:06:26 +0000 |
commit | c22418befbc72b25c7ee2ca8e6fe0a7c9344437e (patch) | |
tree | 64f7a701344241c0663aaaf97ba2ce9c04d60c29 /cc/scrollbar_layer_impl.cc | |
parent | 62669313d2d987074bd63f8d7687bfc314b37d99 (diff) | |
download | chromium_src-c22418befbc72b25c7ee2ca8e6fe0a7c9344437e.zip chromium_src-c22418befbc72b25c7ee2ca8e6fe0a7c9344437e.tar.gz chromium_src-c22418befbc72b25c7ee2ca8e6fe0a7c9344437e.tar.bz2 |
cc: Make the DrawQuad subclasses into a struct-like classes.
I've replaced the create() and constructor on each class with a SetNew() method:
void SetNew(const SharedQuadState* shared_quad_state,
gfx::Rect rect,
...);
This method sets everything in the base class, based on the subclass'
interpretation of the minimal parameters given to it. This is used when
creating a new quad of this type - hence the name. The "..." represents
all the quad-type-specific arguments.
I've also added a new SetAll() method, that takes all of the data held by this
quad type, and simply passes on the appropriate things to the super class:
void SetAll(const SharedQuadState* shared_quad_state,
gfx::Rect rect,
gfx::Rect opaque_rect,
gfx::Rect visible_rect,
bool needs_blending,
...);
This method is used for deserializing, or other cases where you have all the
data for the quad well defined, and want to set every field at once. The
"..." represents all the quad-type-specific arguments.
Added tests for SetAll() in cc_unittests:DrawQuadTest.*
TBR=aelias
BUG=152337
Review URL: https://chromiumcodereview.appspot.com/11411050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/scrollbar_layer_impl.cc')
-rw-r--r-- | cc/scrollbar_layer_impl.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cc/scrollbar_layer_impl.cc b/cc/scrollbar_layer_impl.cc index 2b82529..5b6968dc 100644 --- a/cc/scrollbar_layer_impl.cc +++ b/cc/scrollbar_layer_impl.cc @@ -97,7 +97,8 @@ void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append if (m_thumbResourceId && !thumbRect.isEmpty()) { gfx::Rect quadRect(scrollbarLayerRectToContentRect(thumbRect)); gfx::Rect opaqueRect; - scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::create(sharedQuadState, quadRect, opaqueRect, m_thumbResourceId, premultipledAlpha, uvRect, flipped); + scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); + quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_thumbResourceId, premultipledAlpha, uvRect, flipped); quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); } @@ -108,7 +109,9 @@ void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) { gfx::Rect quadRect(scrollbarLayerRectToContentRect(foreTrackRect)); gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); - quadSink.append(TextureDrawQuad::create(sharedQuadState, quadRect, opaqueRect, m_foreTrackResourceId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped).PassAs<DrawQuad>(), appendQuadsData); + scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); + quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_foreTrackResourceId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped); + quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); } // Order matters here: since the back track texture is being drawn to the entire contents rect, we must append it after the thumb and @@ -116,7 +119,9 @@ void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append if (!contentBoundsRect.IsEmpty()) { gfx::Rect quadRect(contentBoundsRect); gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); - quadSink.append(TextureDrawQuad::create(sharedQuadState, quadRect, opaqueRect, m_backTrackResourceId, premultipledAlpha, uvRect, flipped).PassAs<DrawQuad>(), appendQuadsData); + scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); + quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_backTrackResourceId, premultipledAlpha, uvRect, flipped); + quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); } } |