summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/output/gl_renderer.cc16
-rw-r--r--cc/resources/resource_provider.cc7
-rw-r--r--content/renderer/media/android/webmediaplayer_android.cc6
-rw-r--r--media/renderers/skcanvas_video_renderer.cc40
-rw-r--r--skia/config/SkUserConfig.h3
-rw-r--r--skia/ext/texture_handle.h25
-rw-r--r--third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp9
-rw-r--r--third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp6
-rw-r--r--third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp4
-rw-r--r--third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp3
10 files changed, 84 insertions, 35 deletions
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 57e3f33..6e58884 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -45,6 +45,7 @@
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
+#include "skia/ext/texture_handle.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkColorFilter.h"
@@ -54,6 +55,7 @@
#include "third_party/skia/include/gpu/GrTexture.h"
#include "third_party/skia/include/gpu/GrTextureProvider.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
+#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/skia_util.h"
@@ -618,11 +620,15 @@ static skia::RefPtr<SkImage> ApplyImageFilter(
// Wrap the source texture in a Ganesh platform texture.
GrBackendTextureDesc backend_texture_description;
+ GrGLTextureInfo texture_info;
+ texture_info.fTarget = lock.target();
+ texture_info.fID = lock.texture_id();
backend_texture_description.fWidth = source_texture_resource->size().width();
backend_texture_description.fHeight =
source_texture_resource->size().height();
backend_texture_description.fConfig = kSkia8888_GrPixelConfig;
- backend_texture_description.fTextureHandle = lock.texture_id();
+ backend_texture_description.fTextureHandle =
+ skia::GrGLTextureInfoToGrBackendObject(texture_info);
backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin;
skia::RefPtr<SkImage> srcImage = skia::AdoptRef(SkImage::NewFromTexture(
@@ -955,7 +961,9 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
background_image = ApplyBackgroundFilters(
frame, quad, background_texture.get(), gfx::RectF(background_rect));
if (background_image)
- background_image_id = background_image->getTextureHandle(true);
+ background_image_id = skia::GrBackendObjectToGrGLTextureInfo(
+ background_image->getTextureHandle(true))
+ ->fID;
DCHECK(background_image_id);
}
}
@@ -1034,7 +1042,9 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
resource_provider_, rect, dst_rect,
scale, filter.get(), contents_texture);
if (filter_image) {
- filter_image_id = filter_image->getTextureHandle(true);
+ filter_image_id = skia::GrBackendObjectToGrGLTextureInfo(
+ filter_image->getTextureHandle(true))
+ ->fID;
DCHECK(filter_image_id);
rect = dst_rect;
}
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index d7fcee7..4fdbb4a 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -31,11 +31,13 @@
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
+#include "skia/ext/texture_handle.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/GrTextureProvider.h"
+#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gl/trace_util.h"
@@ -1109,13 +1111,16 @@ void ResourceProvider::ScopedWriteLockGr::InitSkSurface(
int msaa_sample_count) {
DCHECK(resource_->locked_for_write);
+ GrGLTextureInfo texture_info;
+ texture_info.fID = resource_->gl_id;
+ texture_info.fTarget = resource_->target;
GrBackendTextureDesc desc;
desc.fFlags = kRenderTarget_GrBackendTextureFlag;
desc.fWidth = resource_->size.width();
desc.fHeight = resource_->size.height();
desc.fConfig = ToGrPixelConfig(resource_->format);
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
- desc.fTextureHandle = resource_->gl_id;
+ desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info);
desc.fSampleCnt = msaa_sample_count;
bool use_worker_context = true;
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index a0096d5..aaf45aa 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -49,6 +49,7 @@
#include "media/blink/webmediaplayer_delegate.h"
#include "media/blink/webmediaplayer_util.h"
#include "net/base/mime_util.h"
+#include "skia/ext/texture_handle.h"
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
@@ -663,8 +664,9 @@ void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas,
}
}
- unsigned textureId = static_cast<unsigned>(
- (bitmap_.getTexture())->getTextureHandle());
+ unsigned textureId = skia::GrBackendObjectToGrGLTextureInfo(
+ (bitmap_.getTexture())->getTextureHandle())
+ ->fID;
if (!copyVideoTextureToPlatformTexture(context3D, textureId,
GL_RGBA, GL_UNSIGNED_BYTE, true, false)) {
return;
diff --git a/media/renderers/skcanvas_video_renderer.cc b/media/renderers/skcanvas_video_renderer.cc
index e3af0fe..d84f152 100644
--- a/media/renderers/skcanvas_video_renderer.cc
+++ b/media/renderers/skcanvas_video_renderer.cc
@@ -13,6 +13,7 @@
#include "media/base/video_frame.h"
#include "media/base/yuv_convert.h"
#include "skia/ext/refptr.h"
+#include "skia/ext/texture_handle.h"
#include "third_party/libyuv/include/libyuv.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
@@ -22,6 +23,7 @@
#include "third_party/skia/include/gpu/GrTexture.h"
#include "third_party/skia/include/gpu/GrTextureProvider.h"
#include "third_party/skia/include/gpu/SkGr.h"
+#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/skia_util.h"
@@ -95,7 +97,7 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameYUVTextures(
gfx::Size uv_tex_size((ya_tex_size.width() + 1) / 2,
(ya_tex_size.height() + 1) / 2);
- unsigned source_textures[3] = {0};
+ GrGLTextureInfo source_textures[] = {{0, 0}, {0, 0}, {0, 0}};
for (size_t i = 0; i < media::VideoFrame::NumPlanes(video_frame->format());
++i) {
// Get the texture from the mailbox and wrap it in a GrTexture.
@@ -104,8 +106,9 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameYUVTextures(
mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES ||
mailbox_holder.texture_target == GL_TEXTURE_RECTANGLE_ARB);
gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData());
- source_textures[i] = gl->CreateAndConsumeTextureCHROMIUM(
+ source_textures[i].fID = gl->CreateAndConsumeTextureCHROMIUM(
mailbox_holder.texture_target, mailbox_holder.mailbox.name);
+ source_textures[i].fTarget = mailbox_holder.texture_target;
// TODO(dcastagna): avoid this copy once Skia supports native textures
// with a texture target different than TEXTURE_2D.
@@ -115,22 +118,18 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameYUVTextures(
gl->GenTextures(1, &texture_copy);
DCHECK(texture_copy);
gl->BindTexture(GL_TEXTURE_2D, texture_copy);
- gl->CopyTextureCHROMIUM(source_textures[i], texture_copy, GL_RGB,
+ gl->CopyTextureCHROMIUM(source_textures[i].fID, texture_copy, GL_RGB,
GL_UNSIGNED_BYTE, false, true, false);
- gl->DeleteTextures(1, &source_textures[i]);
- source_textures[i] = texture_copy;
+ gl->DeleteTextures(1, &source_textures[i].fID);
+ source_textures[i].fID = texture_copy;
+ source_textures[i].fTarget = GL_TEXTURE_2D;
}
}
- DCHECK_LE(source_textures[0],
- static_cast<unsigned>(std::numeric_limits<int>::max()));
- DCHECK_LE(source_textures[1],
- static_cast<unsigned>(std::numeric_limits<int>::max()));
- DCHECK_LE(source_textures[2],
- static_cast<unsigned>(std::numeric_limits<int>::max()));
- GrBackendObject handles[3] = {static_cast<int>(source_textures[0]),
- static_cast<int>(source_textures[1]),
- static_cast<int>(source_textures[2])};
+ GrBackendObject handles[3] = {
+ skia::GrGLTextureInfoToGrBackendObject(source_textures[0]),
+ skia::GrGLTextureInfoToGrBackendObject(source_textures[1]),
+ skia::GrGLTextureInfoToGrBackendObject(source_textures[2])};
SkISize yuvSizes[] = {
{ya_tex_size.width(), ya_tex_size.height()},
@@ -147,7 +146,10 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameYUVTextures(
SkImage* img = SkImage::NewFromYUVTexturesCopy(context_3d.gr_context,
color_space, handles, yuvSizes,
kTopLeft_GrSurfaceOrigin);
- gl->DeleteTextures(3, source_textures);
+ for (size_t i = 0; i < media::VideoFrame::NumPlanes(video_frame->format());
+ ++i) {
+ gl->DeleteTextures(1, &source_textures[i].fID);
+ }
return skia::AdoptRef(img);
}
@@ -190,9 +192,11 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameNative(
desc.fWidth = video_frame->coded_size().width();
desc.fHeight = video_frame->coded_size().height();
desc.fConfig = kRGBA_8888_GrPixelConfig;
- DCHECK_LE(source_texture,
- static_cast<unsigned>(std::numeric_limits<int>::max()));
- desc.fTextureHandle = static_cast<int>(source_texture);
+ GrGLTextureInfo source_texture_info;
+ source_texture_info.fID = source_texture;
+ source_texture_info.fTarget = GL_TEXTURE_2D;
+ desc.fTextureHandle =
+ skia::GrGLTextureInfoToGrBackendObject(source_texture_info);
return skia::AdoptRef(
SkImage::NewFromAdoptedTexture(context_3d.gr_context, desc));
}
diff --git a/skia/config/SkUserConfig.h b/skia/config/SkUserConfig.h
index 7ce21a6..ee02c55 100644
--- a/skia/config/SkUserConfig.h
+++ b/skia/config/SkUserConfig.h
@@ -250,9 +250,6 @@ SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
*/
#define SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
-#ifndef SK_IGNORE_GL_TEXTURE_TARGET
-# define SK_IGNORE_GL_TEXTURE_TARGET
-#endif
#define SK_IGNORE_BLURRED_RRECT_OPT
#define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
#define SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT
diff --git a/skia/ext/texture_handle.h b/skia/ext/texture_handle.h
new file mode 100644
index 0000000..a5409c5
--- /dev/null
+++ b/skia/ext/texture_handle.h
@@ -0,0 +1,25 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SKIA_EXT_TEXTURE_HANDLE_H_
+#define SKIA_EXT_TEXTURE_HANDLE_H_
+
+#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
+
+namespace skia {
+
+// TODO(bsalomon): Remove both of these conversions when Skia bug 5019 is fixed.
+inline GrBackendObject GrGLTextureInfoToGrBackendObject(
+ const GrGLTextureInfo& info) {
+ return reinterpret_cast<GrBackendObject>(&info);
+}
+
+inline const GrGLTextureInfo* GrBackendObjectToGrGLTextureInfo(
+ GrBackendObject object) {
+ return reinterpret_cast<const GrGLTextureInfo*>(object);
+}
+
+} // namespace skia
+
+#endif // SKIA_EXT_TEXTURE_HANDLE_H_
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
index 25df126..26e1a68 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -39,10 +39,12 @@
#include "public/platform/WebGraphicsContext3DProvider.h"
#include "public/platform/WebScheduler.h"
#include "public/platform/WebTraceLocation.h"
+#include "skia/ext/texture_handle.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrContext.h"
+#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "wtf/RefCountedLeakCounter.h"
namespace {
@@ -640,16 +642,15 @@ bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox,
if (RuntimeEnabledFeatures::forceDisable2dCanvasCopyOnWriteEnabled())
m_surface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMode);
- // Need to flush skia's internal queue because texture is about to be accessed directly
- grContext->flush();
-
// Because of texture sharing with the compositor, we must invalidate
// the state cached in skia so that the deferred copy on write
// in SkSurface_Gpu does not make any false assumptions.
mailboxInfo.m_image->getTexture()->textureParamsModified();
mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D;
- webContext->bindTexture(GL_TEXTURE_2D, mailboxInfo.m_image->getTexture()->getTextureHandle());
+ // Passing true because we need to flush skia's internal queue since texture is about to be accessed directly
+ GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_image->getTextureHandle(true))->fID;
+ webContext->bindTexture(GL_TEXTURE_2D, textureID);
webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
index 31dc743..a1e80dd 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
@@ -39,10 +39,12 @@
#include "public/platform/WebTaskRunner.h"
#include "public/platform/WebThread.h"
#include "public/platform/WebTraceLocation.h"
+#include "skia/ext/texture_handle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/gpu/GrContext.h"
+#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "third_party/skia/include/gpu/gl/SkNullGLContext.h"
#include "wtf/RefPtr.h"
@@ -160,8 +162,8 @@ protected:
::testing::Mock::VerifyAndClearExpectations(&mainMock);
- unsigned textureId = bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnknown)->getTextureHandle(true);
- EXPECT_EQ(textureId, 0u);
+ const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo(bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnknown)->getTextureHandle(true));
+ EXPECT_EQ(textureInfo, nullptr);
::testing::Mock::VerifyAndClearExpectations(&mainMock);
} // bridge goes out of scope here
diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
index 56f5a20..58b33b4 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
@@ -50,7 +50,9 @@
#include "public/platform/WebExternalTextureMailbox.h"
#include "public/platform/WebGraphicsContext3D.h"
#include "public/platform/WebGraphicsContext3DProvider.h"
+#include "skia/ext/texture_handle.h"
#include "third_party/skia/include/core/SkPicture.h"
+#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "wtf/ArrayBufferContents.h"
#include "wtf/MathExtras.h"
#include "wtf/Vector.h"
@@ -193,7 +195,7 @@ bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
ASSERT(textureImage->isTextureBacked()); // isAccelerated() check above should guarantee this
// Get the texture ID, flushing pending operations if needed.
- Platform3DObject textureId = textureImage->getTextureHandle(true);
+ Platform3DObject textureId = skia::GrBackendObjectToGrGLTextureInfo(textureImage->getTextureHandle(true))->fID;
if (!textureId)
return false;
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp b/third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp
index ade6a31..b3028e5 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp
+++ b/third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp
@@ -32,6 +32,7 @@
#include "public/platform/Platform.h"
#include "public/platform/WebGraphicsContext3DProvider.h"
+#include "skia/ext/texture_handle.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefPtr.h"
@@ -67,7 +68,7 @@ Platform3DObject AcceleratedImageBufferSurface::getBackingTextureHandleForOverwr
{
if (!m_surface)
return 0;
- return m_surface->getTextureHandle(SkSurface::kDiscardWrite_TextureHandleAccess);
+ return skia::GrBackendObjectToGrGLTextureInfo(m_surface->getTextureHandle(SkSurface::kDiscardWrite_TextureHandleAccess))->fID;
}
} // namespace blink