Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: cc/nine_patch_layer.cc

Issue 11304020: cc: Nine patch layer. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix DCHECK failures and rebase to 166129 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/nine_patch_layer.h ('k') | cc/nine_patch_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6
7 #include "cc/nine_patch_layer.h"
8
9 #include "cc/layer_tree_host.h"
10 #include "cc/nine_patch_layer_impl.h"
11 #include "cc/resource_update.h"
12 #include "cc/resource_update_queue.h"
13
14 namespace cc {
15
16 scoped_refptr<NinePatchLayer> NinePatchLayer::create()
17 {
18 return make_scoped_refptr(new NinePatchLayer());
19 }
20
21 NinePatchLayer::NinePatchLayer()
22 : m_bitmapDirty(false)
23 {
24 }
25
26 NinePatchLayer::~NinePatchLayer()
27 {
28 }
29
30 scoped_ptr<LayerImpl> NinePatchLayer::createLayerImpl()
31 {
32 return NinePatchLayerImpl::create(id()).PassAs<LayerImpl>();
33 }
34
35 void NinePatchLayer::setTexturePriorities(const PriorityCalculator& priorityCalc )
36 {
37 if (m_needsDisplay && m_bitmapDirty && drawsContent()) {
38 DCHECK(!m_bitmap.isNull());
39 createUpdaterIfNeeded();
40 m_updater->setBitmap(m_bitmap);
41 m_needsDisplay = false;
42
43 if (!m_resource)
44 m_resource = m_updater->createResource(layerTreeHost()->contentsText ureManager());
45 }
46
47 if (m_resource) {
48 m_resource->texture()->setRequestPriority(PriorityCalculator::uiPriority (true));
49 // FIXME: Need to support swizzle in the shader for !PlatformColor::same ComponentOrder(textureFormat)
50 GLenum textureFormat = layerTreeHost()->rendererCapabilities().bestTextu reFormat;
51 m_resource->texture()->setDimensions(gfx::Size(m_bitmap.width(), m_bitma p.height()), textureFormat);
52 }
53 }
54
55 void NinePatchLayer::setBitmap(const SkBitmap& bitmap, const gfx::Rect& aperture ) {
56 m_bitmap = bitmap;
57 m_imageAperture = aperture;
58 m_bitmapDirty = true;
59 setNeedsDisplay();
60 }
61
62 void NinePatchLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats)
63 {
64 createUpdaterIfNeeded();
65
66 if (m_resource && (m_bitmapDirty || m_resource->texture()->backingResourceWa sEvicted())) {
67 gfx::Rect contentRect(gfx::Point(), gfx::Size(m_bitmap.width(), m_bitmap .height()));
68 ResourceUpdate upload = ResourceUpdate::Create(m_resource->texture(), &m _bitmap, contentRect, contentRect, gfx::Vector2d());
69 queue.appendFullUpload(upload);
70 m_bitmapDirty = false;
71 }
72 }
73
74 void NinePatchLayer::createUpdaterIfNeeded()
75 {
76 if (m_updater)
77 return;
78
79 m_updater = ImageLayerUpdater::create();
80 }
81
82 bool NinePatchLayer::drawsContent() const
83 {
84 bool draws = !m_bitmap.isNull() && Layer::drawsContent() && m_bitmap.width() && m_bitmap.height();
85 return draws;
86 }
87
88 void NinePatchLayer::pushPropertiesTo(LayerImpl* layer)
89 {
90 Layer::pushPropertiesTo(layer);
91 NinePatchLayerImpl* layerImpl = static_cast<NinePatchLayerImpl*>(layer);
92
93 DCHECK(!m_bitmap.isNull());
94 DCHECK(m_resource);
95 layerImpl->setResourceId(m_resource->texture()->resourceId());
96 layerImpl->setLayout(gfx::Size(m_bitmap.width(), m_bitmap.height()), m_image Aperture);
97 }
98
99 }
OLDNEW
« no previous file with comments | « cc/nine_patch_layer.h ('k') | cc/nine_patch_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698