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 38 matching lines...) Loading... |
49 return; | 49 return; |
50 GrContext* grContext = SharedGpuContext::gr(); | 50 GrContext* grContext = SharedGpuContext::gr(); |
51 m_contextId = SharedGpuContext::contextId(); | 51 m_contextId = SharedGpuContext::contextId(); |
52 CHECK(grContext); | 52 CHECK(grContext); |
53 | 53 |
54 SkAlphaType alphaType = | 54 SkAlphaType alphaType = |
55 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; | 55 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
56 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, | 56 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, |
57 alphaType, colorSpace); | 57 alphaType, colorSpace); |
58 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); | 58 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); |
59 m_surface = SkSurface::MakeRenderTarget( | 59 m_surface = PaintSurface::MakeRenderTarget( |
60 grContext, SkBudgeted::kYes, info, 0 /* sampleCount */, | 60 grContext, SkBudgeted::kYes, info, 0 /* sampleCount */, |
61 Opaque == opacityMode ? nullptr : &disableLCDProps); | 61 Opaque == opacityMode ? nullptr : &disableLCDProps); |
62 if (!m_surface) | 62 if (!m_surface) |
63 return; | 63 return; |
64 | |
65 m_canvas = WTF::wrapUnique(new PaintCanvas(m_surface->getCanvas())); | |
66 clear(); | 64 clear(); |
67 | 65 |
68 // Always save an initial frame, to support resetting the top level matrix | 66 // Always save an initial frame, to support resetting the top level matrix |
69 // and clip. | 67 // and clip. |
70 m_canvas->save(); | 68 m_surface->getCanvas()->save(); |
71 } | 69 } |
72 | 70 |
73 bool AcceleratedImageBufferSurface::isValid() const { | 71 bool AcceleratedImageBufferSurface::isValid() const { |
74 return m_surface && SharedGpuContext::isValid() && | 72 return m_surface && SharedGpuContext::isValid() && |
75 m_contextId == SharedGpuContext::contextId(); | 73 m_contextId == SharedGpuContext::contextId(); |
76 } | 74 } |
77 | 75 |
78 sk_sp<SkImage> AcceleratedImageBufferSurface::newImageSnapshot(AccelerationHint, | 76 sk_sp<SkImage> AcceleratedImageBufferSurface::newImageSnapshot(AccelerationHint, |
79 SnapshotReason) { | 77 SnapshotReason) { |
80 return m_surface->makeImageSnapshot(); | 78 return m_surface->makeImageSnapshot(); |
81 } | 79 } |
82 | 80 |
83 GLuint AcceleratedImageBufferSurface::getBackingTextureHandleForOverwrite() { | 81 GLuint AcceleratedImageBufferSurface::getBackingTextureHandleForOverwrite() { |
84 if (!m_surface) | 82 if (!m_surface) |
85 return 0; | 83 return 0; |
86 return skia::GrBackendObjectToGrGLTextureInfo( | 84 return skia::GrBackendObjectToGrGLTextureInfo( |
87 m_surface->getTextureHandle( | 85 m_surface->getTextureHandle( |
88 SkSurface::kDiscardWrite_TextureHandleAccess)) | 86 PaintSurface::kDiscardWrite_TextureHandleAccess)) |
89 ->fID; | 87 ->fID; |
90 } | 88 } |
91 | 89 |
92 } // namespace blink | 90 } // namespace blink |
OLD | NEW |