| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 */ | 31 */ |
| 32 | 32 |
| 33 #include "platform/graphics/ImageBuffer.h" | 33 #include "platform/graphics/ImageBuffer.h" |
| 34 | 34 |
| 35 #include <memory> | 35 #include <memory> |
| 36 #include "gpu/command_buffer/client/gles2_interface.h" | 36 #include "gpu/command_buffer/client/gles2_interface.h" |
| 37 #include "gpu/command_buffer/common/mailbox.h" | 37 #include "gpu/command_buffer/common/mailbox.h" |
| 38 #include "gpu/command_buffer/common/sync_token.h" | 38 #include "gpu/command_buffer/common/sync_token.h" |
| 39 #include "platform/RuntimeEnabledFeatures.h" | 39 #include "platform/RuntimeEnabledFeatures.h" |
| 40 #include "platform/geometry/IntRect.h" | 40 #include "platform/geometry/IntRect.h" |
| 41 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 41 #include "platform/graphics/CanvasHeuristicParameters.h" |
| 42 #include "platform/graphics/GraphicsContext.h" | 42 #include "platform/graphics/GraphicsContext.h" |
| 43 #include "platform/graphics/ImageBufferClient.h" | 43 #include "platform/graphics/ImageBufferClient.h" |
| 44 #include "platform/graphics/RecordingImageBufferSurface.h" | 44 #include "platform/graphics/RecordingImageBufferSurface.h" |
| 45 #include "platform/graphics/StaticBitmapImage.h" | 45 #include "platform/graphics/StaticBitmapImage.h" |
| 46 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 46 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 47 #include "platform/graphics/gpu/DrawingBuffer.h" | 47 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 48 #include "platform/graphics/gpu/Extensions3DUtil.h" | 48 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 49 #include "platform/graphics/paint/PaintImage.h" | 49 #include "platform/graphics/paint/PaintImage.h" |
| 50 #include "platform/graphics/paint/PaintRecord.h" | 50 #include "platform/graphics/paint/PaintRecord.h" |
| 51 #include "platform/graphics/skia/SkiaUtils.h" | 51 #include "platform/graphics/skia/SkiaUtils.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 int y) { | 140 int y) { |
| 141 return surface_->WritePixels(info, pixels, row_bytes, x, y); | 141 return surface_->WritePixels(info, pixels, row_bytes, x, y); |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool ImageBuffer::IsSurfaceValid() const { | 144 bool ImageBuffer::IsSurfaceValid() const { |
| 145 return surface_->IsValid(); | 145 return surface_->IsValid(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void ImageBuffer::FinalizeFrame() { | 148 void ImageBuffer::FinalizeFrame() { |
| 149 if (IsAccelerated() && | 149 if (IsAccelerated() && |
| 150 ExpensiveCanvasHeuristicParameters::kGPUReadbackForcesNoAcceleration && | 150 CanvasHeuristicParameters::kGPUReadbackForcesNoAcceleration && |
| 151 !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled()) { | 151 !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled()) { |
| 152 if (gpu_readback_invoked_in_current_frame_) { | 152 if (gpu_readback_invoked_in_current_frame_) { |
| 153 gpu_readback_successive_frames_++; | 153 gpu_readback_successive_frames_++; |
| 154 gpu_readback_invoked_in_current_frame_ = false; | 154 gpu_readback_invoked_in_current_frame_ = false; |
| 155 } else { | 155 } else { |
| 156 gpu_readback_successive_frames_ = 0; | 156 gpu_readback_successive_frames_ = 0; |
| 157 } | 157 } |
| 158 | 158 |
| 159 if (gpu_readback_successive_frames_ >= | 159 if (gpu_readback_successive_frames_ >= |
| 160 ExpensiveCanvasHeuristicParameters::kGPUReadbackMinSuccessiveFrames) { | 160 CanvasHeuristicParameters::kGPUReadbackMinSuccessiveFrames) { |
| 161 DisableAcceleration(); | 161 DisableAcceleration(); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 surface_->FinalizeFrame(); | 165 surface_->FinalizeFrame(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void ImageBuffer::DoPaintInvalidation(const FloatRect& dirty_rect) { | 168 void ImageBuffer::DoPaintInvalidation(const FloatRect& dirty_rect) { |
| 169 surface_->DoPaintInvalidation(dirty_rect); | 169 surface_->DoPaintInvalidation(dirty_rect); |
| 170 } | 170 } |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); | 580 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); |
| 581 | 581 |
| 582 Vector<unsigned char> result; | 582 Vector<unsigned char> result; |
| 583 if (!EncodeImage(mime_type, quality, &result)) | 583 if (!EncodeImage(mime_type, quality, &result)) |
| 584 return "data:,"; | 584 return "data:,"; |
| 585 | 585 |
| 586 return "data:" + mime_type + ";base64," + Base64Encode(result); | 586 return "data:" + mime_type + ";base64," + Base64Encode(result); |
| 587 } | 587 } |
| 588 | 588 |
| 589 } // namespace blink | 589 } // namespace blink |
| OLD | NEW |