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

Side by Side Diff: cc/CCIOSurfaceLayerImpl.cpp

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « cc/CCIOSurfaceLayerImpl.h ('k') | cc/CCInputHandler.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 #if USE(ACCELERATED_COMPOSITING)
8
9 #include "CCIOSurfaceLayerImpl.h"
10
11 #include "base/stringprintf.h"
12 #include "CCGraphicsContext.h"
13 #include "CCIOSurfaceDrawQuad.h"
14 #include "CCLayerTreeHostImpl.h"
15 #include "CCQuadSink.h"
16 #include "CCRendererGL.h" // For the GLC() macro.
17 #include "Extensions3D.h"
18 #include <public/WebGraphicsContext3D.h>
19
20 namespace cc {
21
22 CCIOSurfaceLayerImpl::CCIOSurfaceLayerImpl(int id)
23 : CCLayerImpl(id)
24 , m_ioSurfaceId(0)
25 , m_ioSurfaceChanged(false)
26 , m_ioSurfaceTextureId(0)
27 {
28 }
29
30 CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl()
31 {
32 if (!m_ioSurfaceTextureId)
33 return;
34
35 CCGraphicsContext* context = layerTreeHostImpl()->context();
36 // FIXME: Implement this path for software compositing.
37 WebKit::WebGraphicsContext3D* context3d = context->context3D();
38 if (context3d)
39 context3d->deleteTexture(m_ioSurfaceTextureId);
40 }
41
42 void CCIOSurfaceLayerImpl::willDraw(CCResourceProvider* resourceProvider)
43 {
44 CCLayerImpl::willDraw(resourceProvider);
45
46 if (m_ioSurfaceChanged) {
47 WebKit::WebGraphicsContext3D* context3d = resourceProvider->graphicsCont ext3D();
48 if (!context3d) {
49 // FIXME: Implement this path for software compositing.
50 return;
51 }
52
53 // FIXME: Do this in a way that we can track memory usage.
54 if (!m_ioSurfaceTextureId)
55 m_ioSurfaceTextureId = context3d->createTexture();
56
57 GLC(context3d, context3d->activeTexture(GraphicsContext3D::TEXTURE0));
58 GLC(context3d, context3d->bindTexture(Extensions3D::TEXTURE_RECTANGLE_AR B, m_ioSurfaceTextureId));
59 GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ ARB, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
60 GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ ARB, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
61 GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ ARB, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
62 GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ ARB, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
63 context3d->texImageIOSurface2DCHROMIUM(Extensions3D::TEXTURE_RECTANGLE_A RB,
64 m_ioSurfaceSize.width(),
65 m_ioSurfaceSize.height(),
66 m_ioSurfaceId,
67 0);
68 // Do not check for error conditions. texImageIOSurface2DCHROMIUM is sup posed to hold on to
69 // the last good IOSurface if the new one is already closed. This is onl y a possibility
70 // during live resizing of plugins. However, it seems that this is not s ufficient to
71 // completely guard against garbage being drawn. If this is found to be a significant issue,
72 // it may be necessary to explicitly tell the embedder when to free the surfaces it has
73 // allocated.
74 m_ioSurfaceChanged = false;
75 }
76 }
77
78 void CCIOSurfaceLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuadsData)
79 {
80 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare dQuadState());
81 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
82
83 IntRect quadRect(IntPoint(), contentBounds());
84 quadSink.append(CCIOSurfaceDrawQuad::create(sharedQuadState, quadRect, m_ioS urfaceSize, m_ioSurfaceTextureId, CCIOSurfaceDrawQuad::Flipped).PassAs<CCDrawQua d>(), appendQuadsData);
85 }
86
87 void CCIOSurfaceLayerImpl::dumpLayerProperties(std::string* str, int indent) con st
88 {
89 str->append(indentString(indent));
90 base::StringAppendF(str, "iosurface id: %u texture id: %u\n", m_ioSurfaceId, m_ioSurfaceTextureId);
91 CCLayerImpl::dumpLayerProperties(str, indent);
92 }
93
94 void CCIOSurfaceLayerImpl::didLoseContext()
95 {
96 // We don't have a valid texture ID in the new context; however,
97 // the IOSurface is still valid.
98 m_ioSurfaceTextureId = 0;
99 m_ioSurfaceChanged = true;
100 }
101
102 void CCIOSurfaceLayerImpl::setIOSurfaceProperties(unsigned ioSurfaceId, const In tSize& size)
103 {
104 if (m_ioSurfaceId != ioSurfaceId)
105 m_ioSurfaceChanged = true;
106
107 m_ioSurfaceId = ioSurfaceId;
108 m_ioSurfaceSize = size;
109 }
110
111 const char* CCIOSurfaceLayerImpl::layerTypeAsString() const
112 {
113 return "IOSurfaceLayer";
114 }
115
116 }
117
118 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « cc/CCIOSurfaceLayerImpl.h ('k') | cc/CCInputHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698