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

Side by Side Diff: mojo/skia/ganesh_texture_surface.cc

Issue 1518793004: Improve GL bindings for Ganesh surfaces. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address review comments Created 5 years 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 | « mojo/skia/ganesh_texture_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "mojo/skia/ganesh_surface.h" 5 #include "base/logging.h"
6 #include "mojo/skia/ganesh_texture_surface.h"
6 7
7 namespace mojo { 8 namespace mojo {
8 9
9 GaneshSurface::GaneshSurface(GaneshContext* context, 10 GaneshTextureSurface::GaneshTextureSurface(GaneshContext* context,
10 scoped_ptr<GLTexture> texture) 11 std::unique_ptr<GLTexture> texture)
11 : texture_(texture.Pass()) { 12 : texture_(std::move(texture)) {
13 DCHECK(context);
14 DCHECK(texture_);
15 DCHECK(texture_->texture_id());
16 DCHECK(texture_->size().width > 0);
17 DCHECK(texture_->size().height > 0);
18
12 GrBackendTextureDesc desc; 19 GrBackendTextureDesc desc;
13 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 20 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
14 desc.fWidth = texture_->size().width; 21 desc.fWidth = texture_->size().width;
15 desc.fHeight = texture_->size().height; 22 desc.fHeight = texture_->size().height;
16 desc.fConfig = kSkia8888_GrPixelConfig; 23 desc.fConfig = kSkia8888_GrPixelConfig;
17 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 24 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
18 desc.fTextureHandle = texture_->texture_id(); 25 desc.fTextureHandle = texture_->texture_id();
19 DCHECK(texture_->texture_id());
20 26
21 auto gr_texture = skia::AdoptRef( 27 skia::RefPtr<GrTexture> gr_texture = skia::AdoptRef(
22 context->gr()->textureProvider()->wrapBackendTexture(desc)); 28 context->gr()->textureProvider()->wrapBackendTexture(desc));
23 DCHECK(gr_texture); 29 DCHECK(gr_texture);
30
24 surface_ = skia::AdoptRef( 31 surface_ = skia::AdoptRef(
25 SkSurface::NewRenderTargetDirect(gr_texture->asRenderTarget())); 32 SkSurface::NewRenderTargetDirect(gr_texture->asRenderTarget()));
26 DCHECK(surface_); 33 DCHECK(surface_);
27 } 34 }
28 35
29 GaneshSurface::~GaneshSurface() { 36 GaneshTextureSurface::~GaneshTextureSurface() {}
30 }
31 37
32 scoped_ptr<GLTexture> GaneshSurface::TakeTexture() { 38 std::unique_ptr<GLTexture> GaneshTextureSurface::TakeTexture() {
33 surface_.clear(); 39 surface_.clear();
34 return texture_.Pass(); 40 return std::move(texture_);
35 } 41 }
36 42
37 } // namespace mojo 43 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/skia/ganesh_texture_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698