| 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 "cc/quad_sink.h" | 8 #include "cc/quad_sink.h" |
| 9 #include "cc/texture_draw_quad.h" | 9 #include "cc/texture_draw_quad.h" |
| 10 #include "ui/gfx/rect_f.h" | 10 #include "ui/gfx/rect_f.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Patch positions in bitmap UV space (from zero to one) | 76 // Patch positions in bitmap UV space (from zero to one) |
| 77 gfx::RectF uvTopLeft = normalizedRect(0, 0, leftWidth, topHeight, imgWidth,
imgHeight); | 77 gfx::RectF uvTopLeft = normalizedRect(0, 0, leftWidth, topHeight, imgWidth,
imgHeight); |
| 78 gfx::RectF uvTopRight = normalizedRect(imgWidth - rightWidth, 0, rightWidth,
topHeight, imgWidth, imgHeight); | 78 gfx::RectF uvTopRight = normalizedRect(imgWidth - rightWidth, 0, rightWidth,
topHeight, imgWidth, imgHeight); |
| 79 gfx::RectF uvBottomLeft = normalizedRect(0, imgHeight - bottomHeight, leftWi
dth, bottomHeight, imgWidth, imgHeight); | 79 gfx::RectF uvBottomLeft = normalizedRect(0, imgHeight - bottomHeight, leftWi
dth, bottomHeight, imgWidth, imgHeight); |
| 80 gfx::RectF uvBottomRight = normalizedRect(imgWidth - rightWidth, imgHeight -
bottomHeight, rightWidth, bottomHeight, imgWidth, imgHeight); | 80 gfx::RectF uvBottomRight = normalizedRect(imgWidth - rightWidth, imgHeight -
bottomHeight, rightWidth, bottomHeight, imgWidth, imgHeight); |
| 81 gfx::RectF uvTop(uvTopLeft.right(), 0, (imgWidth - leftWidth - rightWidth) /
imgWidth, (topHeight) / imgHeight); | 81 gfx::RectF uvTop(uvTopLeft.right(), 0, (imgWidth - leftWidth - rightWidth) /
imgWidth, (topHeight) / imgHeight); |
| 82 gfx::RectF uvLeft(0, uvTopLeft.bottom(), leftWidth / imgWidth, (imgHeight -
topHeight - bottomHeight) / imgHeight); | 82 gfx::RectF uvLeft(0, uvTopLeft.bottom(), leftWidth / imgWidth, (imgHeight -
topHeight - bottomHeight) / imgHeight); |
| 83 gfx::RectF uvRight(uvTopRight.x(), uvTopRight.bottom(), rightWidth / imgWidt
h, uvLeft.height()); | 83 gfx::RectF uvRight(uvTopRight.x(), uvTopRight.bottom(), rightWidth / imgWidt
h, uvLeft.height()); |
| 84 gfx::RectF uvBottom(uvTop.x(), uvBottomLeft.y(), uvTop.width(), bottomHeight
/ imgHeight); | 84 gfx::RectF uvBottom(uvTop.x(), uvBottomLeft.y(), uvTop.width(), bottomHeight
/ imgHeight); |
| 85 | 85 |
| 86 quadSink.append(TextureDrawQuad::create(sharedQuadState, topLeft, m_resource
Id, premultipliedAlpha, uvTopLeft, flipped).PassAs<DrawQuad>(), appendQuadsData)
; | 86 // Nothing is opaque here. |
| 87 quadSink.append(TextureDrawQuad::create(sharedQuadState, topRight, m_resourc
eId, premultipliedAlpha, uvTopRight, flipped).PassAs<DrawQuad>(), appendQuadsDat
a); | 87 // TODO(danakj): Should we look at the SkBitmaps to determine opaqueness? |
| 88 quadSink.append(TextureDrawQuad::create(sharedQuadState, bottomLeft, m_resou
rceId, premultipliedAlpha, uvBottomLeft, flipped).PassAs<DrawQuad>(), appendQuad
sData); | 88 gfx::Rect opaqueRect; |
| 89 quadSink.append(TextureDrawQuad::create(sharedQuadState, bottomRight, m_reso
urceId, premultipliedAlpha, uvBottomRight, flipped).PassAs<DrawQuad>(), appendQu
adsData); | 89 |
| 90 quadSink.append(TextureDrawQuad::create(sharedQuadState, top, m_resourceId,
premultipliedAlpha, uvTop, flipped).PassAs<DrawQuad>(), appendQuadsData); | 90 quadSink.append(TextureDrawQuad::create(sharedQuadState, topLeft, opaqueRect
, m_resourceId, premultipliedAlpha, uvTopLeft, flipped).PassAs<DrawQuad>(), appe
ndQuadsData); |
| 91 quadSink.append(TextureDrawQuad::create(sharedQuadState, left, m_resourceId,
premultipliedAlpha, uvLeft, flipped).PassAs<DrawQuad>(), appendQuadsData); | 91 quadSink.append(TextureDrawQuad::create(sharedQuadState, topRight, opaqueRec
t, m_resourceId, premultipliedAlpha, uvTopRight, flipped).PassAs<DrawQuad>(), ap
pendQuadsData); |
| 92 quadSink.append(TextureDrawQuad::create(sharedQuadState, right, m_resourceId
, premultipliedAlpha, uvRight, flipped).PassAs<DrawQuad>(), appendQuadsData); | 92 quadSink.append(TextureDrawQuad::create(sharedQuadState, bottomLeft, opaqueR
ect, m_resourceId, premultipliedAlpha, uvBottomLeft, flipped).PassAs<DrawQuad>()
, appendQuadsData); |
| 93 quadSink.append(TextureDrawQuad::create(sharedQuadState, bottom, m_resourceI
d, premultipliedAlpha, uvBottom, flipped).PassAs<DrawQuad>(), appendQuadsData); | 93 quadSink.append(TextureDrawQuad::create(sharedQuadState, bottomRight, opaque
Rect, m_resourceId, premultipliedAlpha, uvBottomRight, flipped).PassAs<DrawQuad>
(), appendQuadsData); |
| 94 quadSink.append(TextureDrawQuad::create(sharedQuadState, top, opaqueRect, m_
resourceId, premultipliedAlpha, uvTop, flipped).PassAs<DrawQuad>(), appendQuadsD
ata); |
| 95 quadSink.append(TextureDrawQuad::create(sharedQuadState, left, opaqueRect, m
_resourceId, premultipliedAlpha, uvLeft, flipped).PassAs<DrawQuad>(), appendQuad
sData); |
| 96 quadSink.append(TextureDrawQuad::create(sharedQuadState, right, opaqueRect,
m_resourceId, premultipliedAlpha, uvRight, flipped).PassAs<DrawQuad>(), appendQu
adsData); |
| 97 quadSink.append(TextureDrawQuad::create(sharedQuadState, bottom, opaqueRect,
m_resourceId, premultipliedAlpha, uvBottom, flipped).PassAs<DrawQuad>(), append
QuadsData); |
| 94 } | 98 } |
| 95 | 99 |
| 96 void NinePatchLayerImpl::didDraw(ResourceProvider* resourceProvider) | 100 void NinePatchLayerImpl::didDraw(ResourceProvider* resourceProvider) |
| 97 { | 101 { |
| 98 } | 102 } |
| 99 | 103 |
| 100 void NinePatchLayerImpl::didLoseContext() | 104 void NinePatchLayerImpl::didLoseContext() |
| 101 { | 105 { |
| 102 m_resourceId = 0; | 106 m_resourceId = 0; |
| 103 } | 107 } |
| 104 | 108 |
| 105 const char* NinePatchLayerImpl::layerTypeAsString() const | 109 const char* NinePatchLayerImpl::layerTypeAsString() const |
| 106 { | 110 { |
| 107 return "NinePatchLayer"; | 111 return "NinePatchLayer"; |
| 108 } | 112 } |
| 109 | 113 |
| 110 void NinePatchLayerImpl::dumpLayerProperties(std::string* str, int indent) const | 114 void NinePatchLayerImpl::dumpLayerProperties(std::string* str, int indent) const |
| 111 { | 115 { |
| 112 str->append(indentString(indent)); | 116 str->append(indentString(indent)); |
| 113 base::StringAppendF(str, "imageAperture: %s\n", m_imageAperture.ToString().c
_str()); | 117 base::StringAppendF(str, "imageAperture: %s\n", m_imageAperture.ToString().c
_str()); |
| 114 LayerImpl::dumpLayerProperties(str, indent); | 118 LayerImpl::dumpLayerProperties(str, indent); |
| 115 } | 119 } |
| 116 | 120 |
| 117 } | 121 } |
| OLD | NEW |