| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "platform/wtf/PtrUtil.h" | 35 #include "platform/wtf/PtrUtil.h" |
| 36 #include "platform/wtf/RefPtr.h" | 36 #include "platform/wtf/RefPtr.h" |
| 37 #include "skia/ext/texture_handle.h" | 37 #include "skia/ext/texture_handle.h" |
| 38 #include "third_party/skia/include/gpu/GrContext.h" | 38 #include "third_party/skia/include/gpu/GrContext.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 AcceleratedImageBufferSurface::AcceleratedImageBufferSurface( | 42 AcceleratedImageBufferSurface::AcceleratedImageBufferSurface( |
| 43 const IntSize& size, | 43 const IntSize& size, |
| 44 OpacityMode opacity_mode, | 44 OpacityMode opacity_mode, |
| 45 sk_sp<SkColorSpace> color_space, | 45 const CanvasColorParams& color_params) |
| 46 SkColorType color_type) | 46 : ImageBufferSurface(size, opacity_mode, color_params) { |
| 47 : ImageBufferSurface(size, opacity_mode, color_space, color_type) { | |
| 48 if (!SharedGpuContext::IsValid()) | 47 if (!SharedGpuContext::IsValid()) |
| 49 return; | 48 return; |
| 50 GrContext* gr_context = SharedGpuContext::Gr(); | 49 GrContext* gr_context = SharedGpuContext::Gr(); |
| 51 context_id_ = SharedGpuContext::ContextId(); | 50 context_id_ = SharedGpuContext::ContextId(); |
| 52 CHECK(gr_context); | 51 CHECK(gr_context); |
| 53 | 52 |
| 54 SkAlphaType alpha_type = | 53 SkAlphaType alpha_type = |
| 55 (kOpaque == opacity_mode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; | 54 (kOpaque == opacity_mode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
| 56 SkImageInfo info = SkImageInfo::Make(size.Width(), size.Height(), color_type, | 55 SkImageInfo info = SkImageInfo::Make( |
| 57 alpha_type, color_space); | 56 size.Width(), size.Height(), color_params.GetSkColorType(), alpha_type, |
| 57 color_params.GetSkColorSpaceForSkSurfaces()); |
| 58 SkSurfaceProps disable_lcd_props(0, kUnknown_SkPixelGeometry); | 58 SkSurfaceProps disable_lcd_props(0, kUnknown_SkPixelGeometry); |
| 59 surface_ = SkSurface::MakeRenderTarget( | 59 surface_ = SkSurface::MakeRenderTarget( |
| 60 gr_context, SkBudgeted::kYes, info, 0 /* sampleCount */, | 60 gr_context, SkBudgeted::kYes, info, 0 /* sampleCount */, |
| 61 kOpaque == opacity_mode ? nullptr : &disable_lcd_props); | 61 kOpaque == opacity_mode ? nullptr : &disable_lcd_props); |
| 62 if (!surface_) | 62 if (!surface_) |
| 63 return; | 63 return; |
| 64 | 64 |
| 65 canvas_ = WTF::WrapUnique(new SkiaPaintCanvas(surface_->getCanvas())); | 65 canvas_ = WTF::WrapUnique(new SkiaPaintCanvas(surface_->getCanvas())); |
| 66 Clear(); | 66 Clear(); |
| 67 | 67 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 83 GLuint AcceleratedImageBufferSurface::GetBackingTextureHandleForOverwrite() { | 83 GLuint AcceleratedImageBufferSurface::GetBackingTextureHandleForOverwrite() { |
| 84 if (!surface_) | 84 if (!surface_) |
| 85 return 0; | 85 return 0; |
| 86 return skia::GrBackendObjectToGrGLTextureInfo( | 86 return skia::GrBackendObjectToGrGLTextureInfo( |
| 87 surface_->getTextureHandle( | 87 surface_->getTextureHandle( |
| 88 SkSurface::kDiscardWrite_TextureHandleAccess)) | 88 SkSurface::kDiscardWrite_TextureHandleAccess)) |
| 89 ->fID; | 89 ->fID; |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace blink | 92 } // namespace blink |
| OLD | NEW |