OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 "mojo/skia/ganesh_surface.h" | |
6 | |
7 namespace mojo { | |
8 | |
9 GaneshSurface::GaneshSurface(GaneshContext* context, | |
10 scoped_ptr<GLTexture> texture) | |
11 : texture_(texture.Pass()) { | |
12 GrBackendTextureDesc desc; | |
13 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | |
14 desc.fWidth = texture_->size().width; | |
15 desc.fHeight = texture_->size().height; | |
16 desc.fConfig = kSkia8888_GrPixelConfig; | |
17 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | |
18 desc.fTextureHandle = texture_->texture_id(); | |
19 DCHECK(texture_->texture_id()); | |
20 | |
21 auto gr_texture = skia::AdoptRef( | |
22 context->gr()->textureProvider()->wrapBackendTexture(desc)); | |
23 DCHECK(gr_texture); | |
24 surface_ = skia::AdoptRef( | |
25 SkSurface::NewRenderTargetDirect(gr_texture->asRenderTarget())); | |
26 DCHECK(surface_); | |
27 } | |
28 | |
29 GaneshSurface::~GaneshSurface() { | |
30 } | |
31 | |
32 scoped_ptr<GLTexture> GaneshSurface::TakeTexture() { | |
33 surface_.clear(); | |
34 return texture_.Pass(); | |
35 } | |
36 | |
37 } // namespace mojo | |
OLD | NEW |