Commit da8c644e authored by xlai's avatar xlai Committed by Commit Bot

Clean up duplicate function WebGLRenderingContextBase::MakeImagesnapshot()

A follow-up CL to do more cleaning on code duplication in WebGL rendering context,
after https://chromium-review.googlesource.com/943761.

Bug: 794706
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I8c9de02c113a36b4c6b95bb1dd3af25079b4c4d3
Reviewed-on: https://chromium-review.googlesource.com/946899Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Olivia Lai <xlai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540721}
parent f16ef544
...@@ -751,13 +751,9 @@ WebGLRenderingContextBase::GetStaticBitmapImage( ...@@ -751,13 +751,9 @@ WebGLRenderingContextBase::GetStaticBitmapImage(
if (!GetDrawingBuffer()) if (!GetDrawingBuffer())
return nullptr; return nullptr;
if (CreationAttributes().preserve_drawing_buffer) { if (CreationAttributes().preserve_drawing_buffer)
int width = GetDrawingBuffer()->Size().Width(); return GetImage();
int height = GetDrawingBuffer()->Size().Height();
SkImageInfo image_info = SkImageInfo::Make(
width, height, kRGBA_8888_SkColorType, ColorParams().GetSkAlphaType());
return MakeImageSnapshot(image_info);
}
return GetDrawingBuffer()->TransferToStaticBitmapImage(out_release_callback); return GetDrawingBuffer()->TransferToStaticBitmapImage(out_release_callback);
} }
...@@ -784,34 +780,6 @@ scoped_refptr<StaticBitmapImage> WebGLRenderingContextBase::GetImage( ...@@ -784,34 +780,6 @@ scoped_refptr<StaticBitmapImage> WebGLRenderingContextBase::GetImage(
return resource_provider->Snapshot(); return resource_provider->Snapshot();
} }
scoped_refptr<StaticBitmapImage> WebGLRenderingContextBase::MakeImageSnapshot(
SkImageInfo& image_info) const {
GetDrawingBuffer()->ResolveAndBindForReadAndDraw();
base::WeakPtr<WebGraphicsContext3DProviderWrapper> shared_context_wrapper =
SharedGpuContext::ContextProviderWrapper();
if (!shared_context_wrapper)
return nullptr;
gpu::gles2::GLES2Interface* gl =
shared_context_wrapper->ContextProvider()->ContextGL();
SkSurfaceProps disable_lcd_props(0, kUnknown_SkPixelGeometry);
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(
shared_context_wrapper->ContextProvider()->GetGrContext(),
SkBudgeted::kYes, image_info, 0,
image_info.alphaType() == kOpaque_SkAlphaType ? nullptr
: &disable_lcd_props);
const GrGLTextureInfo* texture_info = skia::GrBackendObjectToGrGLTextureInfo(
surface->getTextureHandle(SkSurface::kDiscardWrite_TextureHandleAccess));
GLuint texture_id = texture_info->fID;
GLenum texture_target = texture_info->fTarget;
GetDrawingBuffer()->CopyToPlatformTexture(
gl, texture_target, texture_id, true, false, IntPoint(0, 0),
IntRect(IntPoint(0, 0), GetDrawingBuffer()->Size()), kBackBuffer);
return AcceleratedStaticBitmapImage::CreateFromSkImage(
surface->makeImageSnapshot(), std::move(shared_context_wrapper));
}
ScriptPromise WebGLRenderingContextBase::setCompatibleXRDevice( ScriptPromise WebGLRenderingContextBase::setCompatibleXRDevice(
ScriptState* script_state, ScriptState* script_state,
XRDevice* xr_device) { XRDevice* xr_device) {
......
...@@ -592,7 +592,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext, ...@@ -592,7 +592,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
// object. // object.
}; };
scoped_refptr<StaticBitmapImage> GetImage(AccelerationHint) const override; scoped_refptr<StaticBitmapImage> GetImage(
AccelerationHint = kPreferAcceleration) const override;
void SetFilterQuality(SkFilterQuality) override; void SetFilterQuality(SkFilterQuality) override;
bool IsWebGL2OrHigher() { return Version() >= 2; } bool IsWebGL2OrHigher() { return Version() >= 2; }
...@@ -1698,7 +1699,6 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext, ...@@ -1698,7 +1699,6 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
GLint, GLint,
const IntRect&); const IntRect&);
scoped_refptr<StaticBitmapImage> MakeImageSnapshot(SkImageInfo&) const;
const unsigned version_; const unsigned version_;
bool IsPaintable() const final { return GetDrawingBuffer(); } bool IsPaintable() const final { return GetDrawingBuffer(); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment