| 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 "nine_patch_layer_impl.h" | 5 #include "nine_patch_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "cc/quad_sink.h" | 9 #include "cc/quad_sink.h" |
| 10 #include "cc/texture_draw_quad.h" | 10 #include "cc/texture_draw_quad.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 gfx::RectF uvBottomLeft = normalizedRect(0, imgHeight - bottomHeight, leftWi
dth, bottomHeight, imgWidth, imgHeight); | 101 gfx::RectF uvBottomLeft = normalizedRect(0, imgHeight - bottomHeight, leftWi
dth, bottomHeight, imgWidth, imgHeight); |
| 102 gfx::RectF uvBottomRight = normalizedRect(imgWidth - rightWidth, imgHeight -
bottomHeight, rightWidth, bottomHeight, imgWidth, imgHeight); | 102 gfx::RectF uvBottomRight = normalizedRect(imgWidth - rightWidth, imgHeight -
bottomHeight, rightWidth, bottomHeight, imgWidth, imgHeight); |
| 103 gfx::RectF uvTop(uvTopLeft.right(), 0, (imgWidth - leftWidth - rightWidth) /
imgWidth, (topHeight) / imgHeight); | 103 gfx::RectF uvTop(uvTopLeft.right(), 0, (imgWidth - leftWidth - rightWidth) /
imgWidth, (topHeight) / imgHeight); |
| 104 gfx::RectF uvLeft(0, uvTopLeft.bottom(), leftWidth / imgWidth, (imgHeight -
topHeight - bottomHeight) / imgHeight); | 104 gfx::RectF uvLeft(0, uvTopLeft.bottom(), leftWidth / imgWidth, (imgHeight -
topHeight - bottomHeight) / imgHeight); |
| 105 gfx::RectF uvRight(uvTopRight.x(), uvTopRight.bottom(), rightWidth / imgWidt
h, uvLeft.height()); | 105 gfx::RectF uvRight(uvTopRight.x(), uvTopRight.bottom(), rightWidth / imgWidt
h, uvLeft.height()); |
| 106 gfx::RectF uvBottom(uvTop.x(), uvBottomLeft.y(), uvTop.width(), bottomHeight
/ imgHeight); | 106 gfx::RectF uvBottom(uvTop.x(), uvBottomLeft.y(), uvTop.width(), bottomHeight
/ imgHeight); |
| 107 | 107 |
| 108 // Nothing is opaque here. | 108 // Nothing is opaque here. |
| 109 // TODO(danakj): Should we look at the SkBitmaps to determine opaqueness? | 109 // TODO(danakj): Should we look at the SkBitmaps to determine opaqueness? |
| 110 gfx::Rect opaqueRect; | 110 gfx::Rect opaqueRect; |
| 111 const float vertex_opacity[] = {1, 1, 1, 1}; |
| 111 scoped_ptr<TextureDrawQuad> quad; | 112 scoped_ptr<TextureDrawQuad> quad; |
| 112 | 113 |
| 113 quad = TextureDrawQuad::Create(); | 114 quad = TextureDrawQuad::Create(); |
| 114 quad->SetNew(sharedQuadState, topLeft, opaqueRect, m_resourceId, premultipli
edAlpha, uvTopLeft, flipped); | 115 quad->SetNew(sharedQuadState, topLeft, opaqueRect, m_resourceId, premultipli
edAlpha, uvTopLeft, vertex_opacity, flipped); |
| 115 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 116 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 116 | 117 |
| 117 quad = TextureDrawQuad::Create(); | 118 quad = TextureDrawQuad::Create(); |
| 118 quad->SetNew(sharedQuadState, topRight, opaqueRect, m_resourceId, premultipl
iedAlpha, uvTopRight, flipped); | 119 quad->SetNew(sharedQuadState, topRight, opaqueRect, m_resourceId, premultipl
iedAlpha, uvTopRight, vertex_opacity, flipped); |
| 119 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 120 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 120 | 121 |
| 121 quad = TextureDrawQuad::Create(); | 122 quad = TextureDrawQuad::Create(); |
| 122 quad->SetNew(sharedQuadState, bottomLeft, opaqueRect, m_resourceId, premulti
pliedAlpha, uvBottomLeft, flipped); | 123 quad->SetNew(sharedQuadState, bottomLeft, opaqueRect, m_resourceId, premulti
pliedAlpha, uvBottomLeft, vertex_opacity, flipped); |
| 123 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 124 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 124 | 125 |
| 125 quad = TextureDrawQuad::Create(); | 126 quad = TextureDrawQuad::Create(); |
| 126 quad->SetNew(sharedQuadState, bottomRight, opaqueRect, m_resourceId, premult
ipliedAlpha, uvBottomRight, flipped); | 127 quad->SetNew(sharedQuadState, bottomRight, opaqueRect, m_resourceId, premult
ipliedAlpha, uvBottomRight, vertex_opacity, flipped); |
| 127 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 128 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 128 | 129 |
| 129 quad = TextureDrawQuad::Create(); | 130 quad = TextureDrawQuad::Create(); |
| 130 quad->SetNew(sharedQuadState, top, opaqueRect, m_resourceId, premultipliedAl
pha, uvTop, flipped); | 131 quad->SetNew(sharedQuadState, top, opaqueRect, m_resourceId, premultipliedAl
pha, uvTop, vertex_opacity, flipped); |
| 131 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 132 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 132 | 133 |
| 133 quad = TextureDrawQuad::Create(); | 134 quad = TextureDrawQuad::Create(); |
| 134 quad->SetNew(sharedQuadState, left, opaqueRect, m_resourceId, premultipliedA
lpha, uvLeft, flipped); | 135 quad->SetNew(sharedQuadState, left, opaqueRect, m_resourceId, premultipliedA
lpha, uvLeft, vertex_opacity, flipped); |
| 135 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 136 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 136 | 137 |
| 137 quad = TextureDrawQuad::Create(); | 138 quad = TextureDrawQuad::Create(); |
| 138 quad->SetNew(sharedQuadState, right, opaqueRect, m_resourceId, premultiplied
Alpha, uvRight, flipped); | 139 quad->SetNew(sharedQuadState, right, opaqueRect, m_resourceId, premultiplied
Alpha, uvRight, vertex_opacity, flipped); |
| 139 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 140 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 140 | 141 |
| 141 quad = TextureDrawQuad::Create(); | 142 quad = TextureDrawQuad::Create(); |
| 142 quad->SetNew(sharedQuadState, bottom, opaqueRect, m_resourceId, premultiplie
dAlpha, uvBottom, flipped); | 143 quad->SetNew(sharedQuadState, bottom, opaqueRect, m_resourceId, premultiplie
dAlpha, uvBottom, vertex_opacity, flipped); |
| 143 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 144 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 144 } | 145 } |
| 145 | 146 |
| 146 void NinePatchLayerImpl::didDraw(ResourceProvider* resourceProvider) | 147 void NinePatchLayerImpl::didDraw(ResourceProvider* resourceProvider) |
| 147 { | 148 { |
| 148 } | 149 } |
| 149 | 150 |
| 150 void NinePatchLayerImpl::didLoseOutputSurface() | 151 void NinePatchLayerImpl::didLoseOutputSurface() |
| 151 { | 152 { |
| 152 m_resourceId = 0; | 153 m_resourceId = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 172 list->AppendInteger(m_imageAperture.origin().x()); | 173 list->AppendInteger(m_imageAperture.origin().x()); |
| 173 list->AppendInteger(m_imageAperture.origin().y()); | 174 list->AppendInteger(m_imageAperture.origin().y()); |
| 174 list->AppendInteger(m_imageAperture.size().width()); | 175 list->AppendInteger(m_imageAperture.size().width()); |
| 175 list->AppendInteger(m_imageAperture.size().height()); | 176 list->AppendInteger(m_imageAperture.size().height()); |
| 176 result->Set("ImageAperture", list); | 177 result->Set("ImageAperture", list); |
| 177 | 178 |
| 178 return result; | 179 return result; |
| 179 } | 180 } |
| 180 | 181 |
| 181 } | 182 } |
| OLD | NEW |