Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: webkit/tools/pepper_test_plugin/plugin_object.cc

Issue 547005: This CL is for Neb. It contains his change 501124, with conflicts merged. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/tools/pepper_test_plugin/plugin_object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/tools/pepper_test_plugin/plugin_object.cc
===================================================================
--- webkit/tools/pepper_test_plugin/plugin_object.cc (revision 35905)
+++ webkit/tools/pepper_test_plugin/plugin_object.cc (working copy)
@@ -28,12 +28,16 @@
#include <stdio.h>
#include <string>
+#if defined(INDEPENDENT_PLUGIN)
+#define CHECK(x)
+#else
#include "base/logging.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/client/gles2_demo_cc.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
+#endif
#include "webkit/tools/pepper_test_plugin/event_handler.h"
#include "webkit/tools/pepper_test_plugin/test_object.h"
@@ -210,7 +214,26 @@
// Bitmap painting -------------------------------------------------------------
-void DrawSampleBitmap(SkCanvas& canvas, int width, int height) {
+#if defined(INDEPENDENT_PLUGIN)
+void DrawSampleBitmap(void *region, int width, int height) {
+ int32 *bitmap = reinterpret_cast<int32 *>(region);
+
+ for (int h = 0; h < height; ++h) {
+ uint8 opacity = (h * 0xff) / height;
+ for (int w = 0; w < width; ++w) {
+ // kudos to apatrick for noticing we're using premultiplied alpha
+ uint8 greenness = (w * opacity) / width;
+ *bitmap++ = (opacity << 24) | (greenness << 8);
+ }
+ }
+}
+#else
+void DrawSampleBitmap(void *region, int width, int height) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.setPixels(region);
+
+ SkCanvas canvas(bitmap);
SkRect rect;
rect.set(SkIntToScalar(0), SkIntToScalar(0),
SkIntToScalar(width), SkIntToScalar(height));
@@ -233,7 +256,7 @@
canvas.drawPath(path, paint);
}
-
+#endif
void FlushCallback(NPP instance, NPDeviceContext* context,
NPError err, void* user_data) {
}
@@ -290,26 +313,22 @@
void PluginObject::SetWindow(const NPWindow& window) {
if (dimensions_ == 2) {
- size_.set_width(window.width);
- size_.set_height(window.height);
+ width_ = window.width;
+ height_ = window.height;
NPDeviceContext2DConfig config;
NPDeviceContext2D context;
device2d_->initializeContext(npp_, &config, &context);
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, window.width, window.height);
- bitmap.setPixels(context.region);
+ DrawSampleBitmap(context.region, width_, height_);
- SkCanvas canvas(bitmap);
- DrawSampleBitmap(canvas, window.width, window.height);
-
// TODO(brettw) figure out why this cast is necessary, the functions seem to
// match. Could be a calling convention mismatch?
NPDeviceFlushContextCallbackPtr callback =
reinterpret_cast<NPDeviceFlushContextCallbackPtr>(&FlushCallback);
device2d_->flushContext(npp_, &context, callback, NULL);
} else {
+#if !defined(INDEPENDENT_PLUGIN)
if (!command_buffer_.get()) {
if (!InitializeCommandBuffer())
return;
@@ -319,10 +338,12 @@
// Schedule the first call to Draw.
browser->pluginthreadasynccall(npp_, Draw3DCallback, this);
+#endif
}
}
void PluginObject::Draw3D() {
+#if !defined(INDEPENDENT_PLUGIN)
// Render some stuff.
gles2::g_gl_impl = gles2_implementation_.get();
GLFromCPPTestFunction();
@@ -332,9 +353,11 @@
// Schedule another call to Draw.
browser->pluginthreadasynccall(npp_, Draw3DCallback, this);
+#endif
}
bool PluginObject::InitializeCommandBuffer() {
+#if !defined(INDEPENDENT_PLUGIN)
const static int32 kCommandBufferSize = 512 * 1024;
command_buffer_.reset(new CommandBufferPepper(npp_, browser));
if (command_buffer_->Initialize(kCommandBufferSize)) {
@@ -360,6 +383,7 @@
}
command_buffer_.reset();
+#endif
return false;
}
« no previous file with comments | « webkit/tools/pepper_test_plugin/plugin_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698